@mercurjs/framework 1.5.1 → 1.5.3

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.
@@ -21,7 +21,8 @@ export declare enum ProductRequestUpdatedEvent {
21
21
  CREATED = "requests.product.created",
22
22
  ACCEPTED = "requests.product.accepted",
23
23
  REJECTED = "requests.product.rejected",
24
- TO_CREATE = "requests.product.to_create"
24
+ TO_CREATE = "requests.product.to_create",
25
+ DELETED = "requests.product.deleted"
25
26
  }
26
27
  export declare enum ProductUpdateRequestUpdatedEvent {
27
28
  CREATED = "requests.product_update.created",
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/types/requests/events.ts"],"names":[],"mappings":"AAAA,oBAAY,gCAAgC;IAC1C,QAAQ,6BAA6B;IACrC,QAAQ,6BAA6B;CACtC;AAED,oBAAY,aAAa;IACvB,OAAO,4BAA4B;IACnC,SAAS,8BAA8B;CACxC;AAED,oBAAY,cAAc;IACxB,OAAO,uBAAuB;CAC/B;AAED,oBAAY,kCAAkC;IAC5C,QAAQ,uCAAuC;IAC/C,QAAQ,uCAAuC;CAChD;AAED,oBAAY,oCAAoC;IAC9C,QAAQ,yCAAyC;IACjD,QAAQ,yCAAyC;CAClD;AAED,oBAAY,0BAA0B;IACpC,OAAO,6BAA6B;IACpC,QAAQ,8BAA8B;IACtC,QAAQ,8BAA8B;IACtC,SAAS,+BAA+B;CACzC;AAED,oBAAY,gCAAgC;IAC1C,OAAO,oCAAoC;IAC3C,QAAQ,qCAAqC;IAC7C,QAAQ,qCAAqC;IAC7C,SAAS,sCAAsC;CAChD;AAED,oBAAY,uCAAuC;IACjD,SAAS,8CAA8C;CACxD;AAED,oBAAY,qBAAqB;IAC/B,OAAO,+BAA+B;CACvC;AAED,oBAAY,8BAA8B;IACxC,QAAQ,mCAAmC;IAC3C,QAAQ,mCAAmC;CAC5C;AAED,oBAAY,6BAA6B;IACvC,QAAQ,kCAAkC;IAC1C,QAAQ,kCAAkC;CAC3C;AAED,oBAAY,+BAA+B;IACzC,OAAO,4BAA4B;CACpC"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/types/requests/events.ts"],"names":[],"mappings":"AAAA,oBAAY,gCAAgC;IAC1C,QAAQ,6BAA6B;IACrC,QAAQ,6BAA6B;CACtC;AAED,oBAAY,aAAa;IACvB,OAAO,4BAA4B;IACnC,SAAS,8BAA8B;CACxC;AAED,oBAAY,cAAc;IACxB,OAAO,uBAAuB;CAC/B;AAED,oBAAY,kCAAkC;IAC5C,QAAQ,uCAAuC;IAC/C,QAAQ,uCAAuC;CAChD;AAED,oBAAY,oCAAoC;IAC9C,QAAQ,yCAAyC;IACjD,QAAQ,yCAAyC;CAClD;AAED,oBAAY,0BAA0B;IACpC,OAAO,6BAA6B;IACpC,QAAQ,8BAA8B;IACtC,QAAQ,8BAA8B;IACtC,SAAS,+BAA+B;IACxC,OAAO,6BAA6B;CACrC;AAED,oBAAY,gCAAgC;IAC1C,OAAO,oCAAoC;IAC3C,QAAQ,qCAAqC;IAC7C,QAAQ,qCAAqC;IAC7C,SAAS,sCAAsC;CAChD;AAED,oBAAY,uCAAuC;IACjD,SAAS,8CAA8C;CACxD;AAED,oBAAY,qBAAqB;IAC/B,OAAO,+BAA+B;CACvC;AAED,oBAAY,8BAA8B;IACxC,QAAQ,mCAAmC;IAC3C,QAAQ,mCAAmC;CAC5C;AAED,oBAAY,6BAA6B;IACvC,QAAQ,kCAAkC;IAC1C,QAAQ,kCAAkC;CAC3C;AAED,oBAAY,+BAA+B;IACzC,OAAO,4BAA4B;CACpC"}
@@ -31,6 +31,7 @@ var ProductRequestUpdatedEvent;
31
31
  ProductRequestUpdatedEvent["ACCEPTED"] = "requests.product.accepted";
32
32
  ProductRequestUpdatedEvent["REJECTED"] = "requests.product.rejected";
33
33
  ProductRequestUpdatedEvent["TO_CREATE"] = "requests.product.to_create";
34
+ ProductRequestUpdatedEvent["DELETED"] = "requests.product.deleted";
34
35
  })(ProductRequestUpdatedEvent || (exports.ProductRequestUpdatedEvent = ProductRequestUpdatedEvent = {}));
35
36
  var ProductUpdateRequestUpdatedEvent;
36
37
  (function (ProductUpdateRequestUpdatedEvent) {
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/types/requests/events.ts"],"names":[],"mappings":";;;AAAA,IAAY,gCAGX;AAHD,WAAY,gCAAgC;IAC1C,yEAAqC,CAAA;IACrC,yEAAqC,CAAA;AACvC,CAAC,EAHW,gCAAgC,gDAAhC,gCAAgC,QAG3C;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,oDAAmC,CAAA;IACnC,wDAAuC,CAAA;AACzC,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAED,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,gDAA8B,CAAA;AAChC,CAAC,EAFW,cAAc,8BAAd,cAAc,QAEzB;AAED,IAAY,kCAGX;AAHD,WAAY,kCAAkC;IAC5C,qFAA+C,CAAA;IAC/C,qFAA+C,CAAA;AACjD,CAAC,EAHW,kCAAkC,kDAAlC,kCAAkC,QAG7C;AAED,IAAY,oCAGX;AAHD,WAAY,oCAAoC;IAC9C,yFAAiD,CAAA;IACjD,yFAAiD,CAAA;AACnD,CAAC,EAHW,oCAAoC,oDAApC,oCAAoC,QAG/C;AAED,IAAY,0BAKX;AALD,WAAY,0BAA0B;IACpC,kEAAoC,CAAA;IACpC,oEAAsC,CAAA;IACtC,oEAAsC,CAAA;IACtC,sEAAwC,CAAA;AAC1C,CAAC,EALW,0BAA0B,0CAA1B,0BAA0B,QAKrC;AAED,IAAY,gCAKX;AALD,WAAY,gCAAgC;IAC1C,+EAA2C,CAAA;IAC3C,iFAA6C,CAAA;IAC7C,iFAA6C,CAAA;IAC7C,mFAA+C,CAAA;AACjD,CAAC,EALW,gCAAgC,gDAAhC,gCAAgC,QAK3C;AAED,IAAY,uCAEX;AAFD,WAAY,uCAAuC;I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C,QAG/C;AAED,IAAY,0BAMX;AAND,WAAY,0BAA0B;IACpC,kEAAoC,CAAA;IACpC,oEAAsC,CAAA;IACtC,oEAAsC,CAAA;IACtC,sEAAwC,CAAA;IACxC,kEAAoC,CAAA;AACtC,CAAC,EANW,0BAA0B,0CAA1B,0BAA0B,QAMrC;AAED,IAAY,gCAKX;AALD,WAAY,gCAAgC;IAC1C,+EAA2C,CAAA;IAC3C,iFAA6C,CAAA;IAC7C,iFAA6C,CAAA;IAC7C,mFAA+C,CAAA;AACjD,CAAC,EALW,gCAAgC,gDAAhC,gCAAgC,QAK3C;AAED,IAAY,uCAEX;AAFD,WAAY,uCAAuC;IACjD,kGAAuD,CAAA;AACzD,CAAC,EAFW,uCAAuC,uDAAvC,uCAAuC,QAElD;AAED,IAAY,qBAEX;AAFD,WAAY,qBAAqB;IAC/B,+DAAsC,CAAA;AACxC,CAAC,EAFW,qBAAqB,qCAArB,qBAAqB,QAEhC;AAED,IAAY,8BAGX;AAHD,WAAY,8BAA8B;IACxC,6EAA2C,CAAA;IAC3C,6EAA2C,CAAA;AAC7C,CAAC,EAHW,8BAA8B,8CAA9B,8BAA8B,QAGzC;AAED,IAAY,6BAGX;AAHD,WAAY,6BAA6B;IACvC,2EAA0C,CAAA;IAC1C,2EAA0C,CAAA;AAC5C,CAAC,EAHW,6BAA6B,6CAA7B,6BAA6B,QAGxC;AAED,IAAY,+BAEX;AAFD,WAAY,+BAA+B;IACzC,sEAAmC,CAAA;AACrC,CAAC,EAFW,+BAA+B,+CAA/B,+BAA+B,QAE1C"}
@@ -1,10 +1,12 @@
1
1
  export declare enum Hosts {
2
2
  VENDOR_PANEL = "VENDOR_PANEL_URL",
3
+ ADMIN_PANEL = "ADMIN_PANEL_URL",
3
4
  STOREFRONT = "STOREFRONT_URL",
4
5
  BACKEND = "BACKEND_URL"
5
6
  }
6
7
  export declare const defaultHosts: {
7
8
  VENDOR_PANEL_URL: string;
9
+ ADMIN_PANEL_URL: string;
8
10
  STOREFRONT_URL: string;
9
11
  BACKEND_URL: string;
10
12
  };
@@ -12,13 +14,14 @@ export declare const hostTypeToResetPasswordPath: {
12
14
  VENDOR_PANEL_URL: string;
13
15
  STOREFRONT_URL: string;
14
16
  BACKEND_URL: string;
17
+ ADMIN_PANEL_URL: string;
15
18
  };
16
19
  export declare const actorTypeToHost: {
17
- customer: Hosts;
18
- seller: Hosts;
19
- user: Hosts;
20
+ readonly customer: Hosts.STOREFRONT;
21
+ readonly seller: Hosts.VENDOR_PANEL;
22
+ readonly user: Hosts.BACKEND;
20
23
  };
21
- export declare const buildHostAddress: (hostType: Hosts, path?: string) => import("url").URL;
22
- export declare const buildResetPasswordUrl: (hostType: Hosts, token?: string) => import("url").URL;
23
- export declare const buildInviteUrl: (token: string) => import("url").URL;
24
+ export declare const buildHostAddress: (hostType: Hosts, path?: string) => import("node:url").URL;
25
+ export declare const buildResetPasswordUrl: (hostType: Hosts, token?: string) => import("node:url").URL;
26
+ export declare const buildInviteUrl: (token: string) => import("node:url").URL;
24
27
  //# sourceMappingURL=hosts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hosts.d.ts","sourceRoot":"","sources":["../../src/utils/hosts.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK;IACf,YAAY,qBAAqB;IACjC,UAAU,mBAAmB;IAC7B,OAAO,gBAAgB;CACxB;AAED,eAAO,MAAM,YAAY;;;;CAIxB,CAAA;AAED,eAAO,MAAM,2BAA2B;;;;CAIvC,CAAA;AAED,eAAO,MAAM,eAAe;;;;CAI3B,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,UAAU,KAAK,EAAE,OAAO,MAAM,sBAE9D,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,UAAU,KAAK,EAAE,QAAQ,MAAM,sBAQpE,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,sBAK3C,CAAA"}
1
+ {"version":3,"file":"hosts.d.ts","sourceRoot":"","sources":["../../src/utils/hosts.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK;IACf,YAAY,qBAAqB;IACjC,WAAW,oBAAoB;IAC/B,UAAU,mBAAmB;IAC7B,OAAO,gBAAgB;CACxB;AAED,eAAO,MAAM,YAAY;;;;;CAKxB,CAAA;AAED,eAAO,MAAM,2BAA2B;;;;;CAKvC,CAAA;AAQD,eAAO,MAAM,eAAe;;;;CAO1B,CAAA;AAEF,eAAO,MAAM,gBAAgB,GAAI,UAAU,KAAK,EAAE,OAAO,MAAM,2BAE9D,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,UAAU,KAAK,EAAE,QAAQ,MAAM,2BAQpE,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,2BAK3C,CAAA"}
@@ -4,24 +4,35 @@ exports.buildInviteUrl = exports.buildResetPasswordUrl = exports.buildHostAddres
4
4
  var Hosts;
5
5
  (function (Hosts) {
6
6
  Hosts["VENDOR_PANEL"] = "VENDOR_PANEL_URL";
7
+ Hosts["ADMIN_PANEL"] = "ADMIN_PANEL_URL";
7
8
  Hosts["STOREFRONT"] = "STOREFRONT_URL";
8
9
  Hosts["BACKEND"] = "BACKEND_URL";
9
10
  })(Hosts || (exports.Hosts = Hosts = {}));
10
11
  exports.defaultHosts = {
11
12
  [Hosts.VENDOR_PANEL]: 'http://localhost:5173',
13
+ [Hosts.ADMIN_PANEL]: 'http://localhost:8000',
12
14
  [Hosts.STOREFRONT]: 'http://localhost:3000',
13
15
  [Hosts.BACKEND]: 'http://localhost:9000'
14
16
  };
15
17
  exports.hostTypeToResetPasswordPath = {
16
18
  [Hosts.VENDOR_PANEL]: '/reset-password',
17
19
  [Hosts.STOREFRONT]: '/reset-password',
18
- [Hosts.BACKEND]: '/app/reset-password'
20
+ [Hosts.BACKEND]: '/app/reset-password',
21
+ [Hosts.ADMIN_PANEL]: '/reset-password'
19
22
  };
20
- exports.actorTypeToHost = {
23
+ const actorTypeToHostBase = {
21
24
  ['customer']: Hosts.STOREFRONT,
22
25
  ['seller']: Hosts.VENDOR_PANEL,
23
- ['user']: Hosts.BACKEND
26
+ ['user']: Hosts.BACKEND,
24
27
  };
28
+ exports.actorTypeToHost = new Proxy(actorTypeToHostBase, {
29
+ get(target, prop) {
30
+ if (prop === 'user' && process.env[Hosts.ADMIN_PANEL]) {
31
+ return Hosts.ADMIN_PANEL;
32
+ }
33
+ return target[prop];
34
+ },
35
+ });
25
36
  const buildHostAddress = (hostType, path) => {
26
37
  return new URL(path || '', process.env[hostType] || exports.defaultHosts[hostType]);
27
38
  };
@@ -1 +1 @@
1
- {"version":3,"file":"hosts.js","sourceRoot":"","sources":["../../src/utils/hosts.ts"],"names":[],"mappings":";;;AAAA,IAAY,KAIX;AAJD,WAAY,KAAK;IACf,0CAAiC,CAAA;IACjC,sCAA6B,CAAA;IAC7B,gCAAuB,CAAA;AACzB,CAAC,EAJW,KAAK,qBAAL,KAAK,QAIhB;AAEY,QAAA,YAAY,GAAG;IAC1B,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,uBAAuB;IAC7C,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,uBAAuB;IAC3C,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,uBAAuB;CACzC,CAAA;AAEY,QAAA,2BAA2B,GAAG;IACzC,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,iBAAiB;IACvC,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,iBAAiB;IACrC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,qBAAqB;CACvC,CAAA;AAEY,QAAA,eAAe,GAAG;IAC7B,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,UAAU;IAC9B,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY;IAC9B,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO;CACxB,CAAA;AAEM,MAAM,gBAAgB,GAAG,CAAC,QAAe,EAAE,IAAa,EAAE,EAAE;IACjE,OAAO,IAAI,GAAG,CAAC,IAAI,IAAI,E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EAAE,KAAK,CAAC,CAAA;IACtC,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AARY,QAAA,qBAAqB,yBAQjC;AAEM,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;IAC9C,MAAM,GAAG,GAAG,IAAA,wBAAgB,EAAC,KAAK,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;IAC3D,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAEpC,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AALY,QAAA,cAAc,kBAK1B"}
@@ -3,32 +3,41 @@ import { AuthenticatedMedusaRequest, MedusaResponse } from '@medusajs/framework'
3
3
  type CheckResourceOwnershipByResourceIdOptions<Body> = {
4
4
  entryPoint: string;
5
5
  filterField?: string;
6
- resourceId?: (req: AuthenticatedMedusaRequest<Body>) => string;
6
+ resourceId?: (req: AuthenticatedMedusaRequest<Body>) => string | string[];
7
7
  };
8
8
  /**
9
- * Middleware that verifies if the authenticated member owns/has access to the requested resource.
9
+ * Middleware that verifies if the authenticated member owns/has access to the requested resource(s).
10
10
  * This is done by checking if the member's seller ID matches the resource's seller ID.
11
+ * Supports both single resource ID and arrays of resource IDs.
11
12
  *
12
13
  * @param options - Configuration options for the ownership check
13
14
  * @param options.entryPoint - The entity type to verify ownership of (e.g. 'seller_product', 'service_zone')
14
15
  * @param options.filterField - Field used to filter/lookup the resource (defaults to 'id')
15
- * @param options.paramIdField - Request parameter containing the resource ID (defaults to 'id')
16
+ * @param options.resourceId - Function to extract resource ID(s) from the request (defaults to req.params.id)
16
17
  *
17
- * @throws {MedusaError} If the member does not own the resource
18
+ * @throws {MedusaError} If the member does not own any of the resources
18
19
  *
19
20
  * @example
20
- * // Basic usage - check ownership of vendor product
21
- * app.use(checkResourceOwnershipByParamId({
21
+ * // Basic usage - check ownership of single vendor product
22
+ * app.use(checkResourceOwnershipByResourceId({
22
23
  * entryPoint: 'seller_product'
23
24
  * }))
24
25
  *
25
26
  * @example
26
27
  * // Custom field usage - check ownership of service zone
27
- * app.use(checkResourceOwnershipByParamId({
28
+ * app.use(checkResourceOwnershipByResourceId({
28
29
  * entryPoint: 'service_zone',
29
30
  * filterField: 'service_zone_id',
30
31
  * resourceId: (req) => req.params.zone_id
31
32
  * }))
33
+ *
34
+ * @example
35
+ * // Batch usage - check ownership of multiple promotions
36
+ * app.use(checkResourceOwnershipByResourceId({
37
+ * entryPoint: 'seller_promotion',
38
+ * filterField: 'promotion_id',
39
+ * resourceId: (req) => [...(req.body.add || []), ...(req.body.remove || [])]
40
+ * }))
32
41
  */
33
42
  export declare const checkResourceOwnershipByResourceId: <Body>({ entryPoint, filterField, resourceId }: CheckResourceOwnershipByResourceIdOptions<Body>) => (req: AuthenticatedMedusaRequest<Body>, res: MedusaResponse, next: NextFunction) => Promise<void>;
34
43
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"check-ownership.d.ts","sourceRoot":"","sources":["../../../src/utils/middlewares/check-ownership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAMhF,KAAK,yCAAyC,CAAC,IAAI,IAAI;IACrD,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,0BAA0B,CAAC,IAAI,CAAC,KAAK,MAAM,CAAA;CAC/D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,kCAAkC,GAAI,IAAI,EAAE,yCAItD,yCAAyC,CAAC,IAAI,CAAC,MAE9C,KAAK,0BAA0B,CAAC,IAAI,CAAC,EACrC,KAAK,cAAc,EACnB,MAAM,YAAY,kBA+CrB,CAAA"}
1
+ {"version":3,"file":"check-ownership.d.ts","sourceRoot":"","sources":["../../../src/utils/middlewares/check-ownership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAE,0BAA0B,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAMhF,KAAK,yCAAyC,CAAC,IAAI,IAAI;IACrD,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,0BAA0B,CAAC,IAAI,CAAC,KAAK,MAAM,GAAG,MAAM,EAAE,CAAA;CAC1E,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,kCAAkC,GAAI,IAAI,EAAE,yCAItD,yCAAyC,CAAC,IAAI,CAAC,MAE9C,KAAK,0BAA0B,CAAC,IAAI,CAAC,EACrC,KAAK,cAAc,EACnB,MAAM,YAAY,kBA4CrB,CAAA"}
@@ -3,29 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkResourceOwnershipByResourceId = void 0;
4
4
  const utils_1 = require("@medusajs/framework/utils");
5
5
  /**
6
- * Middleware that verifies if the authenticated member owns/has access to the requested resource.
6
+ * Middleware that verifies if the authenticated member owns/has access to the requested resource(s).
7
7
  * This is done by checking if the member's seller ID matches the resource's seller ID.
8
+ * Supports both single resource ID and arrays of resource IDs.
8
9
  *
9
10
  * @param options - Configuration options for the ownership check
10
11
  * @param options.entryPoint - The entity type to verify ownership of (e.g. 'seller_product', 'service_zone')
11
12
  * @param options.filterField - Field used to filter/lookup the resource (defaults to 'id')
12
- * @param options.paramIdField - Request parameter containing the resource ID (defaults to 'id')
13
+ * @param options.resourceId - Function to extract resource ID(s) from the request (defaults to req.params.id)
13
14
  *
14
- * @throws {MedusaError} If the member does not own the resource
15
+ * @throws {MedusaError} If the member does not own any of the resources
15
16
  *
16
17
  * @example
17
- * // Basic usage - check ownership of vendor product
18
- * app.use(checkResourceOwnershipByParamId({
18
+ * // Basic usage - check ownership of single vendor product
19
+ * app.use(checkResourceOwnershipByResourceId({
19
20
  * entryPoint: 'seller_product'
20
21
  * }))
21
22
  *
22
23
  * @example
23
24
  * // Custom field usage - check ownership of service zone
24
- * app.use(checkResourceOwnershipByParamId({
25
+ * app.use(checkResourceOwnershipByResourceId({
25
26
  * entryPoint: 'service_zone',
26
27
  * filterField: 'service_zone_id',
27
28
  * resourceId: (req) => req.params.zone_id
28
29
  * }))
30
+ *
31
+ * @example
32
+ * // Batch usage - check ownership of multiple promotions
33
+ * app.use(checkResourceOwnershipByResourceId({
34
+ * entryPoint: 'seller_promotion',
35
+ * filterField: 'promotion_id',
36
+ * resourceId: (req) => [...(req.body.add || []), ...(req.body.remove || [])]
37
+ * }))
29
38
  */
30
39
  const checkResourceOwnershipByResourceId = ({ entryPoint, filterField = 'id', resourceId = (req) => req.params.id }) => {
31
40
  return async (req, res, next) => {
@@ -37,22 +46,21 @@ const checkResourceOwnershipByResourceId = ({ entryPoint, filterField = 'id', re
37
46
  id: req.auth_context.actor_id
38
47
  }
39
48
  }, { throwIfKeyNotFound: true });
40
- const id = resourceId(req);
41
- const { data: [resource] } = await query.graph({
49
+ const ids = resourceId(req);
50
+ const idArray = Array.isArray(ids) ? ids : [ids];
51
+ if (idArray.length === 0) {
52
+ next();
53
+ return;
54
+ }
55
+ const { data: resources } = await query.graph({
42
56
  entity: entryPoint,
43
57
  fields: ['seller_id'],
44
58
  filters: {
45
- [filterField]: id
59
+ [filterField]: idArray,
60
+ seller_id: member.seller.id
46
61
  }
47
62
  });
48
- if (!resource) {
49
- res.status(404).json({
50
- message: `${entryPoint} with ${filterField}: ${id} not found`,
51
- type: utils_1.MedusaError.Types.NOT_FOUND
52
- });
53
- return;
54
- }
55
- if (member.seller.id !== resource.seller_id) {
63
+ if (resources.length !== idArray.length) {
56
64
  res.status(403).json({
57
65
  message: 'You are not allowed to perform this action',
58
66
  type: utils_1.MedusaError.Types.NOT_ALLOWED
@@ -1 +1 @@
1
- {"version":3,"file":"check-ownership.js","sourceRoot":"","sources":["../../../src/utils/middlewares/check-ownership.ts"],"names":[],"mappings":";;;AAGA,qDAGkC;AAQlC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,MAAM,kCAAkC,GAAG,CAAO,EACvD,UAAU,EACV,WAAW,GAAG,IAAI,EAClB,UAAU,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EACa,EAAE,EAAE;IACpD,OAAO,KAAK,EACV,GAAqC,EACrC,GAAmB,EACnB,IAAkB,EAClB,EAAE;QACF,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,iCAAyB,CAAC,KAAK,CAAC,CAAA;QAEhE,MAAM,EACJ,IAAI,EAAE,CAAC,MAAM,CAAC,EACf,GAAG,MAAM,KAAK,CAAC,KAAK,CACnB;YACE,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,CAAC,WAAW,CAAC;YACrB,OAAO,EAAE;gBACP,EAAE,EAAE,GAAG,CAAC,YAAY,CAAC,QAAQ;aAC9B;SACF,EACD,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAC7B,CAAA;QAED,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;QAE1B,MAAM,EACJ,IAAI,EAAE,CAAC,QAAQ,CAAC,EACjB,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC;YACpB,MAAM,EAAE,UAAU;YAClB,MAAM,EAAE,CAAC,WAAW,CAAC;YACrB,OAAO,EAAE;gBACP,CAAC,WAAW,CAAC,EAAE,EAAE;aAClB;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,OAAO,EAAE,GAAG,UAAU,SAAS,WAAW,KAAK,EAAE,YAAY;gBAC7D,IAAI,EAAE,mBAAW,CAAC,KAAK,CAAC,SAAS;aAClC,CAAC,CAAA;YACF,OAAM;QACR,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,QAAQ,CAAC,SAAS,EAAE,CAAC;YAC5C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,OAAO,EAAE,4CAA4C;gBACrD,IAAI,EAAE,mBAAW,CAAC,KAAK,CAAC,WAAW;aACpC,CAAC,CAAA;YACF,OAAM;QACR,CAAC;QAED,IAAI,EAAE,CAAA;IACR,CAAC,CAAA;AACH,CAAC,CAAA;AAvDY,QAAA,kCAAkC,sCAuD9C"}
1
+ {"version":3,"file":"check-ownership.js","sourceRoot":"","sources":["../../../src/utils/middlewares/check-ownership.ts"],"names":[],"mappings":";;;AAGA,qDAGkC;AAQlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACI,MAAM,kCAAkC,GAAG,CAAO,EACvD,UAAU,EACV,WAAW,GAAG,IAAI,EAClB,UAAU,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EACa,EAAE,EAAE;IACpD,OAAO,KAAK,EACV,GAAqC,EACrC,GAAmB,EACnB,IAAkB,EAClB,EAAE;QACF,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,iCAAyB,CAAC,KAAK,CAAC,CAAA;QAEhE,MAAM,EACJ,IAAI,EAAE,CAAC,MAAM,CAAC,EACf,GAAG,MAAM,KAAK,CAAC,KAAK,CACnB;YACE,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,CAAC,WAAW,CAAC;YACrB,OAAO,EAAE;gBACP,EAAE,EAAE,GAAG,CAAC,YAAY,CAAC,QAAQ;aAC9B;SACF,EACD,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAC7B,CAAA;QAED,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;QAC3B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QAEhD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,EAAE,CAAA;YACN,OAAM;QACR,CAAC;QAED,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC;YAC5C,MAAM,EAAE,UAAU;YAClB,MAAM,EAAE,CAAC,WAAW,CAAC;YACrB,OAAO,EAAE;gBACP,CAAC,WAAW,CAAC,EAAE,OAAO;gBACtB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE;aAC5B;SACF,CAAC,CAAA;QAEF,IAAI,SAAS,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;YACxC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,OAAO,EAAE,4CAA4C;gBACrD,IAAI,EAAE,mBAAW,CAAC,KAAK,CAAC,WAAW;aACpC,CAAC,CAAA;YACF,OAAM;QACR,CAAC;QAED,IAAI,EAAE,CAAA;IACR,CAAC,CAAA;AACH,CAAC,CAAA;AApDY,QAAA,kCAAkC,sCAoD9C"}
@@ -1,4 +1,4 @@
1
- import { ProductStatus } from "@medusajs/framework/utils";
1
+ import { ProductStatus } from '@medusajs/framework/utils';
2
2
  export declare const updateProductStatusStep: import("@medusajs/workflows-sdk").StepFunction<{
3
3
  id: string;
4
4
  status: ProductStatus;
@@ -1 +1 @@
1
- {"version":3,"file":"update-product-status.d.ts","sourceRoot":"","sources":["../../src/workflows/update-product-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAQnE,eAAO,MAAM,uBAAuB;QAEd,MAAM;YAAU,aAAa;wCAYlD,CAAC;AAEF,eAAO,MAAM,2BAA2B;QAEf,MAAM;YAAU,aAAa;4CAGrD,CAAC"}
1
+ {"version":3,"file":"update-product-status.d.ts","sourceRoot":"","sources":["../../src/workflows/update-product-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAUlE,eAAO,MAAM,uBAAuB;QAEd,MAAM;YAAU,aAAa;wCAkBlD,CAAA;AAED,eAAO,MAAM,2BAA2B;QAEf,MAAM;YAAU,aAAa;4CAGrD,CAAA"}
@@ -3,16 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateProductStatusWorkflow = exports.updateProductStatusStep = void 0;
4
4
  const utils_1 = require("@medusajs/framework/utils");
5
5
  const workflows_sdk_1 = require("@medusajs/workflows-sdk");
6
- exports.updateProductStatusStep = (0, workflows_sdk_1.createStep)("update-product-status", async (input, { container }) => {
6
+ const events_1 = require("../types/algolia/events");
7
+ exports.updateProductStatusStep = (0, workflows_sdk_1.createStep)('update-product-status', async (input, { container }) => {
7
8
  const service = container.resolve(utils_1.Modules.PRODUCT);
8
- const knex = container.resolve("__pg_connection__");
9
- await knex("product").where("id", input.id).update({
10
- status: input.status,
9
+ const knex = container.resolve('__pg_connection__');
10
+ const eventBus = container.resolve(utils_1.Modules.EVENT_BUS);
11
+ await knex('product').where('id', input.id).update({
12
+ status: input.status
11
13
  });
12
14
  const product = await service.retrieveProduct(input.id);
15
+ await eventBus.emit({
16
+ name: events_1.AlgoliaEvents.PRODUCTS_CHANGED,
17
+ data: { ids: [input.id] }
18
+ });
13
19
  return new workflows_sdk_1.StepResponse(product, product.id);
14
20
  });
15
- exports.updateProductStatusWorkflow = (0, workflows_sdk_1.createWorkflow)("update-product-status", function (input) {
21
+ exports.updateProductStatusWorkflow = (0, workflows_sdk_1.createWorkflow)('update-product-status', function (input) {
16
22
  return new workflows_sdk_1.WorkflowResponse((0, exports.updateProductStatusStep)(input));
17
23
  });
18
24
  //# sourceMappingURL=update-product-status.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-product-status.js","sourceRoot":"","sources":["../../src/workflows/update-product-status.ts"],"names":[],"mappings":";;;AAAA,qDAAmE;AACnE,2DAKiC;AAEpB,QAAA,uBAAuB,GAAG,IAAA,0BAAU,EAC/C,uBAAuB,EACvB,KAAK,EAAE,KAA4C,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IACpE,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,eAAO,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEpD,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC;QACjD,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAExD,OAAO,IAAI,4BAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC,CACF,CAAC;AAEW,QAAA,2BAA2B,GAAG,IAAA,8BAAc,EACvD,uBAAuB,EACvB,UAAU,KAA4C;IACpD,OAAO,IAAI,gCAAgB,CAAC,IAAA,+BAAuB,EAAC,KAAK,CAAC,CAAC,CAAC;AAC9D,CAAC,CACF,CAAC"}
1
+ {"version":3,"file":"update-product-status.js","sourceRoot":"","sources":["../../src/workflows/update-product-status.ts"],"names":[],"mappings":";;;AAAA,qDAAkE;AAClE,2DAKgC;AAEhC,oDAAuD;AAE1C,QAAA,uBAAuB,GAAG,IAAA,0BAAU,EAC/C,uBAAuB,EACvB,KAAK,EAAE,KAA4C,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IACpE,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,eAAO,CAAC,OAAO,CAAC,CAAA;IAClD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACnD,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,eAAO,CAAC,SAAS,CAAC,CAAA;IAErD,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC;QACjD,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAEvD,MAAM,QAAQ,CAAC,IAAI,CAAC;QAClB,IAAI,EAAE,sBAAa,CAAC,gBAAgB;QACpC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;KAC1B,CAAC,CAAA;IAEF,OAAO,IAAI,4BAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;AAC9C,CAAC,CACF,CAAA;AAEY,QAAA,2BAA2B,GAAG,IAAA,8BAAc,EACvD,uBAAuB,EACvB,UAAU,KAA4C;IACpD,OAAO,IAAI,gCAAgB,CAAC,IAAA,+BAAuB,EAAC,KAAK,CAAC,CAAC,CAAA;AAC7D,CAAC,CACF,CAAA"}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "medusajs",
12
12
  "mercurjs"
13
13
  ],
14
- "version": "1.5.1",
14
+ "version": "1.5.3",
15
15
  "main": "dist/index.js",
16
16
  "types": "dist/index.d.ts",
17
17
  "files": [