@rytass/wms-module-graphql 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +19 -0
  2. package/docs/README.md +5 -2
  3. package/docs/api-reference.md +10 -8
  4. package/docs/integration-guide.md +34 -17
  5. package/docs/inventory-count.md +372 -0
  6. package/index.cjs.js +10 -0
  7. package/lib/inputs/index.d.ts +0 -0
  8. package/lib/inputs/inventory-count-order.args.d.ts +6 -0
  9. package/package.json +8 -29
  10. package/adapters/event-emitter.d.mts +0 -6
  11. package/adapters/event-emitter.mjs +0 -41
  12. package/adapters/member-base.d.mts +0 -6
  13. package/adapters/member-base.mjs +0 -63
  14. package/index.d.mts +0 -6
  15. package/index.mjs +0 -12
  16. package/lib/auth/host-skip.constant.mjs +0 -29
  17. package/lib/auth/wms-auth.guard.mjs +0 -41
  18. package/lib/auth/wms-auth.types.mjs +0 -6
  19. package/lib/auth/wms-operation.decorator.mjs +0 -29
  20. package/lib/dto/allocate-inventory-order-item.dto.mjs +0 -36
  21. package/lib/dto/allocate-inventory-order.dto.mjs +0 -31
  22. package/lib/dto/batch.dto.mjs +0 -26
  23. package/lib/dto/consumption-order-item.dto.mjs +0 -43
  24. package/lib/dto/consumption-order.dto.mjs +0 -52
  25. package/lib/dto/hold-inventory-order-item.dto.mjs +0 -37
  26. package/lib/dto/hold-inventory-order.dto.mjs +0 -47
  27. package/lib/dto/inventory-count-order.dto.mjs +0 -207
  28. package/lib/dto/loader-type.dto.mjs +0 -46
  29. package/lib/dto/loader-unit.dto.mjs +0 -21
  30. package/lib/dto/loader.dto.mjs +0 -71
  31. package/lib/dto/location.dto.mjs +0 -36
  32. package/lib/dto/material-unit.dto.mjs +0 -46
  33. package/lib/dto/material.dto.mjs +0 -36
  34. package/lib/dto/merge-batch-order.dto.mjs +0 -50
  35. package/lib/dto/order-reference.dto.mjs +0 -73
  36. package/lib/dto/pagination.dto.mjs +0 -51
  37. package/lib/dto/quality-inspection-order-item.dto.mjs +0 -50
  38. package/lib/dto/quality-inspection-order.dto.mjs +0 -42
  39. package/lib/dto/receive-inventory-order-item.dto.mjs +0 -60
  40. package/lib/dto/receive-inventory-order.dto.mjs +0 -58
  41. package/lib/dto/reclassify-inventory-order.dto.mjs +0 -55
  42. package/lib/dto/sale-order.dto.mjs +0 -20
  43. package/lib/dto/scrape-order-item.dto.mjs +0 -56
  44. package/lib/dto/scrape-order.dto.mjs +0 -37
  45. package/lib/dto/ship-inventory-order-item.dto.mjs +0 -56
  46. package/lib/dto/ship-inventory-order-reference.dto.mjs +0 -48
  47. package/lib/dto/ship-inventory-order.dto.mjs +0 -58
  48. package/lib/dto/split-batch-order.dto.mjs +0 -50
  49. package/lib/dto/stock.dto.mjs +0 -166
  50. package/lib/dto/transfer-customer-order-item.dto.mjs +0 -61
  51. package/lib/dto/transfer-customer-order.dto.mjs +0 -37
  52. package/lib/dto/transfer-order-item.dto.mjs +0 -41
  53. package/lib/dto/transfer-order.dto.mjs +0 -57
  54. package/lib/dto/transfer-vendor-order-item.dto.mjs +0 -61
  55. package/lib/dto/transfer-vendor-order.dto.mjs +0 -37
  56. package/lib/dto/unit.dto.mjs +0 -20
  57. package/lib/dto/warehouse-map.dto.mjs +0 -165
  58. package/lib/events/wms-mutation-event.constants.mjs +0 -4
  59. package/lib/events/wms-mutation-event.decorator.mjs +0 -20
  60. package/lib/events/wms-mutation.interceptor.mjs +0 -64
  61. package/lib/graphql.module.mjs +0 -183
  62. package/lib/helpers/create-wms-loaders.mjs +0 -11
  63. package/lib/helpers/helper.module.mjs +0 -15
  64. package/lib/helpers/loader.service.mjs +0 -230
  65. package/lib/helpers/query-path.mjs +0 -19
  66. package/lib/inputs/cancel-ship-order.args.mjs +0 -20
  67. package/lib/inputs/cancel-transfer-order.args.mjs +0 -23
  68. package/lib/inputs/consumption-order.args.mjs +0 -182
  69. package/lib/inputs/create-allocate-inventory-order-item.args.mjs +0 -50
  70. package/lib/inputs/create-allocate-inventory-order.args.mjs +0 -36
  71. package/lib/inputs/create-hold-inventory-order-item.args.mjs +0 -40
  72. package/lib/inputs/create-hold-inventory-order.args.mjs +0 -41
  73. package/lib/inputs/create-loader-type.args.mjs +0 -35
  74. package/lib/inputs/create-loader.args.mjs +0 -130
  75. package/lib/inputs/create-location.args.mjs +0 -50
  76. package/lib/inputs/create-material-unit.args.mjs +0 -25
  77. package/lib/inputs/create-material.args.mjs +0 -51
  78. package/lib/inputs/create-quality-inspection-order.args.mjs +0 -50
  79. package/lib/inputs/create-receive-inventory-order-item.args.mjs +0 -70
  80. package/lib/inputs/create-receive-inventory-order.args.mjs +0 -51
  81. package/lib/inputs/create-ship-inventory-order-item.args.mjs +0 -45
  82. package/lib/inputs/create-ship-inventory-order-reference.args.mjs +0 -65
  83. package/lib/inputs/create-ship-inventory-order.args.mjs +0 -57
  84. package/lib/inputs/create-transfer-customer-order-item.args.mjs +0 -40
  85. package/lib/inputs/create-transfer-customer-order.args.mjs +0 -51
  86. package/lib/inputs/create-transfer-order-item.args.mjs +0 -40
  87. package/lib/inputs/create-transfer-order.args.mjs +0 -61
  88. package/lib/inputs/create-transfer-vendor-order-item.args.mjs +0 -40
  89. package/lib/inputs/create-transfer-vendor-order.args.mjs +0 -51
  90. package/lib/inputs/date-range.args.mjs +0 -20
  91. package/lib/inputs/deallocate-order.args.mjs +0 -25
  92. package/lib/inputs/find-allocate-inventory-order.args.mjs +0 -42
  93. package/lib/inputs/find-batch.args.mjs +0 -21
  94. package/lib/inputs/find-hold-inventory-order.args.mjs +0 -42
  95. package/lib/inputs/find-loader-type.args.mjs +0 -32
  96. package/lib/inputs/find-loader.args.mjs +0 -72
  97. package/lib/inputs/find-location.args.mjs +0 -26
  98. package/lib/inputs/find-material.args.mjs +0 -21
  99. package/lib/inputs/find-receive-inventory-order.args.mjs +0 -71
  100. package/lib/inputs/find-sale-order.args.mjs +0 -16
  101. package/lib/inputs/find-ship-inventory-order.args.mjs +0 -71
  102. package/lib/inputs/find-stock.args.mjs +0 -102
  103. package/lib/inputs/find-transfer-order.args.mjs +0 -82
  104. package/lib/inputs/inventory-count-order.args.mjs +0 -257
  105. package/lib/inputs/merge-batch.args.mjs +0 -40
  106. package/lib/inputs/order-reference.args.mjs +0 -103
  107. package/lib/inputs/pagination.args.mjs +0 -20
  108. package/lib/inputs/receive-order.args.mjs +0 -40
  109. package/lib/inputs/reclassify-inventory-order.args.mjs +0 -40
  110. package/lib/inputs/release-order.args.mjs +0 -25
  111. package/lib/inputs/return-transfer-customer-order.args.mjs +0 -35
  112. package/lib/inputs/return-transfer-vendor-order.args.mjs +0 -35
  113. package/lib/inputs/scrape-order.args.mjs +0 -35
  114. package/lib/inputs/ship-order.args.mjs +0 -20
  115. package/lib/inputs/split-batch.args.mjs +0 -51
  116. package/lib/inputs/transfer-order.args.mjs +0 -20
  117. package/lib/inputs/update-warehouse-map.args.mjs +0 -121
  118. package/lib/mutations/allocate-inventory-order.mutation.mjs +0 -91
  119. package/lib/mutations/consumption-order.mutation.mjs +0 -90
  120. package/lib/mutations/hold-inventory-order.mutation.mjs +0 -91
  121. package/lib/mutations/inventory-count-order.mutation.mjs +0 -138
  122. package/lib/mutations/loader.mutation.mjs +0 -123
  123. package/lib/mutations/location.mutation.mjs +0 -47
  124. package/lib/mutations/material.mutation.mjs +0 -74
  125. package/lib/mutations/merge-batch.mutation.mjs +0 -50
  126. package/lib/mutations/order-reference.mutation.mjs +0 -57
  127. package/lib/mutations/quality-inspection-order.mutation.mjs +0 -50
  128. package/lib/mutations/receive-inventory-order.mutation.mjs +0 -106
  129. package/lib/mutations/reclassify-inventory-order.mutation.mjs +0 -51
  130. package/lib/mutations/scrape-order.mutation.mjs +0 -44
  131. package/lib/mutations/ship-inventory-order.mutation.mjs +0 -123
  132. package/lib/mutations/split-batch.mutation.mjs +0 -44
  133. package/lib/mutations/transfer-customer-order.mutation.mjs +0 -91
  134. package/lib/mutations/transfer-order.mutation.mjs +0 -96
  135. package/lib/mutations/transfer-vendor-order.mutation.mjs +0 -91
  136. package/lib/mutations/warehouse-map.mutation.mjs +0 -60
  137. package/lib/queries/allocate-inventory-order.query.mjs +0 -33
  138. package/lib/queries/batch.query.mjs +0 -36
  139. package/lib/queries/consumption-order.query.mjs +0 -45
  140. package/lib/queries/hold-inventory-order.query.mjs +0 -33
  141. package/lib/queries/inventory-count-order.query.mjs +0 -63
  142. package/lib/queries/loader.query.mjs +0 -167
  143. package/lib/queries/location.query.mjs +0 -51
  144. package/lib/queries/material.query.mjs +0 -79
  145. package/lib/queries/order-reference.query.mjs +0 -34
  146. package/lib/queries/recieve-inventory-order.query.mjs +0 -77
  147. package/lib/queries/sale-order.query.mjs +0 -57
  148. package/lib/queries/ship-inventory-order.query.mjs +0 -77
  149. package/lib/queries/stock.query.mjs +0 -116
  150. package/lib/queries/transfer-order.query.mjs +0 -46
  151. package/lib/queries/unit.query.mjs +0 -30
  152. package/lib/queries/warehouse-map.query.mjs +0 -32
  153. package/lib/registry/operation-registry.mjs +0 -136
  154. package/lib/resolvers/aggregated-stock.resolver.mjs +0 -119
  155. package/lib/resolvers/allocate-inventory-order.resolver.mjs +0 -27
  156. package/lib/resolvers/change-log.resolver.mjs +0 -99
  157. package/lib/resolvers/consumption-order.resolver.mjs +0 -238
  158. package/lib/resolvers/hold-inventory-order.resolver.mjs +0 -27
  159. package/lib/resolvers/inventory-count-order.resolver.mjs +0 -148
  160. package/lib/resolvers/loader-type.resolver.mjs +0 -54
  161. package/lib/resolvers/loader.resolver.mjs +0 -99
  162. package/lib/resolvers/location.resolver.mjs +0 -80
  163. package/lib/resolvers/material.resolver.mjs +0 -87
  164. package/lib/resolvers/merge-batch.resolver.mjs +0 -26
  165. package/lib/resolvers/receive-inventory-order.resolver.mjs +0 -156
  166. package/lib/resolvers/ship-inventory-order.resolver.mjs +0 -301
  167. package/lib/resolvers/split-batch.resolver.mjs +0 -26
  168. package/lib/resolvers/stock.resolver.mjs +0 -99
  169. package/lib/resolvers/transfer-customer-order.resolver.mjs +0 -27
  170. package/lib/resolvers/transfer-order.resolver.mjs +0 -246
  171. package/lib/resolvers/transfer-vendor-order.resolver.mjs +0 -27
  172. package/lib/resolvers/warehouse-map.resolver.mjs +0 -41
  173. package/lib/scalars/json-object.scalar.mjs +0 -62
package/index.cjs.js CHANGED
@@ -8024,6 +8024,12 @@ let CreateInventoryCountOrderArgs = class CreateInventoryCountOrderArgs {
8024
8024
  countDate;
8025
8025
  /** Root locations; every descendant is pulled into scope automatically. */
8026
8026
  locationIds;
8027
+ /**
8028
+ * Who opened the count, as the host names its users. Shown as 建立者 and
8029
+ * matched by the list's `createdBy` filter; the other order families take
8030
+ * it the same way.
8031
+ */
8032
+ createdBy;
8027
8033
  };
8028
8034
  tslib.__decorate([
8029
8035
  graphql.Field(() => String),
@@ -8037,6 +8043,10 @@ tslib.__decorate([
8037
8043
  graphql.Field(() => [graphql.ID]),
8038
8044
  tslib.__metadata("design:type", Array)
8039
8045
  ], CreateInventoryCountOrderArgs.prototype, "locationIds", void 0);
8046
+ tslib.__decorate([
8047
+ graphql.Field(() => String, { nullable: true }),
8048
+ tslib.__metadata("design:type", String)
8049
+ ], CreateInventoryCountOrderArgs.prototype, "createdBy", void 0);
8040
8050
  CreateInventoryCountOrderArgs = tslib.__decorate([
8041
8051
  graphql.ArgsType()
8042
8052
  ], CreateInventoryCountOrderArgs);
File without changes
@@ -33,6 +33,12 @@ export declare class CreateInventoryCountOrderArgs {
33
33
  countDate: string;
34
34
  /** Root locations; every descendant is pulled into scope automatically. */
35
35
  locationIds: string[];
36
+ /**
37
+ * Who opened the count, as the host names its users. Shown as 建立者 and
38
+ * matched by the list's `createdBy` filter; the other order families take
39
+ * it the same way.
40
+ */
41
+ createdBy?: string;
36
42
  }
37
43
  export declare class UpdateInventoryCountOrderArgs {
38
44
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/wms-module-graphql",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "description": "Rytass WMS Module — GraphQL schema, resolvers and DTOs for warehouse management",
5
5
  "keywords": [
6
6
  "rytass",
@@ -21,46 +21,25 @@
21
21
  "url": "https://github.com/Rytass/WMS-Module/issues"
22
22
  },
23
23
  "main": "./index.cjs.js",
24
- "module": "./index.mjs",
25
24
  "typings": "./index.d.ts",
26
25
  "exports": {
27
26
  ".": {
28
- "import": {
29
- "types": "./index.d.mts",
30
- "default": "./index.mjs"
31
- },
32
- "require": {
33
- "types": "./index.d.ts",
34
- "default": "./index.cjs.js"
35
- }
27
+ "types": "./index.d.ts",
28
+ "default": "./index.cjs.js"
36
29
  },
37
30
  "./adapters/member-base": {
38
- "import": {
39
- "types": "./adapters/member-base.d.mts",
40
- "default": "./adapters/member-base.mjs"
41
- },
42
- "require": {
43
- "types": "./adapters/member-base.d.ts",
44
- "default": "./adapters/member-base.cjs.js"
45
- }
31
+ "types": "./adapters/member-base.d.ts",
32
+ "default": "./adapters/member-base.cjs.js"
46
33
  },
47
34
  "./adapters/event-emitter": {
48
- "import": {
49
- "types": "./adapters/event-emitter.d.mts",
50
- "default": "./adapters/event-emitter.mjs"
51
- },
52
- "require": {
53
- "types": "./adapters/event-emitter.d.ts",
54
- "default": "./adapters/event-emitter.cjs.js"
55
- }
35
+ "types": "./adapters/event-emitter.d.ts",
36
+ "default": "./adapters/event-emitter.cjs.js"
56
37
  },
57
38
  "./package.json": "./package.json"
58
39
  },
59
40
  "files": [
60
41
  "**/*.js",
61
- "**/*.mjs",
62
42
  "**/*.d.ts",
63
- "**/*.d.mts",
64
43
  "README.md",
65
44
  "LICENSE",
66
45
  "docs",
@@ -84,7 +63,7 @@
84
63
  "@nestjs/core": "^10.0.0 || ^11.0.0",
85
64
  "@nestjs/graphql": "^13.0.0",
86
65
  "@rytass/wms-base-nestjs-module": "^0.4.0",
87
- "@rytass/wms-module-core": "^0.9.1",
66
+ "@rytass/wms-module-core": "^0.10.0",
88
67
  "graphql": "^16.0.0",
89
68
  "reflect-metadata": "^0.1.13 || ^0.2.0",
90
69
  "rxjs": "^7.0.0",
@@ -1,6 +0,0 @@
1
- // Generated by tools/emit-esm-type-shims.mjs — do not edit.
2
- //
3
- // ESM-flavoured types for the `import` condition. The declarations
4
- // themselves live in the sibling .d.ts, which is CJS-flavoured because
5
- // this package has no "type": "module".
6
- export * from './event-emitter.js';
@@ -1,41 +0,0 @@
1
- import { EventEmitter2 } from '@nestjs/event-emitter';
2
- import { WMS_EVENT_EMITTER_BRIDGE } from '@rytass/wms-module-core';
3
-
4
- /**
5
- * Bridges WMS domain events onto `@nestjs/event-emitter`'s `EventEmitter2`, so
6
- * consumers can subscribe with `@OnEvent('wms.<event-name>')` instead of (or in
7
- * addition to) the typed `afterListeners`.
8
- *
9
- * Pass this into `WmsModuleGraphqlModule.forRootAsync({ eventEmitterBridge })`.
10
- * Importing this module is the only place `@nestjs/event-emitter` is referenced,
11
- * keeping it an entirely optional peer dependency — the core graphql module
12
- * never imports it.
13
- *
14
- * Prerequisite: register `EventEmitterModule.forRoot()` in your app so an
15
- * `EventEmitter2` instance is available for injection.
16
- *
17
- * @example
18
- * ```ts
19
- * import { wmsEventEmitterBridgeProvider } from '@rytass/wms-module-graphql/adapters/event-emitter';
20
- *
21
- * WmsModuleGraphqlModule.forRootAsync({
22
- * ...coreOptions,
23
- * eventEmitterBridge: wmsEventEmitterBridgeProvider,
24
- * });
25
- *
26
- * // elsewhere
27
- * @OnEvent('wms.stock.allocated')
28
- * handle(payload: WmsStockEventPayload) { ... }
29
- * ```
30
- */
31
- const wmsEventEmitterBridgeProvider = {
32
- provide: WMS_EVENT_EMITTER_BRIDGE,
33
- useFactory: (emitter) => ({
34
- forward: (event) => {
35
- emitter.emit(`wms.${event.name}`, event.payload);
36
- },
37
- }),
38
- inject: [EventEmitter2],
39
- };
40
-
41
- export { wmsEventEmitterBridgeProvider };
@@ -1,6 +0,0 @@
1
- // Generated by tools/emit-esm-type-shims.mjs — do not edit.
2
- //
3
- // ESM-flavoured types for the `import` condition. The declarations
4
- // themselves live in the sibling .d.ts, which is CJS-flavoured because
5
- // this package has no "type": "module".
6
- export * from './member-base.js';
@@ -1,63 +0,0 @@
1
- import { GqlExecutionContext } from '@nestjs/graphql';
2
-
3
- const extractRequest = (context) => {
4
- const gqlContext = GqlExecutionContext.create(context).getContext();
5
- return gqlContext?.req;
6
- };
7
- /**
8
- * Builds a {@link WmsAuthChecker} that authorizes WMS operations against
9
- * `@rytass/member-base-nestjs-module`'s Casbin setup.
10
- *
11
- * It reuses everything the host's global `CasbinGuard` already prepared on the
12
- * request — the verified `payload`, the `enforcer`, and even the consumer's
13
- * (possibly customized) `casbinPermissionChecker`. WMS therefore enforces with
14
- * the *exact same* policy engine and rules as the host's own resolvers, with no
15
- * member-base import on the WMS side.
16
- *
17
- * Prerequisite: register `MemberBaseModule` with its global guard enabled
18
- * (the default), and expose the request on the GraphQL context as `req`
19
- * (Apollo's default).
20
- */
21
- const createMemberBaseWmsAuthChecker = (options) => {
22
- return async (context, requirement) => {
23
- const request = extractRequest(context);
24
- // No verified member → unauthenticated. CasbinGuard sets `payload` to
25
- // undefined when the token is missing or invalid.
26
- if (!request?.payload) {
27
- return false;
28
- }
29
- // The enforcer / checker are injected by CasbinGuard. Their absence means
30
- // the host did not enable the global guard — fail closed rather than
31
- // silently allowing everything.
32
- if (!request.enforcer || !request.casbinPermissionChecker) {
33
- return false;
34
- }
35
- const actions = options.map(requirement);
36
- if (actions.length === 0) {
37
- return false;
38
- }
39
- return request.casbinPermissionChecker({
40
- enforcer: request.enforcer,
41
- payload: request.payload,
42
- actions,
43
- });
44
- };
45
- };
46
- /**
47
- * A {@link WmsActorExtractor} for `@rytass/member-base-nestjs-module`. Reads the
48
- * verified JWT payload that `CasbinGuard` attaches to the request and surfaces it
49
- * as the event/hook `actor`. Returns `null` for unauthenticated requests.
50
- *
51
- * Pass to `WmsModuleGraphqlModule.forRootAsync({ actorExtractor })` so every
52
- * operation event and before-hook carries `{ id, domain }`. Imports nothing from
53
- * member-base — it only reads the runtime request fields.
54
- */
55
- const memberBaseActorExtractor = (context) => {
56
- const payload = extractRequest(context)?.payload;
57
- if (!payload?.id) {
58
- return null;
59
- }
60
- return { id: payload.id, domain: payload.domain, raw: payload };
61
- };
62
-
63
- export { createMemberBaseWmsAuthChecker, memberBaseActorExtractor };
package/index.d.mts DELETED
@@ -1,6 +0,0 @@
1
- // Generated by tools/emit-esm-type-shims.mjs — do not edit.
2
- //
3
- // ESM-flavoured types for the `import` condition. The declarations
4
- // themselves live in the sibling .d.ts, which is CJS-flavoured because
5
- // this package has no "type": "module".
6
- export * from './index.js';
package/index.mjs DELETED
@@ -1,12 +0,0 @@
1
- export { WmsModuleGraphqlModule } from './lib/graphql.module.mjs';
2
- export { LoaderService } from './lib/helpers/loader.service.mjs';
3
- export { createWmsLoaders } from './lib/helpers/create-wms-loaders.mjs';
4
- export { HOST_SKIP_METADATA_KEY } from './lib/auth/host-skip.constant.mjs';
5
- export { WmsAuthGuard } from './lib/auth/wms-auth.guard.mjs';
6
- export { WmsOperation } from './lib/auth/wms-operation.decorator.mjs';
7
- export { WMS_AUTH_OPTIONS, WMS_OPERATION_METADATA } from './lib/auth/wms-auth.types.mjs';
8
- export { pruneDisabledOperations } from './lib/registry/operation-registry.mjs';
9
- export { WmsMutationEvent } from './lib/events/wms-mutation-event.decorator.mjs';
10
- export { WMS_MUTATION_EVENT_METADATA } from './lib/events/wms-mutation-event.constants.mjs';
11
- export { WmsMutationInterceptor } from './lib/events/wms-mutation.interceptor.mjs';
12
- export { WMS_OPERATION_NAMES } from '@rytass/wms-module-core';
@@ -1,29 +0,0 @@
1
- /**
2
- * Metadata key stamped on every `@WmsOperation` handler so that a host
3
- * application's *globally registered* auth guard (`APP_GUARD`) treats WMS
4
- * resolvers as "skip / public" and defers the real authorization decision to
5
- * {@link WmsAuthGuard}.
6
- *
7
- * Why this exists
8
- * ---------------
9
- * A deny-by-default global guard — e.g. the `CasbinGuard` from
10
- * `@rytass/member-base-nestjs-module` — blankets every resolver in the compiled
11
- * schema, including the ones this library owns. WMS resolvers carry no
12
- * host-specific permission metadata, so such a guard rejects them all. By
13
- * stamping this key WMS tells the host guard "let me through", and then runs
14
- * its own {@link WmsAuthGuard} (wired to the consumer's `authChecker`) to do the
15
- * actual enforcement.
16
- *
17
- * The single coupling point
18
- * -------------------------
19
- * The default value matches `@rytass/member-base-nestjs-module`'s
20
- * `IS_ROUTE_PUBLIC` metadata key. This is the *one and only* place WMS assumes
21
- * anything about a specific host guard. If your host guard uses a different
22
- * "public / skip" metadata key, fork this constant — nothing else changes.
23
- *
24
- * If you do not register a global guard at all (or set
25
- * `enableGlobalGuard: false`), this marker is simply inert.
26
- */
27
- const HOST_SKIP_METADATA_KEY = 'IS_ROUTE_PUBLIC';
28
-
29
- export { HOST_SKIP_METADATA_KEY };
@@ -1,41 +0,0 @@
1
- import { __decorate, __param, __metadata } from 'tslib';
2
- import { Injectable, Inject } from '@nestjs/common';
3
- import { Reflector } from '@nestjs/core';
4
- import { WMS_AUTH_OPTIONS, WMS_OPERATION_METADATA } from './wms-auth.types.mjs';
5
-
6
- /**
7
- * Route-level guard applied automatically by `@WmsOperation`. It reads the
8
- * requirement declared on the handler and delegates the allow/deny decision to
9
- * the consumer-supplied {@link WmsAuthModuleOptions.authChecker}.
10
- *
11
- * It is deliberately permissive in two cases:
12
- * - the handler carries no requirement (field resolvers reached only through an
13
- * already-authorized root operation), and
14
- * - no `authChecker` was configured (local dev / auth handled elsewhere).
15
- */
16
- let WmsAuthGuard = class WmsAuthGuard {
17
- reflector;
18
- options;
19
- constructor(reflector, options) {
20
- this.reflector = reflector;
21
- this.options = options;
22
- }
23
- canActivate(context) {
24
- const requirement = this.reflector.get(WMS_OPERATION_METADATA, context.getHandler());
25
- if (!requirement) {
26
- return true;
27
- }
28
- const { authChecker } = this.options;
29
- if (!authChecker) {
30
- return true;
31
- }
32
- return authChecker(context, requirement);
33
- }
34
- };
35
- WmsAuthGuard = __decorate([
36
- Injectable(),
37
- __param(1, Inject(WMS_AUTH_OPTIONS)),
38
- __metadata("design:paramtypes", [Reflector, Object])
39
- ], WmsAuthGuard);
40
-
41
- export { WmsAuthGuard };
@@ -1,6 +0,0 @@
1
- /** DI token holding the resolved {@link WmsAuthModuleOptions}. */
2
- const WMS_AUTH_OPTIONS = Symbol('WMS_AUTH_OPTIONS');
3
- /** Reflector metadata key carrying the {@link WmsOperationRequirement}. */
4
- const WMS_OPERATION_METADATA = 'wms:operation';
5
-
6
- export { WMS_AUTH_OPTIONS, WMS_OPERATION_METADATA };
@@ -1,29 +0,0 @@
1
- import { applyDecorators, SetMetadata, UseGuards } from '@nestjs/common';
2
- import { HOST_SKIP_METADATA_KEY } from './host-skip.constant.mjs';
3
- import { WmsAuthGuard } from './wms-auth.guard.mjs';
4
- import { WMS_OPERATION_METADATA } from './wms-auth.types.mjs';
5
-
6
- /**
7
- * Declares the permission requirement for a WMS root operation and wires up its
8
- * enforcement. Apply it to every `@Query` / `@Mutation` the library exposes.
9
- *
10
- * It bundles three concerns so a single annotation keeps a resolver
11
- * self-protecting and host-friendly:
12
- *
13
- * 1. {@link WMS_OPERATION_METADATA} — the host-neutral `{ resource, action }`
14
- * that {@link WmsAuthGuard} hands to the consumer's `authChecker`.
15
- * 2. {@link HOST_SKIP_METADATA_KEY} — tells a host's global guard to defer (see
16
- * that constant for the single coupling point with member-base).
17
- * 3. `@UseGuards(WmsAuthGuard)` — the route-level guard that performs the real
18
- * authorization through the configured `authChecker`.
19
- *
20
- * @example
21
- * ```ts
22
- * @Query(() => MaterialDto)
23
- * @WmsOperation({ resource: 'material', action: 'read' })
24
- * material(@Args('id') id: string): Promise<MaterialDto> { ... }
25
- * ```
26
- */
27
- const WmsOperation = (requirement) => applyDecorators(SetMetadata(WMS_OPERATION_METADATA, requirement), SetMetadata(HOST_SKIP_METADATA_KEY, true), UseGuards(WmsAuthGuard));
28
-
29
- export { WmsOperation };
@@ -1,36 +0,0 @@
1
- import { __decorate, __metadata } from 'tslib';
2
- import { Field, ID, Int, ObjectType } from '@nestjs/graphql';
3
-
4
- let AllocateInventoryOrderItemDto = class AllocateInventoryOrderItemDto {
5
- id;
6
- materialId;
7
- batchId;
8
- locationId;
9
- loaderId;
10
- orderId;
11
- unitId;
12
- targetAllocatedQuantity;
13
- saleId;
14
- saleSerialId;
15
- };
16
- __decorate([
17
- Field(() => ID),
18
- __metadata("design:type", String)
19
- ], AllocateInventoryOrderItemDto.prototype, "id", void 0);
20
- __decorate([
21
- Field(() => Int),
22
- __metadata("design:type", Number)
23
- ], AllocateInventoryOrderItemDto.prototype, "targetAllocatedQuantity", void 0);
24
- __decorate([
25
- Field(() => String),
26
- __metadata("design:type", String)
27
- ], AllocateInventoryOrderItemDto.prototype, "saleId", void 0);
28
- __decorate([
29
- Field(() => String),
30
- __metadata("design:type", String)
31
- ], AllocateInventoryOrderItemDto.prototype, "saleSerialId", void 0);
32
- AllocateInventoryOrderItemDto = __decorate([
33
- ObjectType()
34
- ], AllocateInventoryOrderItemDto);
35
-
36
- export { AllocateInventoryOrderItemDto };
@@ -1,31 +0,0 @@
1
- import { __decorate, __metadata } from 'tslib';
2
- import { Field, ID, ObjectType } from '@nestjs/graphql';
3
- import { PaginatedResponse } from './pagination.dto.mjs';
4
-
5
- let AllocateInventoryOrderDto = class AllocateInventoryOrderDto {
6
- id;
7
- key;
8
- createdAt;
9
- };
10
- __decorate([
11
- Field(() => ID),
12
- __metadata("design:type", String)
13
- ], AllocateInventoryOrderDto.prototype, "id", void 0);
14
- __decorate([
15
- Field(() => String),
16
- __metadata("design:type", String)
17
- ], AllocateInventoryOrderDto.prototype, "key", void 0);
18
- __decorate([
19
- Field(() => Date),
20
- __metadata("design:type", Date)
21
- ], AllocateInventoryOrderDto.prototype, "createdAt", void 0);
22
- AllocateInventoryOrderDto = __decorate([
23
- ObjectType()
24
- ], AllocateInventoryOrderDto);
25
- let AllocateInventoryOrders = class AllocateInventoryOrders extends PaginatedResponse(AllocateInventoryOrderDto) {
26
- };
27
- AllocateInventoryOrders = __decorate([
28
- ObjectType()
29
- ], AllocateInventoryOrders);
30
-
31
- export { AllocateInventoryOrderDto, AllocateInventoryOrders };
@@ -1,26 +0,0 @@
1
- import { __decorate, __metadata } from 'tslib';
2
- import { Field, ID, ObjectType } from '@nestjs/graphql';
3
- import { PaginatedResponse } from './pagination.dto.mjs';
4
-
5
- let BatchDto = class BatchDto {
6
- id;
7
- key;
8
- };
9
- __decorate([
10
- Field(() => ID),
11
- __metadata("design:type", String)
12
- ], BatchDto.prototype, "id", void 0);
13
- __decorate([
14
- Field(() => String),
15
- __metadata("design:type", String)
16
- ], BatchDto.prototype, "key", void 0);
17
- BatchDto = __decorate([
18
- ObjectType()
19
- ], BatchDto);
20
- let Batches = class Batches extends PaginatedResponse(BatchDto) {
21
- };
22
- Batches = __decorate([
23
- ObjectType()
24
- ], Batches);
25
-
26
- export { BatchDto, Batches };
@@ -1,43 +0,0 @@
1
- import { __decorate, __metadata } from 'tslib';
2
- import { Field, ID, Float, ObjectType } from '@nestjs/graphql';
3
- import { PaginatedResponse } from './pagination.dto.mjs';
4
-
5
- let ConsumptionOrderItemDto = class ConsumptionOrderItemDto {
6
- id;
7
- materialId;
8
- batchId;
9
- locationId;
10
- loaderId;
11
- targetLocationId;
12
- targetLoaderId;
13
- orderId;
14
- unitId;
15
- targetConsumedQuantity;
16
- removedAt;
17
- };
18
- __decorate([
19
- Field(() => ID),
20
- __metadata("design:type", String)
21
- ], ConsumptionOrderItemDto.prototype, "id", void 0);
22
- __decorate([
23
- Field(() => String, { nullable: true }),
24
- __metadata("design:type", Object)
25
- ], ConsumptionOrderItemDto.prototype, "unitId", void 0);
26
- __decorate([
27
- Field(() => Float),
28
- __metadata("design:type", Number)
29
- ], ConsumptionOrderItemDto.prototype, "targetConsumedQuantity", void 0);
30
- __decorate([
31
- Field(() => Date, { nullable: true }),
32
- __metadata("design:type", Object)
33
- ], ConsumptionOrderItemDto.prototype, "removedAt", void 0);
34
- ConsumptionOrderItemDto = __decorate([
35
- ObjectType()
36
- ], ConsumptionOrderItemDto);
37
- let ConsumptionOrderItems = class ConsumptionOrderItems extends PaginatedResponse(ConsumptionOrderItemDto) {
38
- };
39
- ConsumptionOrderItems = __decorate([
40
- ObjectType()
41
- ], ConsumptionOrderItems);
42
-
43
- export { ConsumptionOrderItemDto, ConsumptionOrderItems };
@@ -1,52 +0,0 @@
1
- import { __decorate, __metadata } from 'tslib';
2
- import { Field, ID, ObjectType } from '@nestjs/graphql';
3
- import { ConsumptionOrderItemDto } from './consumption-order-item.dto.mjs';
4
- import { PaginatedResponse } from './pagination.dto.mjs';
5
-
6
- let ConsumptionOrderDto = class ConsumptionOrderDto {
7
- id;
8
- key;
9
- description;
10
- createdBy;
11
- removedAt;
12
- createdAt;
13
- items;
14
- };
15
- __decorate([
16
- Field(() => ID),
17
- __metadata("design:type", String)
18
- ], ConsumptionOrderDto.prototype, "id", void 0);
19
- __decorate([
20
- Field(() => String),
21
- __metadata("design:type", String)
22
- ], ConsumptionOrderDto.prototype, "key", void 0);
23
- __decorate([
24
- Field(() => String, { nullable: true }),
25
- __metadata("design:type", Object)
26
- ], ConsumptionOrderDto.prototype, "description", void 0);
27
- __decorate([
28
- Field(() => String, { nullable: true }),
29
- __metadata("design:type", Object)
30
- ], ConsumptionOrderDto.prototype, "createdBy", void 0);
31
- __decorate([
32
- Field(() => Date, { nullable: true }),
33
- __metadata("design:type", Object)
34
- ], ConsumptionOrderDto.prototype, "removedAt", void 0);
35
- __decorate([
36
- Field(() => Date),
37
- __metadata("design:type", Date)
38
- ], ConsumptionOrderDto.prototype, "createdAt", void 0);
39
- __decorate([
40
- Field(() => [ConsumptionOrderItemDto]),
41
- __metadata("design:type", Array)
42
- ], ConsumptionOrderDto.prototype, "items", void 0);
43
- ConsumptionOrderDto = __decorate([
44
- ObjectType()
45
- ], ConsumptionOrderDto);
46
- let ConsumptionOrders = class ConsumptionOrders extends PaginatedResponse(ConsumptionOrderDto) {
47
- };
48
- ConsumptionOrders = __decorate([
49
- ObjectType()
50
- ], ConsumptionOrders);
51
-
52
- export { ConsumptionOrderDto, ConsumptionOrders };
@@ -1,37 +0,0 @@
1
- import { __decorate, __metadata } from 'tslib';
2
- import { Field, ID, Int, ObjectType } from '@nestjs/graphql';
3
- import { PaginatedResponse } from './pagination.dto.mjs';
4
-
5
- let HoldInventoryOrderItemDto = class HoldInventoryOrderItemDto {
6
- id;
7
- materialId;
8
- batchId;
9
- locationId;
10
- loaderId;
11
- orderId;
12
- unitId;
13
- targetHeldQuantity;
14
- removedAt;
15
- };
16
- __decorate([
17
- Field(() => ID),
18
- __metadata("design:type", String)
19
- ], HoldInventoryOrderItemDto.prototype, "id", void 0);
20
- __decorate([
21
- Field(() => Int),
22
- __metadata("design:type", Number)
23
- ], HoldInventoryOrderItemDto.prototype, "targetHeldQuantity", void 0);
24
- __decorate([
25
- Field(() => Date, { nullable: true }),
26
- __metadata("design:type", Object)
27
- ], HoldInventoryOrderItemDto.prototype, "removedAt", void 0);
28
- HoldInventoryOrderItemDto = __decorate([
29
- ObjectType()
30
- ], HoldInventoryOrderItemDto);
31
- let HoldInventoryOrderItems = class HoldInventoryOrderItems extends PaginatedResponse(HoldInventoryOrderItemDto) {
32
- };
33
- HoldInventoryOrderItems = __decorate([
34
- ObjectType()
35
- ], HoldInventoryOrderItems);
36
-
37
- export { HoldInventoryOrderItemDto, HoldInventoryOrderItems };
@@ -1,47 +0,0 @@
1
- import { __decorate, __metadata } from 'tslib';
2
- import { Field, ID, ObjectType } from '@nestjs/graphql';
3
- import { HoldInventoryOrderItemDto } from './hold-inventory-order-item.dto.mjs';
4
- import { PaginatedResponse } from './pagination.dto.mjs';
5
-
6
- let HoldInventoryOrderDto = class HoldInventoryOrderDto {
7
- id;
8
- key;
9
- createdBy;
10
- removedAt;
11
- createdAt;
12
- items;
13
- };
14
- __decorate([
15
- Field(() => ID),
16
- __metadata("design:type", String)
17
- ], HoldInventoryOrderDto.prototype, "id", void 0);
18
- __decorate([
19
- Field(() => String),
20
- __metadata("design:type", String)
21
- ], HoldInventoryOrderDto.prototype, "key", void 0);
22
- __decorate([
23
- Field(() => String, { nullable: true }),
24
- __metadata("design:type", Object)
25
- ], HoldInventoryOrderDto.prototype, "createdBy", void 0);
26
- __decorate([
27
- Field(() => Date, { nullable: true }),
28
- __metadata("design:type", Object)
29
- ], HoldInventoryOrderDto.prototype, "removedAt", void 0);
30
- __decorate([
31
- Field(() => Date),
32
- __metadata("design:type", Date)
33
- ], HoldInventoryOrderDto.prototype, "createdAt", void 0);
34
- __decorate([
35
- Field(() => [HoldInventoryOrderItemDto]),
36
- __metadata("design:type", Array)
37
- ], HoldInventoryOrderDto.prototype, "items", void 0);
38
- HoldInventoryOrderDto = __decorate([
39
- ObjectType()
40
- ], HoldInventoryOrderDto);
41
- let HoldInventoryOrders = class HoldInventoryOrders extends PaginatedResponse(HoldInventoryOrderDto) {
42
- };
43
- HoldInventoryOrders = __decorate([
44
- ObjectType()
45
- ], HoldInventoryOrders);
46
-
47
- export { HoldInventoryOrderDto, HoldInventoryOrders };