@happyvertical/smrt-inventory 0.49.2 → 0.49.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/manifest.json +167 -18
- package/dist/smrt-knowledge.json +4 -4
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ObjectRegistry, SmrtCollection, SmrtObject, field, resolveDatabase, smr
|
|
|
2
2
|
import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy";
|
|
3
3
|
import { createLogger } from "@happyvertical/logger";
|
|
4
4
|
//#region src/__smrt-register__.ts
|
|
5
|
-
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-inventory\",\"packageVersion\":\"0.49.2\",\"objects\":{\"@happyvertical/smrt-inventory:InventoryLocationCollection\":{\"name\":\"inventorylocationcollection\",\"className\":\"InventoryLocationCollection\",\"qualifiedName\":\"@happyvertical/smrt-inventory:InventoryLocationCollection\",\"collection\":\"inventorylocations\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/collections/InventoryLocationCollection.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{},\"methods\":{\"findByCode\":{\"name\":\"findByCode\",\"async\":true,\"parameters\":[{\"name\":\"code\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<InventoryLocation | null>\",\"isStatic\":false,\"isPublic\":true},\"findByKind\":{\"name\":\"findByKind\",\"async\":true,\"parameters\":[{\"name\":\"kind\",\"type\":\"InventoryLocationKind\",\"optional\":false}],\"returnType\":\"Promise<InventoryLocation[]>\",\"isStatic\":false,\"isPublic\":true},\"findByPlace\":{\"name\":\"findByPlace\",\"async\":true,\"parameters\":[{\"name\":\"placeId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<InventoryLocation[]>\",\"isStatic\":false,\"isPublic\":true},\"findActive\":{\"name\":\"findActive\",\"async\":true,\"parameters\":[{\"name\":\"kind\",\"type\":\"InventoryLocationKind\",\"optional\":true}],\"returnType\":\"Promise<InventoryLocation[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"inventory_locations\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"InventoryLocation\",\"exportName\":\"InventoryLocationCollection\",\"collectionExportName\":\"InventoryLocationCollectionCollection\",\"schema\":{\"tableName\":\"inventory_locations\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_locations\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"inventory_locations_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true},{\"name\":\"inventory_locations_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"a8cccfa5\"}},\"@happyvertical/smrt-inventory:StockLevelCollection\":{\"name\":\"stocklevelcollection\",\"className\":\"StockLevelCollection\",\"qualifiedName\":\"@happyvertical/smrt-inventory:StockLevelCollection\",\"collection\":\"stocklevels\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/collections/StockLevelCollection.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{},\"methods\":{\"getLevel\":{\"name\":\"getLevel\",\"async\":true,\"parameters\":[{\"name\":\"skuId\",\"type\":\"string\",\"optional\":false},{\"name\":\"locationId\",\"type\":\"string\",\"optional\":false},{\"name\":\"state\",\"type\":\"StockState\",\"optional\":true,\"default\":\"available\"}],\"returnType\":\"Promise<StockLevel | null>\",\"isStatic\":false,\"isPublic\":true},\"findBySku\":{\"name\":\"findBySku\",\"async\":true,\"parameters\":[{\"name\":\"skuId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<StockLevel[]>\",\"isStatic\":false,\"isPublic\":true},\"findByLocation\":{\"name\":\"findByLocation\",\"async\":true,\"parameters\":[{\"name\":\"locationId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<StockLevel[]>\",\"isStatic\":false,\"isPublic\":true},\"totalForSku\":{\"name\":\"totalForSku\",\"async\":true,\"parameters\":[{\"name\":\"skuId\",\"type\":\"string\",\"optional\":false},{\"name\":\"state\",\"type\":\"StockState\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"totalForLocation\":{\"name\":\"totalForLocation\",\"async\":true,\"parameters\":[{\"name\":\"locationId\",\"type\":\"string\",\"optional\":false},{\"name\":\"state\",\"type\":\"StockState\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"inventory_stock_levels\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"StockLevel\",\"exportName\":\"StockLevelCollection\",\"collectionExportName\":\"StockLevelCollectionCollection\",\"schema\":{\"tableName\":\"inventory_stock_levels\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_stock_levels\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"inventory_stock_levels_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true},{\"name\":\"inventory_stock_levels_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"d858b8a5\"}},\"@happyvertical/smrt-inventory:StockMovementCollection\":{\"name\":\"stockmovementcollection\",\"className\":\"StockMovementCollection\",\"qualifiedName\":\"@happyvertical/smrt-inventory:StockMovementCollection\",\"collection\":\"stockmovements\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/collections/StockMovementCollection.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{},\"methods\":{\"findBySku\":{\"name\":\"findBySku\",\"async\":true,\"parameters\":[{\"name\":\"skuId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<StockMovement[]>\",\"isStatic\":false,\"isPublic\":true},\"findByLocation\":{\"name\":\"findByLocation\",\"async\":true,\"parameters\":[{\"name\":\"locationId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<StockMovement[]>\",\"isStatic\":false,\"isPublic\":true},\"findBySource\":{\"name\":\"findBySource\",\"async\":true,\"parameters\":[{\"name\":\"sourceType\",\"type\":\"string\",\"optional\":false},{\"name\":\"sourceId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<StockMovement[]>\",\"isStatic\":false,\"isPublic\":true},\"findByReason\":{\"name\":\"findByReason\",\"async\":true,\"parameters\":[{\"name\":\"reasonCode\",\"type\":\"StockMovementReason\",\"optional\":false}],\"returnType\":\"Promise<StockMovement[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"inventory_stock_movements\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"StockMovement\",\"exportName\":\"StockMovementCollection\",\"collectionExportName\":\"StockMovementCollectionCollection\",\"schema\":{\"tableName\":\"inventory_stock_movements\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_stock_movements\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"}},\"indexes\":[{\"name\":\"inventory_stock_movements_slug_context_idx\",\"columns\":[\"slug\",\"context\"],\"unique\":true},{\"name\":\"inventory_stock_movements_created_at_idx\",\"columns\":[\"created_at\"]}],\"version\":\"54d9d8f6\"}},\"@happyvertical/smrt-inventory:InventoryLocation\":{\"name\":\"inventorylocation\",\"className\":\"InventoryLocation\",\"qualifiedName\":\"@happyvertical/smrt-inventory:InventoryLocation\",\"collection\":\"inventorylocations\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/models/InventoryLocation.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"code\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"kind\":{\"type\":\"text\",\"required\":false,\"default\":\"warehouse\"},\"placeId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"active\":{\"type\":\"boolean\",\"required\":false,\"default\":true}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"inventory_locations\",\"conflictColumns\":[\"code\",\"tenant_id\"],\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"InventoryLocation\",\"collectionExportName\":\"InventoryLocationCollection\",\"validationRules\":[{\"field\":\"code\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"inventory_locations\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_locations\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"code\\\" TEXT NOT NULL DEFAULT '',\\n \\\"name\\\" TEXT DEFAULT '',\\n \\\"kind\\\" TEXT DEFAULT 'warehouse',\\n \\\"place_id\\\" TEXT DEFAULT '',\\n \\\"active\\\" BOOLEAN DEFAULT TRUE\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"code\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"kind\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"warehouse\"},\"place_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"active\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":true}},\"indexes\":[{\"name\":\"inventory_locations_code_tenant_id_idx\",\"columns\":[\"code\",\"tenant_id\"],\"unique\":true},{\"name\":\"inventory_locations_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"inventory_locations_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"401c28a1\"}},\"@happyvertical/smrt-inventory:StockLevel\":{\"name\":\"stocklevel\",\"className\":\"StockLevel\",\"qualifiedName\":\"@happyvertical/smrt-inventory:StockLevel\",\"collection\":\"stocklevels\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/models/StockLevel.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"skuId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"locationId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"state\":{\"type\":\"text\",\"required\":true,\"default\":\"available\",\"_meta\":{\"required\":true}},\"qty\":{\"type\":\"decimal\",\"required\":false,\"_meta\":{}}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"inventory_stock_levels\",\"conflictColumns\":[\"sku_id\",\"location_id\",\"state\",\"tenant_id\"],\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"StockLevel\",\"collectionExportName\":\"StockLevelCollection\",\"validationRules\":[{\"field\":\"skuId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"locationId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"state\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"inventory_stock_levels\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_stock_levels\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"sku_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"location_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"state\\\" TEXT NOT NULL DEFAULT 'available',\\n \\\"qty\\\" REAL\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"sku_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"location_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"state\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"available\"},\"qty\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"inventory_stock_levels_sku_id_location_id_idx\",\"columns\":[\"sku_id\",\"location_id\",\"state\",\"tenant_id\"],\"unique\":true},{\"name\":\"inventory_stock_levels_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"inventory_stock_levels_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"7b08362b\"}},\"@happyvertical/smrt-inventory:StockMovement\":{\"name\":\"stockmovement\",\"className\":\"StockMovement\",\"qualifiedName\":\"@happyvertical/smrt-inventory:StockMovement\",\"collection\":\"stockmovements\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/models/StockMovement.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"skuId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"locationId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"fromState\":{\"type\":\"text\",\"required\":false},\"toState\":{\"type\":\"text\",\"required\":false},\"qty\":{\"type\":\"decimal\",\"required\":false,\"_meta\":{}},\"reasonCode\":{\"type\":\"text\",\"required\":true,\"default\":\"adjustment\",\"_meta\":{\"required\":true}},\"sourceType\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"sourceId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"note\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"occurredAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"inventory_stock_movements\",\"conflictColumns\":[\"id\"],\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"StockMovement\",\"collectionExportName\":\"StockMovementCollection\",\"validationRules\":[{\"field\":\"skuId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"locationId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"reasonCode\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"inventory_stock_movements\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_stock_movements\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"sku_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"location_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"from_state\\\" TEXT,\\n \\\"to_state\\\" TEXT,\\n \\\"qty\\\" REAL,\\n \\\"reason_code\\\" TEXT NOT NULL DEFAULT 'adjustment',\\n \\\"source_type\\\" TEXT DEFAULT '',\\n \\\"source_id\\\" TEXT DEFAULT '',\\n \\\"note\\\" TEXT DEFAULT '',\\n \\\"occurred_at\\\" TIMESTAMP\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"sku_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"location_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"from_state\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"to_state\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"qty\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"reason_code\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"adjustment\"},\"source_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"note\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"occurred_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"inventory_stock_movements_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"inventory_stock_movements_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"3c5a0445\"}}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-tenancy\"]}"));
|
|
5
|
+
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-inventory\",\"packageVersion\":\"0.49.4\",\"objects\":{\"@happyvertical/smrt-inventory:InventoryLocationCollection\":{\"name\":\"inventorylocationcollection\",\"className\":\"InventoryLocationCollection\",\"qualifiedName\":\"@happyvertical/smrt-inventory:InventoryLocationCollection\",\"collection\":\"inventorylocations\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/collections/InventoryLocationCollection.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{},\"methods\":{\"findByCode\":{\"name\":\"findByCode\",\"async\":true,\"parameters\":[{\"name\":\"code\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<InventoryLocation | null>\",\"isStatic\":false,\"isPublic\":true},\"findByKind\":{\"name\":\"findByKind\",\"async\":true,\"parameters\":[{\"name\":\"kind\",\"type\":\"InventoryLocationKind\",\"optional\":false}],\"returnType\":\"Promise<InventoryLocation[]>\",\"isStatic\":false,\"isPublic\":true},\"findByPlace\":{\"name\":\"findByPlace\",\"async\":true,\"parameters\":[{\"name\":\"placeId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<InventoryLocation[]>\",\"isStatic\":false,\"isPublic\":true},\"findActive\":{\"name\":\"findActive\",\"async\":true,\"parameters\":[{\"name\":\"kind\",\"type\":\"InventoryLocationKind\",\"optional\":true}],\"returnType\":\"Promise<InventoryLocation[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"inventory_locations\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"InventoryLocation\",\"exportName\":\"InventoryLocationCollection\",\"collectionExportName\":\"InventoryLocationCollectionCollection\",\"schema\":{\"tableName\":\"inventory_locations\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_locations\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"code\\\" TEXT NOT NULL DEFAULT '',\\n \\\"name\\\" TEXT DEFAULT '',\\n \\\"kind\\\" TEXT DEFAULT 'warehouse',\\n \\\"place_id\\\" TEXT DEFAULT '',\\n \\\"active\\\" BOOLEAN DEFAULT TRUE\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"code\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"kind\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"warehouse\"},\"place_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"active\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":true}},\"indexes\":[{\"name\":\"inventory_locations_code_tenant_id_idx\",\"columns\":[\"code\",\"tenant_id\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"inventory_locations_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"inventory_locations_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"401c28a1\"}},\"@happyvertical/smrt-inventory:StockLevelCollection\":{\"name\":\"stocklevelcollection\",\"className\":\"StockLevelCollection\",\"qualifiedName\":\"@happyvertical/smrt-inventory:StockLevelCollection\",\"collection\":\"stocklevels\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/collections/StockLevelCollection.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{},\"methods\":{\"getLevel\":{\"name\":\"getLevel\",\"async\":true,\"parameters\":[{\"name\":\"skuId\",\"type\":\"string\",\"optional\":false},{\"name\":\"locationId\",\"type\":\"string\",\"optional\":false},{\"name\":\"state\",\"type\":\"StockState\",\"optional\":true,\"default\":\"available\"}],\"returnType\":\"Promise<StockLevel | null>\",\"isStatic\":false,\"isPublic\":true},\"findBySku\":{\"name\":\"findBySku\",\"async\":true,\"parameters\":[{\"name\":\"skuId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<StockLevel[]>\",\"isStatic\":false,\"isPublic\":true},\"findByLocation\":{\"name\":\"findByLocation\",\"async\":true,\"parameters\":[{\"name\":\"locationId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<StockLevel[]>\",\"isStatic\":false,\"isPublic\":true},\"totalForSku\":{\"name\":\"totalForSku\",\"async\":true,\"parameters\":[{\"name\":\"skuId\",\"type\":\"string\",\"optional\":false},{\"name\":\"state\",\"type\":\"StockState\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true},\"totalForLocation\":{\"name\":\"totalForLocation\",\"async\":true,\"parameters\":[{\"name\":\"locationId\",\"type\":\"string\",\"optional\":false},{\"name\":\"state\",\"type\":\"StockState\",\"optional\":true}],\"returnType\":\"Promise<number>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"inventory_stock_levels\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"StockLevel\",\"exportName\":\"StockLevelCollection\",\"collectionExportName\":\"StockLevelCollectionCollection\",\"schema\":{\"tableName\":\"inventory_stock_levels\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_stock_levels\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"sku_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"location_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"state\\\" TEXT NOT NULL DEFAULT 'available',\\n \\\"qty\\\" REAL\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"sku_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"location_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"state\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"available\"},\"qty\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"inventory_stock_levels_sku_id_location_id_idx\",\"columns\":[\"sku_id\",\"location_id\",\"state\",\"tenant_id\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"inventory_stock_levels_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"inventory_stock_levels_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"7b08362b\"}},\"@happyvertical/smrt-inventory:StockMovementCollection\":{\"name\":\"stockmovementcollection\",\"className\":\"StockMovementCollection\",\"qualifiedName\":\"@happyvertical/smrt-inventory:StockMovementCollection\",\"collection\":\"stockmovements\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/collections/StockMovementCollection.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{},\"methods\":{\"findBySku\":{\"name\":\"findBySku\",\"async\":true,\"parameters\":[{\"name\":\"skuId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<StockMovement[]>\",\"isStatic\":false,\"isPublic\":true},\"findByLocation\":{\"name\":\"findByLocation\",\"async\":true,\"parameters\":[{\"name\":\"locationId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<StockMovement[]>\",\"isStatic\":false,\"isPublic\":true},\"findBySource\":{\"name\":\"findBySource\",\"async\":true,\"parameters\":[{\"name\":\"sourceType\",\"type\":\"string\",\"optional\":false},{\"name\":\"sourceId\",\"type\":\"string\",\"optional\":false}],\"returnType\":\"Promise<StockMovement[]>\",\"isStatic\":false,\"isPublic\":true},\"findByReason\":{\"name\":\"findByReason\",\"async\":true,\"parameters\":[{\"name\":\"reasonCode\",\"type\":\"StockMovementReason\",\"optional\":false}],\"returnType\":\"Promise<StockMovement[]>\",\"isStatic\":false,\"isPublic\":true}},\"decoratorConfig\":{\"tableName\":\"inventory_stock_movements\"},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"StockMovement\",\"exportName\":\"StockMovementCollection\",\"collectionExportName\":\"StockMovementCollectionCollection\",\"schema\":{\"tableName\":\"inventory_stock_movements\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_stock_movements\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"sku_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"location_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"from_state\\\" TEXT,\\n \\\"to_state\\\" TEXT,\\n \\\"qty\\\" REAL,\\n \\\"reason_code\\\" TEXT NOT NULL DEFAULT 'adjustment',\\n \\\"source_type\\\" TEXT DEFAULT '',\\n \\\"source_id\\\" TEXT DEFAULT '',\\n \\\"note\\\" TEXT DEFAULT '',\\n \\\"occurred_at\\\" TIMESTAMP\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"sku_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"location_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"from_state\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"to_state\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"qty\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"reason_code\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"adjustment\"},\"source_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"note\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"occurred_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"inventory_stock_movements_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"inventory_stock_movements_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"3c5a0445\"}},\"@happyvertical/smrt-inventory:InventoryLocation\":{\"name\":\"inventorylocation\",\"className\":\"InventoryLocation\",\"qualifiedName\":\"@happyvertical/smrt-inventory:InventoryLocation\",\"collection\":\"inventorylocations\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/models/InventoryLocation.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"code\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"name\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"kind\":{\"type\":\"text\",\"required\":false,\"default\":\"warehouse\"},\"placeId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"active\":{\"type\":\"boolean\",\"required\":false,\"default\":true}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"inventory_locations\",\"conflictColumns\":[\"code\",\"tenant_id\"],\"api\":{\"include\":[\"list\",\"get\",\"create\",\"update\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":true,\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"InventoryLocation\",\"collectionExportName\":\"InventoryLocationCollection\",\"validationRules\":[{\"field\":\"code\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"inventory_locations\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_locations\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"code\\\" TEXT NOT NULL DEFAULT '',\\n \\\"name\\\" TEXT DEFAULT '',\\n \\\"kind\\\" TEXT DEFAULT 'warehouse',\\n \\\"place_id\\\" TEXT DEFAULT '',\\n \\\"active\\\" BOOLEAN DEFAULT TRUE\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"code\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"name\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"kind\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"warehouse\"},\"place_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"active\":{\"type\":\"BOOLEAN\",\"notNull\":false,\"unique\":false,\"default\":true}},\"indexes\":[{\"name\":\"inventory_locations_code_tenant_id_idx\",\"columns\":[\"code\",\"tenant_id\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"inventory_locations_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"inventory_locations_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"401c28a1\"}},\"@happyvertical/smrt-inventory:StockLevel\":{\"name\":\"stocklevel\",\"className\":\"StockLevel\",\"qualifiedName\":\"@happyvertical/smrt-inventory:StockLevel\",\"collection\":\"stocklevels\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/models/StockLevel.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"skuId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"locationId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"state\":{\"type\":\"text\",\"required\":true,\"default\":\"available\",\"_meta\":{\"required\":true}},\"qty\":{\"type\":\"decimal\",\"required\":false,\"_meta\":{}}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"inventory_stock_levels\",\"conflictColumns\":[\"sku_id\",\"location_id\",\"state\",\"tenant_id\"],\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"StockLevel\",\"collectionExportName\":\"StockLevelCollection\",\"validationRules\":[{\"field\":\"skuId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"locationId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"state\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"inventory_stock_levels\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_stock_levels\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"sku_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"location_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"state\\\" TEXT NOT NULL DEFAULT 'available',\\n \\\"qty\\\" REAL\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"sku_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"location_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"state\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"available\"},\"qty\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"inventory_stock_levels_sku_id_location_id_idx\",\"columns\":[\"sku_id\",\"location_id\",\"state\",\"tenant_id\"],\"unique\":true,\"nullsNotDistinct\":true},{\"name\":\"inventory_stock_levels_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"inventory_stock_levels_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"7b08362b\"}},\"@happyvertical/smrt-inventory:StockMovement\":{\"name\":\"stockmovement\",\"className\":\"StockMovement\",\"qualifiedName\":\"@happyvertical/smrt-inventory:StockMovement\",\"collection\":\"stockmovements\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/inventory/src/models/StockMovement.ts\",\"packageName\":\"@happyvertical/smrt-inventory\",\"fields\":{\"tenantId\":{\"type\":\"text\",\"required\":false,\"_meta\":{\"sqlType\":\"UUID\",\"nullable\":true,\"__tenancy\":{\"isTenantIdField\":true,\"autoFilter\":true,\"required\":false,\"autoPopulate\":true,\"nullable\":true,\"mode\":\"optional\",\"field\":\"tenantId\",\"allowSuperAdminBypass\":false}}},\"skuId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"locationId\":{\"type\":\"text\",\"required\":true,\"default\":\"\",\"_meta\":{\"required\":true}},\"fromState\":{\"type\":\"text\",\"required\":false},\"toState\":{\"type\":\"text\",\"required\":false},\"qty\":{\"type\":\"decimal\",\"required\":false,\"_meta\":{}},\"reasonCode\":{\"type\":\"text\",\"required\":true,\"default\":\"adjustment\",\"_meta\":{\"required\":true}},\"sourceType\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"sourceId\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"note\":{\"type\":\"text\",\"required\":false,\"default\":\"\"},\"occurredAt\":{\"type\":\"datetime\",\"required\":false}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"inventory_stock_movements\",\"conflictColumns\":[\"id\"],\"api\":{\"include\":[\"list\",\"get\"]},\"mcp\":{\"include\":[\"list\",\"get\"]},\"cli\":{\"include\":[\"list\",\"get\"]},\"tenantScoped\":{\"mode\":\"optional\"}},\"extends\":\"SmrtObject\",\"exportName\":\"StockMovement\",\"collectionExportName\":\"StockMovementCollection\",\"validationRules\":[{\"field\":\"skuId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"locationId\",\"rule\":\"required\",\"fieldType\":\"text\"},{\"field\":\"reasonCode\",\"rule\":\"required\",\"fieldType\":\"text\"}],\"schema\":{\"tableName\":\"inventory_stock_movements\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"inventory_stock_movements\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"tenant_id\\\" UUID,\\n \\\"sku_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"location_id\\\" TEXT NOT NULL DEFAULT '',\\n \\\"from_state\\\" TEXT,\\n \\\"to_state\\\" TEXT,\\n \\\"qty\\\" REAL,\\n \\\"reason_code\\\" TEXT NOT NULL DEFAULT 'adjustment',\\n \\\"source_type\\\" TEXT DEFAULT '',\\n \\\"source_id\\\" TEXT DEFAULT '',\\n \\\"note\\\" TEXT DEFAULT '',\\n \\\"occurred_at\\\" TIMESTAMP\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"tenantId\",\"notNull\":false,\"unique\":false},\"sku_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"location_id\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"\"},\"from_state\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"to_state\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false},\"qty\":{\"type\":\"REAL\",\"notNull\":false,\"unique\":false},\"reason_code\":{\"type\":\"TEXT\",\"notNull\":true,\"unique\":false,\"default\":\"adjustment\"},\"source_type\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"source_id\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"note\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"\"},\"occurred_at\":{\"type\":\"TIMESTAMP\",\"notNull\":false,\"unique\":false}},\"indexes\":[{\"name\":\"inventory_stock_movements_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"inventory_stock_movements_tenant_id_created_at_idx\",\"columns\":[\"tenant_id\",\"created_at\"]}],\"version\":\"3c5a0445\"}}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\",\"@happyvertical/smrt-tenancy\"]}"));
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/models/InventoryLocation.ts
|
|
8
8
|
var __defProp$2 = Object.defineProperty;
|
package/dist/manifest.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": "1.0.0",
|
|
3
3
|
"timestamp": 0,
|
|
4
4
|
"packageName": "@happyvertical/smrt-inventory",
|
|
5
|
-
"packageVersion": "0.49.
|
|
5
|
+
"packageVersion": "0.49.4",
|
|
6
6
|
"objects": {
|
|
7
7
|
"@happyvertical/smrt-inventory:InventoryLocationCollection": {
|
|
8
8
|
"name": "inventorylocationcollection",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"collectionExportName": "InventoryLocationCollectionCollection",
|
|
80
80
|
"schema": {
|
|
81
81
|
"tableName": "inventory_locations",
|
|
82
|
-
"ddl": "CREATE TABLE IF NOT EXISTS \"inventory_locations\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
|
|
82
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"inventory_locations\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"code\" TEXT NOT NULL DEFAULT '',\n \"name\" TEXT DEFAULT '',\n \"kind\" TEXT DEFAULT 'warehouse',\n \"place_id\" TEXT DEFAULT '',\n \"active\" BOOLEAN DEFAULT TRUE\n);",
|
|
83
83
|
"columns": {
|
|
84
84
|
"id": {
|
|
85
85
|
"type": "UUID",
|
|
@@ -105,25 +105,70 @@
|
|
|
105
105
|
"type": "TIMESTAMP",
|
|
106
106
|
"notNull": true,
|
|
107
107
|
"default": "current_timestamp"
|
|
108
|
+
},
|
|
109
|
+
"tenant_id": {
|
|
110
|
+
"type": "UUID",
|
|
111
|
+
"referenceKind": "tenantId",
|
|
112
|
+
"notNull": false,
|
|
113
|
+
"unique": false
|
|
114
|
+
},
|
|
115
|
+
"code": {
|
|
116
|
+
"type": "TEXT",
|
|
117
|
+
"notNull": true,
|
|
118
|
+
"unique": false,
|
|
119
|
+
"default": ""
|
|
120
|
+
},
|
|
121
|
+
"name": {
|
|
122
|
+
"type": "TEXT",
|
|
123
|
+
"notNull": false,
|
|
124
|
+
"unique": false,
|
|
125
|
+
"default": ""
|
|
126
|
+
},
|
|
127
|
+
"kind": {
|
|
128
|
+
"type": "TEXT",
|
|
129
|
+
"notNull": false,
|
|
130
|
+
"unique": false,
|
|
131
|
+
"default": "warehouse"
|
|
132
|
+
},
|
|
133
|
+
"place_id": {
|
|
134
|
+
"type": "TEXT",
|
|
135
|
+
"notNull": false,
|
|
136
|
+
"unique": false,
|
|
137
|
+
"default": ""
|
|
138
|
+
},
|
|
139
|
+
"active": {
|
|
140
|
+
"type": "BOOLEAN",
|
|
141
|
+
"notNull": false,
|
|
142
|
+
"unique": false,
|
|
143
|
+
"default": true
|
|
108
144
|
}
|
|
109
145
|
},
|
|
110
146
|
"indexes": [
|
|
147
|
+
{
|
|
148
|
+
"name": "inventory_locations_code_tenant_id_idx",
|
|
149
|
+
"columns": [
|
|
150
|
+
"code",
|
|
151
|
+
"tenant_id"
|
|
152
|
+
],
|
|
153
|
+
"unique": true,
|
|
154
|
+
"nullsNotDistinct": true
|
|
155
|
+
},
|
|
111
156
|
{
|
|
112
157
|
"name": "inventory_locations_slug_context_idx",
|
|
113
158
|
"columns": [
|
|
114
159
|
"slug",
|
|
115
160
|
"context"
|
|
116
|
-
]
|
|
117
|
-
"unique": true
|
|
161
|
+
]
|
|
118
162
|
},
|
|
119
163
|
{
|
|
120
|
-
"name": "
|
|
164
|
+
"name": "inventory_locations_tenant_id_created_at_idx",
|
|
121
165
|
"columns": [
|
|
166
|
+
"tenant_id",
|
|
122
167
|
"created_at"
|
|
123
168
|
]
|
|
124
169
|
}
|
|
125
170
|
],
|
|
126
|
-
"version": "
|
|
171
|
+
"version": "401c28a1"
|
|
127
172
|
}
|
|
128
173
|
},
|
|
129
174
|
"@happyvertical/smrt-inventory:StockLevelCollection": {
|
|
@@ -236,7 +281,7 @@
|
|
|
236
281
|
"collectionExportName": "StockLevelCollectionCollection",
|
|
237
282
|
"schema": {
|
|
238
283
|
"tableName": "inventory_stock_levels",
|
|
239
|
-
"ddl": "CREATE TABLE IF NOT EXISTS \"inventory_stock_levels\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
|
|
284
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"inventory_stock_levels\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"sku_id\" TEXT NOT NULL DEFAULT '',\n \"location_id\" TEXT NOT NULL DEFAULT '',\n \"state\" TEXT NOT NULL DEFAULT 'available',\n \"qty\" REAL\n);",
|
|
240
285
|
"columns": {
|
|
241
286
|
"id": {
|
|
242
287
|
"type": "UUID",
|
|
@@ -262,25 +307,65 @@
|
|
|
262
307
|
"type": "TIMESTAMP",
|
|
263
308
|
"notNull": true,
|
|
264
309
|
"default": "current_timestamp"
|
|
310
|
+
},
|
|
311
|
+
"tenant_id": {
|
|
312
|
+
"type": "UUID",
|
|
313
|
+
"referenceKind": "tenantId",
|
|
314
|
+
"notNull": false,
|
|
315
|
+
"unique": false
|
|
316
|
+
},
|
|
317
|
+
"sku_id": {
|
|
318
|
+
"type": "TEXT",
|
|
319
|
+
"notNull": true,
|
|
320
|
+
"unique": false,
|
|
321
|
+
"default": ""
|
|
322
|
+
},
|
|
323
|
+
"location_id": {
|
|
324
|
+
"type": "TEXT",
|
|
325
|
+
"notNull": true,
|
|
326
|
+
"unique": false,
|
|
327
|
+
"default": ""
|
|
328
|
+
},
|
|
329
|
+
"state": {
|
|
330
|
+
"type": "TEXT",
|
|
331
|
+
"notNull": true,
|
|
332
|
+
"unique": false,
|
|
333
|
+
"default": "available"
|
|
334
|
+
},
|
|
335
|
+
"qty": {
|
|
336
|
+
"type": "REAL",
|
|
337
|
+
"notNull": false,
|
|
338
|
+
"unique": false
|
|
265
339
|
}
|
|
266
340
|
},
|
|
267
341
|
"indexes": [
|
|
342
|
+
{
|
|
343
|
+
"name": "inventory_stock_levels_sku_id_location_id_idx",
|
|
344
|
+
"columns": [
|
|
345
|
+
"sku_id",
|
|
346
|
+
"location_id",
|
|
347
|
+
"state",
|
|
348
|
+
"tenant_id"
|
|
349
|
+
],
|
|
350
|
+
"unique": true,
|
|
351
|
+
"nullsNotDistinct": true
|
|
352
|
+
},
|
|
268
353
|
{
|
|
269
354
|
"name": "inventory_stock_levels_slug_context_idx",
|
|
270
355
|
"columns": [
|
|
271
356
|
"slug",
|
|
272
357
|
"context"
|
|
273
|
-
]
|
|
274
|
-
"unique": true
|
|
358
|
+
]
|
|
275
359
|
},
|
|
276
360
|
{
|
|
277
|
-
"name": "
|
|
361
|
+
"name": "inventory_stock_levels_tenant_id_created_at_idx",
|
|
278
362
|
"columns": [
|
|
363
|
+
"tenant_id",
|
|
279
364
|
"created_at"
|
|
280
365
|
]
|
|
281
366
|
}
|
|
282
367
|
],
|
|
283
|
-
"version": "
|
|
368
|
+
"version": "7b08362b"
|
|
284
369
|
}
|
|
285
370
|
},
|
|
286
371
|
"@happyvertical/smrt-inventory:StockMovementCollection": {
|
|
@@ -363,7 +448,7 @@
|
|
|
363
448
|
"collectionExportName": "StockMovementCollectionCollection",
|
|
364
449
|
"schema": {
|
|
365
450
|
"tableName": "inventory_stock_movements",
|
|
366
|
-
"ddl": "CREATE TABLE IF NOT EXISTS \"inventory_stock_movements\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
|
|
451
|
+
"ddl": "CREATE TABLE IF NOT EXISTS \"inventory_stock_movements\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"sku_id\" TEXT NOT NULL DEFAULT '',\n \"location_id\" TEXT NOT NULL DEFAULT '',\n \"from_state\" TEXT,\n \"to_state\" TEXT,\n \"qty\" REAL,\n \"reason_code\" TEXT NOT NULL DEFAULT 'adjustment',\n \"source_type\" TEXT DEFAULT '',\n \"source_id\" TEXT DEFAULT '',\n \"note\" TEXT DEFAULT '',\n \"occurred_at\" TIMESTAMP\n);",
|
|
367
452
|
"columns": {
|
|
368
453
|
"id": {
|
|
369
454
|
"type": "UUID",
|
|
@@ -389,6 +474,68 @@
|
|
|
389
474
|
"type": "TIMESTAMP",
|
|
390
475
|
"notNull": true,
|
|
391
476
|
"default": "current_timestamp"
|
|
477
|
+
},
|
|
478
|
+
"tenant_id": {
|
|
479
|
+
"type": "UUID",
|
|
480
|
+
"referenceKind": "tenantId",
|
|
481
|
+
"notNull": false,
|
|
482
|
+
"unique": false
|
|
483
|
+
},
|
|
484
|
+
"sku_id": {
|
|
485
|
+
"type": "TEXT",
|
|
486
|
+
"notNull": true,
|
|
487
|
+
"unique": false,
|
|
488
|
+
"default": ""
|
|
489
|
+
},
|
|
490
|
+
"location_id": {
|
|
491
|
+
"type": "TEXT",
|
|
492
|
+
"notNull": true,
|
|
493
|
+
"unique": false,
|
|
494
|
+
"default": ""
|
|
495
|
+
},
|
|
496
|
+
"from_state": {
|
|
497
|
+
"type": "TEXT",
|
|
498
|
+
"notNull": false,
|
|
499
|
+
"unique": false
|
|
500
|
+
},
|
|
501
|
+
"to_state": {
|
|
502
|
+
"type": "TEXT",
|
|
503
|
+
"notNull": false,
|
|
504
|
+
"unique": false
|
|
505
|
+
},
|
|
506
|
+
"qty": {
|
|
507
|
+
"type": "REAL",
|
|
508
|
+
"notNull": false,
|
|
509
|
+
"unique": false
|
|
510
|
+
},
|
|
511
|
+
"reason_code": {
|
|
512
|
+
"type": "TEXT",
|
|
513
|
+
"notNull": true,
|
|
514
|
+
"unique": false,
|
|
515
|
+
"default": "adjustment"
|
|
516
|
+
},
|
|
517
|
+
"source_type": {
|
|
518
|
+
"type": "TEXT",
|
|
519
|
+
"notNull": false,
|
|
520
|
+
"unique": false,
|
|
521
|
+
"default": ""
|
|
522
|
+
},
|
|
523
|
+
"source_id": {
|
|
524
|
+
"type": "TEXT",
|
|
525
|
+
"notNull": false,
|
|
526
|
+
"unique": false,
|
|
527
|
+
"default": ""
|
|
528
|
+
},
|
|
529
|
+
"note": {
|
|
530
|
+
"type": "TEXT",
|
|
531
|
+
"notNull": false,
|
|
532
|
+
"unique": false,
|
|
533
|
+
"default": ""
|
|
534
|
+
},
|
|
535
|
+
"occurred_at": {
|
|
536
|
+
"type": "TIMESTAMP",
|
|
537
|
+
"notNull": false,
|
|
538
|
+
"unique": false
|
|
392
539
|
}
|
|
393
540
|
},
|
|
394
541
|
"indexes": [
|
|
@@ -397,17 +544,17 @@
|
|
|
397
544
|
"columns": [
|
|
398
545
|
"slug",
|
|
399
546
|
"context"
|
|
400
|
-
]
|
|
401
|
-
"unique": true
|
|
547
|
+
]
|
|
402
548
|
},
|
|
403
549
|
{
|
|
404
|
-
"name": "
|
|
550
|
+
"name": "inventory_stock_movements_tenant_id_created_at_idx",
|
|
405
551
|
"columns": [
|
|
552
|
+
"tenant_id",
|
|
406
553
|
"created_at"
|
|
407
554
|
]
|
|
408
555
|
}
|
|
409
556
|
],
|
|
410
|
-
"version": "
|
|
557
|
+
"version": "3c5a0445"
|
|
411
558
|
}
|
|
412
559
|
},
|
|
413
560
|
"@happyvertical/smrt-inventory:InventoryLocation": {
|
|
@@ -574,7 +721,8 @@
|
|
|
574
721
|
"code",
|
|
575
722
|
"tenant_id"
|
|
576
723
|
],
|
|
577
|
-
"unique": true
|
|
724
|
+
"unique": true,
|
|
725
|
+
"nullsNotDistinct": true
|
|
578
726
|
},
|
|
579
727
|
{
|
|
580
728
|
"name": "inventory_locations_slug_context_idx",
|
|
@@ -769,7 +917,8 @@
|
|
|
769
917
|
"state",
|
|
770
918
|
"tenant_id"
|
|
771
919
|
],
|
|
772
|
-
"unique": true
|
|
920
|
+
"unique": true,
|
|
921
|
+
"nullsNotDistinct": true
|
|
773
922
|
},
|
|
774
923
|
{
|
|
775
924
|
"name": "inventory_stock_levels_slug_context_idx",
|
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-inventory",
|
|
6
|
-
"packageVersion": "0.49.
|
|
6
|
+
"packageVersion": "0.49.4",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
10
|
+
"manifest": "9ea37f1573846d7e68c811554896790157a3ea6caad8b37b7303a829474fed08",
|
|
11
|
+
"packageJson": "9e770d27b02c3db0ecf5c83b12be3b4872a37a967a5feea6966cabe158ac28f2",
|
|
12
12
|
"agents": "a771bf16d21cabbe43a77d5cb87ca7dedbf2e68d1928cf804cf4fefaad7a765f"
|
|
13
13
|
},
|
|
14
14
|
"exports": [
|
|
@@ -1293,7 +1293,7 @@
|
|
|
1293
1293
|
"junctionCollections": 0,
|
|
1294
1294
|
"hierarchicalObjects": 0,
|
|
1295
1295
|
"polymorphicAssociations": 0,
|
|
1296
|
-
"uuidColumns":
|
|
1296
|
+
"uuidColumns": 12
|
|
1297
1297
|
},
|
|
1298
1298
|
"agentDoc": "# @happyvertical/smrt-inventory\n\nMulti-location stock tracking. Strictly industry-neutral — the same primitives serve apparel, furniture, automotive, CPG, electronics, and any other vertical that counts discrete units across locations.\n\n## Models\n\n| Model | Purpose |\n|---|---|\n| _(catalog shapes — `Product`, `Material`, `ProductVariant`, `Sku` — live in `@happyvertical/smrt-products`)_ | Sku is the smallest sellable / countable unit; its `attributes` JSON carries axis-value pins. ProductVariant is the per-product axis declaration. Import either from `@happyvertical/smrt-products` directly. |\n| `InventoryLocation` | Warehouse / factory / retail / in-transit / virtual. Open-ended `kind` string. Optional `placeId` references `@happyvertical/smrt-places`. `conflictColumns: ['code', 'tenant_id']`. |\n| `StockLevel` | Materialized `qty` for a `(skuId, locationId, state)` tuple. Upserted in place. **Mutated only by `StockService`.** States: `available`, `allocated`, `wip`, `qc_hold`, `damaged`. |\n| `StockMovement` | Append-only audit log. Every `StockService` mutation writes one (or two for `transfer`). `sourceType` + `sourceId` carry cross-package attribution. |\n\nAll three inventory models (`InventoryLocation`, `StockLevel`, `StockMovement`) use `@TenantScoped({ mode: 'optional' })` + nullable `tenantId` so they can be used either tenant-scoped or globally. The catalog shapes (`Product`, `Material`, `ProductVariant`, `Sku`) live in `@happyvertical/smrt-products` and carry their own tenant decoration there.\n\n## StockService — the only sanctioned way to mutate stock\n\n```typescript\nimport { createStockService } from '@happyvertical/smrt-inventory';\n\nconst service = await createStockService({ db });\nawait service.receive(skuId, locationId, qty, { sourceType, sourceId });\nawait service.reserve(skuId, locationId, qty, { sourceType, sourceId });\nawait service.release(skuId, locationId, qty, { sourceType, sourceId });\nawait service.fulfill(skuId, locationId, qty, { sourceType, sourceId });\nawait service.transfer(skuId, fromLocId, toLocId, qty, { sourceType, sourceId });\nawait service.adjust(skuId, locationId, delta, { sourceType, sourceId });\n```\n\n| Method | Behavior | Movement reason |\n|---|---|---|\n| `receive` | +qty available — purchase receipt, return, production produce | `receipt` |\n| `reserve` | available → allocated. Throws `InsufficientStockError` on overdraw | `reservation` |\n| `release` | allocated → available (order cancel) | `release` |\n| `fulfill` | -qty allocated. Stock leaves the building | `fulfillment` |\n| `transfer` | move stock between locations (writes two movements) | `transfer_out`, `transfer_in` |\n| `adjust` | signed delta — cycle counts and one-off corrections | `adjustment` |\n\nAll methods reject zero / negative / non-finite quantities except `adjust`, which accepts non-zero signed deltas. Negative deltas that would drive a state below zero throw `InsufficientStockError`.\n\n## Opt-in DispatchBus hooks\n\nOff by default. Wire them up explicitly in the application's `smrt.ts`:\n\n```typescript\nimport { installInventoryDispatchHandlers } from '@happyvertical/smrt-inventory';\n\nconst handlers = await installInventoryDispatchHandlers({\n dispatchBus: bus,\n db, // or stockService: existingService\n});\n```\n\nThis subscribes to:\n- `contract:created` → calls `service.reserve()` for every line inside one `stockService.withTransaction(...)`, attributed to `('Contract', payload.contractId)`\n- `fulfillment:shipped` → calls `service.fulfill()` for every line inside one `stockService.withTransaction(...)`, attributed to `('Fulfillment', payload.fulfillmentId)`\n\nBoth handlers are atomic across lines: a shortfall on line N rolls back lines 1..N-1 so the event is all-or-nothing. Without this guarantee, `DispatchBus` would only log the async handler error and a partially-reserved (or partially-fulfilled) contract would have no compensating event to fix it.\n\nPer-handler toggles: `installContractReserved`, `installFulfillmentShipped`. The `production_order:posted` hook is deliberately not installed here — it depends on the BOM model and ships in `@happyvertical/smrt-manufacturing` (issue #1250).\n\n## Schema migration (Phase 1 release)\n\nThe `Sku` model moved out of this package and into `@happyvertical/smrt-products`. Previously it lived in this package's `inventory_skus` table; it now lives in `product_skus` over there.\n\n**Upgrade procedure** for deployed consumers:\n\n1. **Let the framework create the destination table first.** Boot the new version once with `@happyvertical/smrt-products` registered in your `SmrtClassOptions`; the lazy `syncSchema` path will create `product_skus` with the right primary key, NOT NULL, UNIQUE (`code`, `tenant_id`), and indexes — they're derived from the `Sku` model decorators and would be stripped by a raw `CREATE TABLE AS SELECT`.\n\n2. **Idempotently copy rows across.** SQLite + Postgres:\n\n ```sql\n BEGIN;\n INSERT INTO product_skus (\n id, slug, context, created_at, updated_at,\n tenant_id, product_id, code, barcode, name,\n attributes, weight_grams, parent_sku_id, active\n )\n SELECT\n id, slug, context, created_at, updated_at,\n tenant_id, product_id, code, barcode, name,\n attributes, weight_grams, parent_sku_id, active\n FROM inventory_skus\n WHERE NOT EXISTS (\n SELECT 1 FROM product_skus p WHERE p.id = inventory_skus.id\n );\n COMMIT;\n ```\n\n3. **Drop the legacy table** once you've verified row counts match:\n\n ```sql\n DROP TABLE IF EXISTS inventory_skus;\n ```\n\n`StockLevel.skuId` and `StockMovement.skuId` carry plain string ids that still resolve to the same rows after the rename, so no inventory data has to move.\n\n## Gotchas\n\n- **Movements are append-only.** The materialized `StockLevel` row is derived state; the `StockMovement` ledger is the source of truth. Never let CRUD UIs expose update/delete on the movement table. If you find yourself wanting to \"fix\" a movement row, write a compensating `adjust()` call instead.\n- **Never call `StockLevel.create()` or `save()` directly.** Going around `StockService` silently desyncs the audit log and breaks cycle counts.\n- **Cross-industry constraint.** This package's vocabulary stays generic: `InventoryLocation`, `StockLevel`, `StockMovement`. Apparel-specific concepts (`Style`, `Makeup`, `Colorway`, fashion `Season`, tech-pack metadata) and their analogues in furniture / automotive / CPG live in the relevant template package, never here. PRs that introduce industry vocabulary should be rejected.\n- **Cross-package references are plain strings.** `skuId`, `placeId`, `sourceId` — all plain string ids, never `@foreignKey()`. Inventory's stock-motion logic only ever reads StockLevel/StockMovement; it doesn't follow `skuId` back to the catalog's Sku table, so the layering stays loose.\n- **`conflictColumns` include `tenant_id`** on `InventoryLocation` and `StockLevel`. NULL-matching semantics (`(code, NULL) IS NOT DISTINCT FROM (code, NULL)`) are handled by `@happyvertical/sql >= 0.74.0` natively, so two saves with the same `(code, NULL)` tuple correctly merge in place. Pass `nullsDistinct: true` at the sql layer to opt back into NULL-distinct semantics.\n- **Atomic per-method, transactional across composition.** Each `StockService` mutation (`receive` / `reserve` / `release` / `fulfill` / `transfer` / `adjust`) wraps every write in a single `db.transaction(...)` (via `@happyvertical/sql >= 0.74.0`). Partial failure rolls the whole call back — level writes and the matching `StockMovement` audit row commit together or not at all. `transfer` writes both legs (source decrement, destination increment, and both audit rows) inside one tx, so a failure mid-`transfer` is fully reverted.\n Callers composing multiple `StockService` calls into one logical unit (e.g. consuming materials line-by-line for a production order) should wrap them in `await stockService.withTransaction(async (tx) => { ... })` — `tx` is a tx-bound `StockService` with the same public API; mutation calls inside the callback share one transaction and either all commit or all roll back.\n If the underlying SQL adapter does not expose `transaction()` (extremely rare — all four built-in `@happyvertical/sql >= 0.74.0` adapters implement it), the service degrades to non-atomic serial writes and emits a one-time `console.warn`.\n- **Concurrent reservations: tightened, not bulletproof.** `@happyvertical/sql >= 0.74.0` serialises null-aware *upserts* via a per-key in-process lock (SQLite) or advisory lock (Postgres). That lock fixed the row-creation race (issue #1246) — two concurrent `create()` calls on the same conflict-column tuple no longer race the underlying `INSERT ... ON CONFLICT`. It does NOT serialise the read-modify-write compound that `reserve` / `fulfill` / `transfer` / `adjust` perform on an existing row: each method reads the current level (`SELECT`), computes the new value in JS, then writes it back (`UPDATE` via `save()` on the loaded row). The whole compound is inside one `db.transaction(...)` from round-3, so the level write and audit row commit together — but two concurrent transactions on the same `(skuId, locationId)` can each see the same starting balance, compute the same decrement, and double-spend. Awaited (serial) calls always behave correctly. Use a job queue (e.g. `@happyvertical/smrt-jobs`) or your own mutex when you need hard atomicity across concurrent callers. The full fix is `SELECT ... FOR UPDATE` inside the same transaction (Postgres) or upgrading the journal mode (SQLite); deferred until we see a real high-contention workload that warrants it.\n\n## Source attribution\n\nEvery `StockMovement` carries `sourceType` + `sourceId` so downstream queries can reconstruct \"what caused this movement\". Conventions used by the built-in dispatch handlers:\n\n| sourceType | Emitter | Note |\n|---|---|---|\n| `Contract` | `smrt-commerce` `contract:created` | All reservation/release/fulfilment legs caused by a contract |\n| `Fulfillment` | `smrt-commerce` `fulfillment:shipped` | Outbound shipment |\n| `PurchaseOrder` | (your code) | Inbound receipt |\n| `CycleCount` | (your code) | Adjustments from physical counts |\n| `TransferOrder` | (your code) | Both legs of a transfer |\n| `ProductionOrder` | `smrt-manufacturing` (issue #1250) | Materials consumed + finished goods produced |\n"
|
|
1299
1299
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-inventory",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.4",
|
|
4
4
|
"description": "Multi-location stock tracking for the SMRT framework — Sku, InventoryLocation, StockLevel, StockMovement, and a stock-mutation service",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@happyvertical/logger": "^0.89.6",
|
|
23
|
-
"@happyvertical/smrt-core": "0.49.
|
|
24
|
-
"@happyvertical/smrt-tenancy": "0.49.
|
|
23
|
+
"@happyvertical/smrt-core": "0.49.4",
|
|
24
|
+
"@happyvertical/smrt-tenancy": "0.49.4",
|
|
25
25
|
"@happyvertical/sql": "^0.89.6"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@happyvertical/smrt-vitest": "0.49.
|
|
28
|
+
"@happyvertical/smrt-vitest": "0.49.4",
|
|
29
29
|
"@types/node": "24.13.2",
|
|
30
30
|
"typescript": "5.9.3",
|
|
31
31
|
"vite": "8.1.4",
|