@happyvertical/smrt-inventory 0.54.2 → 0.54.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/AGENTS.md +16 -0
- package/README.md +58 -0
- package/dist/collections/StockLevelCollection.d.ts +5 -0
- package/dist/collections/StockLevelCollection.d.ts.map +1 -1
- package/dist/index.js +91 -12
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +88 -10
- package/dist/models/StockLevel.d.ts +6 -0
- package/dist/models/StockLevel.d.ts.map +1 -1
- package/dist/models/StockMovement.d.ts +3 -0
- package/dist/models/StockMovement.d.ts.map +1 -1
- package/dist/services/StockService.d.ts +9 -0
- package/dist/services/StockService.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +95 -10
- package/dist/svelte/AdjustStockForm.svelte +59 -0
- package/dist/svelte/AdjustStockForm.svelte.d.ts +11 -0
- package/dist/svelte/AdjustStockForm.svelte.d.ts.map +1 -0
- package/dist/svelte/LocationForm.svelte +65 -0
- package/dist/svelte/LocationForm.svelte.d.ts +10 -0
- package/dist/svelte/LocationForm.svelte.d.ts.map +1 -0
- package/dist/svelte/LocationList.svelte +16 -0
- package/dist/svelte/LocationList.svelte.d.ts +9 -0
- package/dist/svelte/LocationList.svelte.d.ts.map +1 -0
- package/dist/svelte/MovementHistory.svelte +14 -0
- package/dist/svelte/MovementHistory.svelte.d.ts +8 -0
- package/dist/svelte/MovementHistory.svelte.d.ts.map +1 -0
- package/dist/svelte/StockLevels.svelte +22 -0
- package/dist/svelte/StockLevels.svelte.d.ts +9 -0
- package/dist/svelte/StockLevels.svelte.d.ts.map +1 -0
- package/dist/svelte/index.d.ts +7 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +5 -0
- package/dist/svelte/types.d.ts +40 -0
- package/dist/svelte/types.d.ts.map +1 -0
- package/dist/svelte/types.js +1 -0
- package/package.json +28 -10
package/AGENTS.md
CHANGED
|
@@ -119,3 +119,19 @@ Every `StockMovement` carries `sourceType` + `sourceId` so downstream queries ca
|
|
|
119
119
|
| `CycleCount` | (your code) | Adjustments from physical counts |
|
|
120
120
|
| `TransferOrder` | (your code) | Both legs of a transfer |
|
|
121
121
|
| `ProductionOrder` | `smrt-manufacturing` (issue #1250) | Materials consumed + finished goods produced |
|
|
122
|
+
|
|
123
|
+
## Replenishment and browser components
|
|
124
|
+
|
|
125
|
+
`StockService.setReorderPolicy()` is the sanctioned metadata writer for nullable
|
|
126
|
+
`StockLevel.reorderPoint` / `reorderQuantity` on the available SKU/location row.
|
|
127
|
+
It does not change quantity or emit a movement. `findBelowReorderPoint()` uses
|
|
128
|
+
public tenant-filtered collection reads and strict less-than semantics.
|
|
129
|
+
`StockMutationOptions.actorProfileId` propagates to every movement, including
|
|
130
|
+
both transfer legs; null retains compatibility for automation. It is a qualified
|
|
131
|
+
cross-package profile reference, not an authorization decision.
|
|
132
|
+
|
|
133
|
+
`src/svelte/` exports data-driven components through `./svelte`. Server callers
|
|
134
|
+
own authentication and persistence callbacks; never import backend models into
|
|
135
|
+
this entry or expose ledger mutations as CRUD. Package `typecheck` includes
|
|
136
|
+
Svelte checks and `test` includes DOM component tests. See README for the public
|
|
137
|
+
props, service contracts, and additive schema upgrade requirements.
|
package/README.md
CHANGED
|
@@ -211,3 +211,61 @@ All catalog shapes (`Product`, `Material`, `ProductVariant`, `Sku`) live in [`@h
|
|
|
211
211
|
## License
|
|
212
212
|
|
|
213
213
|
MIT
|
|
214
|
+
|
|
215
|
+
### Database initialization
|
|
216
|
+
|
|
217
|
+
`StockService.create()` and transaction-scoped service construction initialize
|
|
218
|
+
their three collections sequentially. Each initialization checks framework
|
|
219
|
+
system tables on the shared connection; parallel probes can interfere on
|
|
220
|
+
DuckDB. This ordering does not change the single-transaction stock/audit contract
|
|
221
|
+
or provision application schema at runtime.
|
|
222
|
+
|
|
223
|
+
The package test suite covers cold SQLite/DuckDB initialization and repeated
|
|
224
|
+
transaction rollback. Set `SMRT_TEST_POSTGRES_URL` to an isolated PostgreSQL
|
|
225
|
+
database to exercise the same fixture on PostgreSQL.
|
|
226
|
+
|
|
227
|
+
### Reorder policies and movement actors
|
|
228
|
+
|
|
229
|
+
`stock.setReorderPolicy(skuId, locationId, reorderPoint, reorderQuantity?)`
|
|
230
|
+
sets nullable decimal metadata on the **available** stock row. It creates a
|
|
231
|
+
zero-balance row if necessary without inventing an audit movement. Values must
|
|
232
|
+
be finite and non-negative; `null` disables monitoring, and omitting the reorder
|
|
233
|
+
quantity clears its suggestion. Stock mutations preserve these settings.
|
|
234
|
+
`stock.levels.findBelowReorderPoint(locationId?)` returns visible available rows
|
|
235
|
+
whose quantity is **strictly less** than their configured point. Equality, unset
|
|
236
|
+
thresholds, and other states do not count. Both methods retain normal tenant
|
|
237
|
+
scoping and the setter participates in `stock.withTransaction()`.
|
|
238
|
+
|
|
239
|
+
Every mutation accepts `actorProfileId` alongside source attribution. It is a
|
|
240
|
+
nullable qualified reference to `@happyvertical/smrt-profiles:Profile`, copied to
|
|
241
|
+
every ledger row including both transfer legs. Omission records `null` for
|
|
242
|
+
legacy callers and unattended automation. Supply the profile ID from trusted
|
|
243
|
+
server context; this attribution field does not authorize the caller.
|
|
244
|
+
|
|
245
|
+
Existing deployments must generate and apply their normal s-m-r-t schema migration
|
|
246
|
+
before using these fields: add nullable decimal `reorder_point` and
|
|
247
|
+
`reorder_quantity` to `inventory_stock_levels`, and nullable profile-reference
|
|
248
|
+
`actor_profile_id` to `inventory_stock_movements` (UUID on PostgreSQL/DuckDB,
|
|
249
|
+
text on SQLite). Existing rows remain unset; runtime reads do not migrate tables.
|
|
250
|
+
|
|
251
|
+
### Svelte components
|
|
252
|
+
|
|
253
|
+
The optional `@happyvertical/smrt-inventory/svelte` entry exports:
|
|
254
|
+
|
|
255
|
+
| Component | Data / callback contract |
|
|
256
|
+
| --- | --- |
|
|
257
|
+
| `StockLevels` | `levels`, optional `locationId`; shows balance, reorder settings and low-stock status |
|
|
258
|
+
| `MovementHistory` | `movements`; read-only history with actor, source and note |
|
|
259
|
+
| `AdjustStockForm` | `skuId`, `locationId`, `onsubmit({ skuId, locationId, delta, reasonCode, note })` |
|
|
260
|
+
| `LocationList` | `locations`, optional `onedit(location)`; includes inactive locations |
|
|
261
|
+
| `LocationForm` | optional `location`, `onsubmit({ id?, code, name, kind, placeId, active })` |
|
|
262
|
+
|
|
263
|
+
The entry also exports structural browser-safe data types. Hosts load authorized
|
|
264
|
+
records and implement callbacks; components do not import database models, fetch
|
|
265
|
+
endpoints, or manage authentication. Route adjustment submissions through
|
|
266
|
+
`StockService.adjust`, attaching the trusted actor on the server. Save location
|
|
267
|
+
forms through `InventoryLocationCollection`; deactivate using `active: false`
|
|
268
|
+
rather than deleting history. Both forms accept `disabled`, prevent duplicate
|
|
269
|
+
submissions while awaiting callbacks, and display callback failures. Reorder
|
|
270
|
+
policy editing uses the service method above; stock quantities and movements
|
|
271
|
+
remain read-only outside the adjustment workflow.
|
|
@@ -30,6 +30,11 @@ export declare class StockLevelCollection extends SmrtCollection<StockLevel> {
|
|
|
30
30
|
* in this warehouse?" reports.
|
|
31
31
|
*/
|
|
32
32
|
findByLocation(locationId: string): Promise<StockLevel[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Available rows strictly below their configured reorder point.
|
|
35
|
+
* Reads use the public collection pipeline to preserve tenant filtering.
|
|
36
|
+
*/
|
|
37
|
+
findBelowReorderPoint(locationId?: string): Promise<StockLevel[]>;
|
|
33
38
|
/**
|
|
34
39
|
* Sum `qty` across all level rows for the given SKU. Pass `state` to
|
|
35
40
|
* narrow the sum to one logical state (e.g. only `available`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StockLevelCollection.d.ts","sourceRoot":"","sources":["../../src/collections/StockLevelCollection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,qBAAa,oBAAqB,SAAQ,cAAc,CAAC,UAAU,CAAC;IAClE,MAAM,CAAC,QAAQ,CAAC,UAAU,oBAAc;IAExC;;;;;OAKG;IACG,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,UAAwB,GAC9B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAQ7B;;;OAGG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAIrD;;;OAGG;IACG,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAI/D;;;;OAIG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAOrE;;;OAGG;IACG,gBAAgB,CACpB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,MAAM,CAAC;CAMnB"}
|
|
1
|
+
{"version":3,"file":"StockLevelCollection.d.ts","sourceRoot":"","sources":["../../src/collections/StockLevelCollection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,qBAAa,oBAAqB,SAAQ,cAAc,CAAC,UAAU,CAAC;IAClE,MAAM,CAAC,QAAQ,CAAC,UAAU,oBAAc;IAExC;;;;;OAKG;IACG,QAAQ,CACZ,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,UAAwB,GAC9B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAQ7B;;;OAGG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAIrD;;;OAGG;IACG,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAI/D;;;OAGG;IACG,qBAAqB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAWvE;;;;OAIG;IACG,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAOrE;;;OAGG;IACG,gBAAgB,CACpB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,MAAM,CAAC;CAMnB"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { ObjectRegistry, SmrtCollection, SmrtObject, field, resolveDatabase, smrt } from "@happyvertical/smrt-core";
|
|
1
|
+
import { ObjectRegistry, SmrtCollection, SmrtObject, crossPackageRef, field, resolveDatabase, smrt } from "@happyvertical/smrt-core";
|
|
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.54.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 \\\"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\"},\"importPath\":\"@happyvertical/smrt-inventory\"},\"@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\"},\"importPath\":\"@happyvertical/smrt-inventory\"},\"@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\"},\"importPath\":\"@happyvertical/smrt-inventory\"},\"@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\"},\"importPath\":\"@happyvertical/smrt-inventory\"},\"@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\"},\"importPath\":\"@happyvertical/smrt-inventory\"},\"@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\"},\"importPath\":\"@happyvertical/smrt-inventory\"}},\"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.54.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"},"importPath":"@happyvertical/smrt-inventory"},"@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},"findBelowReorderPoint":{"name":"findBelowReorderPoint","async":true,"parameters":[{"name":"locationId","type":"string","optional":true}],"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 \\"reorder_point\\" REAL,\\n \\"reorder_quantity\\" 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},"reorder_point":{"type":"REAL","notNull":false,"unique":false},"reorder_quantity":{"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":"02387935"},"importPath":"@happyvertical/smrt-inventory"},"@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 \\"actor_profile_id\\" UUID,\\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":""},"actor_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"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"]},{"name":"inventory_stock_movements_actor_profile_id_idx","columns":["actor_profile_id"]}],"version":"eff1027e"},"importPath":"@happyvertical/smrt-inventory"},"@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"},"importPath":"@happyvertical/smrt-inventory"},"@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":{}},"reorderPoint":{"type":"decimal","required":false,"_meta":{"nullable":true}},"reorderQuantity":{"type":"decimal","required":false,"_meta":{"nullable":true}}},"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 \\"reorder_point\\" REAL,\\n \\"reorder_quantity\\" 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},"reorder_point":{"type":"REAL","notNull":false,"unique":false},"reorder_quantity":{"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":"02387935"},"importPath":"@happyvertical/smrt-inventory"},"@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":""},"actorProfileId":{"type":"crossPackageRef","required":false,"related":"@happyvertical/smrt-profiles:Profile"},"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 \\"actor_profile_id\\" UUID,\\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":""},"actor_profile_id":{"type":"UUID","referenceKind":"crossPackageRef","notNull":false,"unique":false},"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"]},{"name":"inventory_stock_movements_actor_profile_id_idx","columns":["actor_profile_id"]}],"version":"eff1027e"},"importPath":"@happyvertical/smrt-inventory"}},"moduleType":"smrt","smrtDependencies":["@happyvertical/smrt-core","@happyvertical/smrt-tenancy"],"stampsConstructors":true}`));
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/models/InventoryLocation.ts
|
|
8
8
|
var __defProp$2 = Object.defineProperty;
|
|
9
9
|
var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value
|
|
15
|
+
}) : obj[key] = value;
|
|
10
16
|
var __decorateClass$2 = (decorators, target, key, kind) => {
|
|
11
17
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
|
|
12
18
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
13
19
|
if (kind && result) __defProp$2(target, key, result);
|
|
14
20
|
return result;
|
|
15
21
|
};
|
|
22
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
16
23
|
var InventoryLocation = class extends SmrtObject {
|
|
17
24
|
tenantId = null;
|
|
18
25
|
code = "";
|
|
@@ -43,6 +50,7 @@ var InventoryLocation = class extends SmrtObject {
|
|
|
43
50
|
if (options.active !== void 0) this.active = options.active;
|
|
44
51
|
}
|
|
45
52
|
};
|
|
53
|
+
__publicField$2(InventoryLocation, "__smrtPackage__", "@happyvertical/smrt-inventory");
|
|
46
54
|
__decorateClass$2([tenantId({ nullable: true })], InventoryLocation.prototype, "tenantId", 2);
|
|
47
55
|
__decorateClass$2([field({ required: true })], InventoryLocation.prototype, "code", 2);
|
|
48
56
|
InventoryLocation = __decorateClass$2([TenantScoped({ mode: "optional" }), smrt({
|
|
@@ -107,18 +115,27 @@ var InventoryLocationCollection = class extends SmrtCollection {
|
|
|
107
115
|
//#region src/models/StockLevel.ts
|
|
108
116
|
var __defProp$1 = Object.defineProperty;
|
|
109
117
|
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
118
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
configurable: true,
|
|
121
|
+
writable: true,
|
|
122
|
+
value
|
|
123
|
+
}) : obj[key] = value;
|
|
110
124
|
var __decorateClass$1 = (decorators, target, key, kind) => {
|
|
111
125
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
|
|
112
126
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
113
127
|
if (kind && result) __defProp$1(target, key, result);
|
|
114
128
|
return result;
|
|
115
129
|
};
|
|
130
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
116
131
|
var StockLevel = class extends SmrtObject {
|
|
117
132
|
tenantId = null;
|
|
118
133
|
skuId = "";
|
|
119
134
|
locationId = "";
|
|
120
135
|
state = "available";
|
|
121
136
|
qty = 0;
|
|
137
|
+
reorderPoint = null;
|
|
138
|
+
reorderQuantity = null;
|
|
122
139
|
constructor(options = {}) {
|
|
123
140
|
super(options);
|
|
124
141
|
if (options.tenantId !== void 0) this.tenantId = options.tenantId;
|
|
@@ -126,13 +143,24 @@ var StockLevel = class extends SmrtObject {
|
|
|
126
143
|
if (options.locationId !== void 0) this.locationId = options.locationId;
|
|
127
144
|
if (options.state !== void 0) this.state = options.state;
|
|
128
145
|
if (options.qty !== void 0) this.qty = options.qty;
|
|
146
|
+
if (options.reorderPoint !== void 0) this.reorderPoint = options.reorderPoint;
|
|
147
|
+
if (options.reorderQuantity !== void 0) this.reorderQuantity = options.reorderQuantity;
|
|
129
148
|
}
|
|
130
149
|
};
|
|
150
|
+
__publicField$1(StockLevel, "__smrtPackage__", "@happyvertical/smrt-inventory");
|
|
131
151
|
__decorateClass$1([tenantId({ nullable: true })], StockLevel.prototype, "tenantId", 2);
|
|
132
152
|
__decorateClass$1([field({ required: true })], StockLevel.prototype, "skuId", 2);
|
|
133
153
|
__decorateClass$1([field({ required: true })], StockLevel.prototype, "locationId", 2);
|
|
134
154
|
__decorateClass$1([field({ required: true })], StockLevel.prototype, "state", 2);
|
|
135
155
|
__decorateClass$1([field({ type: "decimal" })], StockLevel.prototype, "qty", 2);
|
|
156
|
+
__decorateClass$1([field({
|
|
157
|
+
type: "decimal",
|
|
158
|
+
nullable: true
|
|
159
|
+
})], StockLevel.prototype, "reorderPoint", 2);
|
|
160
|
+
__decorateClass$1([field({
|
|
161
|
+
type: "decimal",
|
|
162
|
+
nullable: true
|
|
163
|
+
})], StockLevel.prototype, "reorderQuantity", 2);
|
|
136
164
|
StockLevel = __decorateClass$1([TenantScoped({ mode: "optional" }), smrt({
|
|
137
165
|
tableName: "inventory_stock_levels",
|
|
138
166
|
conflictColumns: [
|
|
@@ -180,6 +208,15 @@ var StockLevelCollection = class extends SmrtCollection {
|
|
|
180
208
|
return this.list({ where: { locationId } });
|
|
181
209
|
}
|
|
182
210
|
/**
|
|
211
|
+
* Available rows strictly below their configured reorder point.
|
|
212
|
+
* Reads use the public collection pipeline to preserve tenant filtering.
|
|
213
|
+
*/
|
|
214
|
+
async findBelowReorderPoint(locationId) {
|
|
215
|
+
const where = { state: "available" };
|
|
216
|
+
if (locationId !== void 0) where.locationId = locationId;
|
|
217
|
+
return (await this.list({ where })).filter((level) => level.reorderPoint !== null && Number(level.qty) < Number(level.reorderPoint));
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
183
220
|
* Sum `qty` across all level rows for the given SKU. Pass `state` to
|
|
184
221
|
* narrow the sum to one logical state (e.g. only `available`);
|
|
185
222
|
* omit it for grand total across all states.
|
|
@@ -203,12 +240,19 @@ var StockLevelCollection = class extends SmrtCollection {
|
|
|
203
240
|
//#region src/models/StockMovement.ts
|
|
204
241
|
var __defProp = Object.defineProperty;
|
|
205
242
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
243
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
244
|
+
enumerable: true,
|
|
245
|
+
configurable: true,
|
|
246
|
+
writable: true,
|
|
247
|
+
value
|
|
248
|
+
}) : obj[key] = value;
|
|
206
249
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
207
250
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
208
251
|
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
209
252
|
if (kind && result) __defProp(target, key, result);
|
|
210
253
|
return result;
|
|
211
254
|
};
|
|
255
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
212
256
|
var StockMovement = class extends SmrtObject {
|
|
213
257
|
tenantId = null;
|
|
214
258
|
skuId = "";
|
|
@@ -238,6 +282,7 @@ var StockMovement = class extends SmrtObject {
|
|
|
238
282
|
* the framework never dereferences it.
|
|
239
283
|
*/
|
|
240
284
|
sourceId = "";
|
|
285
|
+
actorProfileId = null;
|
|
241
286
|
/** Optional free-form note shown in audit UIs. */
|
|
242
287
|
note = "";
|
|
243
288
|
/**
|
|
@@ -256,15 +301,18 @@ var StockMovement = class extends SmrtObject {
|
|
|
256
301
|
if (options.reasonCode !== void 0) this.reasonCode = options.reasonCode;
|
|
257
302
|
if (options.sourceType !== void 0) this.sourceType = options.sourceType;
|
|
258
303
|
if (options.sourceId !== void 0) this.sourceId = options.sourceId;
|
|
304
|
+
if (options.actorProfileId !== void 0) this.actorProfileId = options.actorProfileId;
|
|
259
305
|
if (options.note !== void 0) this.note = options.note;
|
|
260
306
|
if (options.occurredAt !== void 0) this.occurredAt = options.occurredAt instanceof Date ? options.occurredAt : new Date(options.occurredAt);
|
|
261
307
|
}
|
|
262
308
|
};
|
|
309
|
+
__publicField(StockMovement, "__smrtPackage__", "@happyvertical/smrt-inventory");
|
|
263
310
|
__decorateClass([tenantId({ nullable: true })], StockMovement.prototype, "tenantId", 2);
|
|
264
311
|
__decorateClass([field({ required: true })], StockMovement.prototype, "skuId", 2);
|
|
265
312
|
__decorateClass([field({ required: true })], StockMovement.prototype, "locationId", 2);
|
|
266
313
|
__decorateClass([field({ type: "decimal" })], StockMovement.prototype, "qty", 2);
|
|
267
314
|
__decorateClass([field({ required: true })], StockMovement.prototype, "reasonCode", 2);
|
|
315
|
+
__decorateClass([crossPackageRef("@happyvertical/smrt-profiles:Profile")], StockMovement.prototype, "actorProfileId", 2);
|
|
268
316
|
StockMovement = __decorateClass([TenantScoped({ mode: "optional" }), smrt({
|
|
269
317
|
tableName: "inventory_stock_movements",
|
|
270
318
|
conflictColumns: ["id"],
|
|
@@ -357,11 +405,9 @@ var StockService = class StockService {
|
|
|
357
405
|
/** Internal factory — prefer {@link createStockService}. */
|
|
358
406
|
static async create(options) {
|
|
359
407
|
const resolved = await resolveDatabase(options.db);
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
InventoryLocationCollection.create({ db: resolved })
|
|
364
|
-
]);
|
|
408
|
+
const levels = await StockLevelCollection.create({ db: resolved });
|
|
409
|
+
const movements = await StockMovementCollection.create({ db: resolved });
|
|
410
|
+
const locations = await InventoryLocationCollection.create({ db: resolved });
|
|
365
411
|
return new StockService(resolved, levels, movements, locations);
|
|
366
412
|
}
|
|
367
413
|
/**
|
|
@@ -394,11 +440,9 @@ var StockService = class StockService {
|
|
|
394
440
|
return work(this);
|
|
395
441
|
}
|
|
396
442
|
return underlying.transaction(async (txDb) => {
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
InventoryLocationCollection.create({ db: txDb })
|
|
401
|
-
]);
|
|
443
|
+
const levels = await StockLevelCollection.create({ db: txDb });
|
|
444
|
+
const movements = await StockMovementCollection.create({ db: txDb });
|
|
445
|
+
const locations = await InventoryLocationCollection.create({ db: txDb });
|
|
402
446
|
return work(new StockService(txDb, levels, movements, locations, true));
|
|
403
447
|
});
|
|
404
448
|
}
|
|
@@ -440,6 +484,7 @@ var StockService = class StockService {
|
|
|
440
484
|
reasonCode: options.reasonCode ?? "receipt",
|
|
441
485
|
sourceType: options.sourceType,
|
|
442
486
|
sourceId: options.sourceId,
|
|
487
|
+
actorProfileId: options.actorProfileId,
|
|
443
488
|
note: options.note
|
|
444
489
|
});
|
|
445
490
|
});
|
|
@@ -461,6 +506,7 @@ var StockService = class StockService {
|
|
|
461
506
|
reasonCode: options.reasonCode ?? "reservation",
|
|
462
507
|
sourceType: options.sourceType,
|
|
463
508
|
sourceId: options.sourceId,
|
|
509
|
+
actorProfileId: options.actorProfileId,
|
|
464
510
|
note: options.note
|
|
465
511
|
});
|
|
466
512
|
});
|
|
@@ -482,6 +528,7 @@ var StockService = class StockService {
|
|
|
482
528
|
reasonCode: options.reasonCode ?? "release",
|
|
483
529
|
sourceType: options.sourceType,
|
|
484
530
|
sourceId: options.sourceId,
|
|
531
|
+
actorProfileId: options.actorProfileId,
|
|
485
532
|
note: options.note
|
|
486
533
|
});
|
|
487
534
|
});
|
|
@@ -511,6 +558,7 @@ var StockService = class StockService {
|
|
|
511
558
|
reasonCode: options.reasonCode ?? "fulfillment",
|
|
512
559
|
sourceType: options.sourceType,
|
|
513
560
|
sourceId: options.sourceId,
|
|
561
|
+
actorProfileId: options.actorProfileId,
|
|
514
562
|
note: options.note
|
|
515
563
|
});
|
|
516
564
|
});
|
|
@@ -548,6 +596,7 @@ var StockService = class StockService {
|
|
|
548
596
|
reasonCode: options.reasonCode ?? "transfer_out",
|
|
549
597
|
sourceType: options.sourceType,
|
|
550
598
|
sourceId: options.sourceId,
|
|
599
|
+
actorProfileId: options.actorProfileId,
|
|
551
600
|
note: options.note
|
|
552
601
|
});
|
|
553
602
|
await adjustLevel(tx.levels, {
|
|
@@ -565,11 +614,38 @@ var StockService = class StockService {
|
|
|
565
614
|
reasonCode: options.reasonCode ?? "transfer_in",
|
|
566
615
|
sourceType: options.sourceType,
|
|
567
616
|
sourceId: options.sourceId,
|
|
617
|
+
actorProfileId: options.actorProfileId,
|
|
568
618
|
note: options.note
|
|
569
619
|
});
|
|
570
620
|
});
|
|
571
621
|
}
|
|
572
622
|
/**
|
|
623
|
+
* Configure replenishment for the available row at a SKU/location.
|
|
624
|
+
* Null disables the threshold. Metadata changes never fabricate movements.
|
|
625
|
+
* The optional quantity is replaced (omitting it clears the suggestion).
|
|
626
|
+
*/
|
|
627
|
+
async setReorderPolicy(skuId, locationId, reorderPoint, reorderQuantity = null) {
|
|
628
|
+
for (const [name, value] of Object.entries({
|
|
629
|
+
reorderPoint,
|
|
630
|
+
reorderQuantity
|
|
631
|
+
})) if (value !== null && (!Number.isFinite(value) || value < 0)) throw new Error(`${name} must be null or a non-negative finite number`);
|
|
632
|
+
return this.withTransaction(async (tx) => {
|
|
633
|
+
const level = await tx.levels.getLevel(skuId, locationId);
|
|
634
|
+
if (!level) return tx.levels.create({
|
|
635
|
+
skuId,
|
|
636
|
+
locationId,
|
|
637
|
+
state: "available",
|
|
638
|
+
qty: 0,
|
|
639
|
+
reorderPoint,
|
|
640
|
+
reorderQuantity
|
|
641
|
+
});
|
|
642
|
+
level.reorderPoint = reorderPoint;
|
|
643
|
+
level.reorderQuantity = reorderQuantity;
|
|
644
|
+
await level.save();
|
|
645
|
+
return level;
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
573
649
|
* Apply a positive or negative `delta` to a level row. Used for cycle
|
|
574
650
|
* counts and one-off corrections; `delta=+5` adds five units,
|
|
575
651
|
* `delta=-2` removes two. By default the adjustment targets
|
|
@@ -601,6 +677,7 @@ var StockService = class StockService {
|
|
|
601
677
|
reasonCode: options.reasonCode ?? "adjustment",
|
|
602
678
|
sourceType: options.sourceType,
|
|
603
679
|
sourceId: options.sourceId,
|
|
680
|
+
actorProfileId: options.actorProfileId,
|
|
604
681
|
note: options.note
|
|
605
682
|
});
|
|
606
683
|
});
|
|
@@ -635,6 +712,7 @@ async function transitionState(tx, args) {
|
|
|
635
712
|
reasonCode: args.reasonCode,
|
|
636
713
|
sourceType: args.sourceType,
|
|
637
714
|
sourceId: args.sourceId,
|
|
715
|
+
actorProfileId: args.actorProfileId,
|
|
638
716
|
note: args.note
|
|
639
717
|
});
|
|
640
718
|
}
|
|
@@ -666,6 +744,7 @@ async function writeMovement(movements, options) {
|
|
|
666
744
|
reasonCode: options.reasonCode,
|
|
667
745
|
sourceType: options.sourceType ?? "",
|
|
668
746
|
sourceId: options.sourceId ?? "",
|
|
747
|
+
actorProfileId: options.actorProfileId ?? null,
|
|
669
748
|
note: options.note ?? "",
|
|
670
749
|
occurredAt: /* @__PURE__ */ new Date()
|
|
671
750
|
});
|