@shopware-ag/app-server-sdk 1.1.9 → 1.1.11

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 (55) hide show
  1. package/dist/commonjs/app.d.ts +3 -1
  2. package/dist/commonjs/app.d.ts.map +1 -1
  3. package/dist/commonjs/app.js +3 -0
  4. package/dist/commonjs/app.js.map +1 -1
  5. package/dist/commonjs/context-resolver.d.ts +1 -1
  6. package/dist/commonjs/context-resolver.d.ts.map +1 -1
  7. package/dist/commonjs/context-resolver.js.map +1 -1
  8. package/dist/commonjs/helper/criteria.d.ts.map +1 -1
  9. package/dist/commonjs/helper/criteria.js.map +1 -1
  10. package/dist/commonjs/hooks.d.ts +13 -0
  11. package/dist/commonjs/hooks.d.ts.map +1 -0
  12. package/dist/commonjs/hooks.js +29 -0
  13. package/dist/commonjs/hooks.js.map +1 -0
  14. package/dist/commonjs/http-client.d.ts.map +1 -1
  15. package/dist/commonjs/http-client.js +26 -0
  16. package/dist/commonjs/http-client.js.map +1 -1
  17. package/dist/commonjs/integration/hono.d.ts +4 -0
  18. package/dist/commonjs/integration/hono.d.ts.map +1 -1
  19. package/dist/commonjs/integration/hono.js +3 -0
  20. package/dist/commonjs/integration/hono.js.map +1 -1
  21. package/dist/commonjs/registration.d.ts +11 -2
  22. package/dist/commonjs/registration.d.ts.map +1 -1
  23. package/dist/commonjs/registration.js +23 -1
  24. package/dist/commonjs/registration.js.map +1 -1
  25. package/dist/commonjs/repository.d.ts +1 -1
  26. package/dist/commonjs/repository.d.ts.map +1 -1
  27. package/dist/commonjs/repository.js.map +1 -1
  28. package/dist/esm/app.d.ts +3 -1
  29. package/dist/esm/app.d.ts.map +1 -1
  30. package/dist/esm/app.js +3 -0
  31. package/dist/esm/app.js.map +1 -1
  32. package/dist/esm/context-resolver.d.ts +1 -1
  33. package/dist/esm/context-resolver.d.ts.map +1 -1
  34. package/dist/esm/context-resolver.js.map +1 -1
  35. package/dist/esm/helper/criteria.d.ts.map +1 -1
  36. package/dist/esm/helper/criteria.js.map +1 -1
  37. package/dist/esm/hooks.d.ts +13 -0
  38. package/dist/esm/hooks.d.ts.map +1 -0
  39. package/dist/esm/hooks.js +25 -0
  40. package/dist/esm/hooks.js.map +1 -0
  41. package/dist/esm/http-client.d.ts.map +1 -1
  42. package/dist/esm/http-client.js +26 -0
  43. package/dist/esm/http-client.js.map +1 -1
  44. package/dist/esm/integration/hono.d.ts +4 -0
  45. package/dist/esm/integration/hono.d.ts.map +1 -1
  46. package/dist/esm/integration/hono.js +3 -0
  47. package/dist/esm/integration/hono.js.map +1 -1
  48. package/dist/esm/registration.d.ts +11 -2
  49. package/dist/esm/registration.d.ts.map +1 -1
  50. package/dist/esm/registration.js +21 -0
  51. package/dist/esm/registration.js.map +1 -1
  52. package/dist/esm/repository.d.ts +1 -1
  53. package/dist/esm/repository.d.ts.map +1 -1
  54. package/dist/esm/repository.js.map +1 -1
  55. package/package.json +1 -1
@@ -1,7 +1,8 @@
1
1
  import type { AppServer } from "./app.js";
2
- export declare class Registration {
2
+ import type { ShopInterface } from "./repository.js";
3
+ export declare class Registration<Shop extends ShopInterface = ShopInterface> {
3
4
  private app;
4
- constructor(app: AppServer);
5
+ constructor(app: AppServer<Shop>);
5
6
  /**
6
7
  * This method checks the request for the handshake with the Shopware Shop.
7
8
  * if it's valid a Shop will be created, and a proof will be responded with a confirmation url.
@@ -39,4 +40,12 @@ export declare class Registration {
39
40
  delete(req: Request): Promise<Response>;
40
41
  }
41
42
  export declare function randomString(length?: number): string;
43
+ export declare class ShopAuthroizeEvent<Shop extends ShopInterface = ShopInterface> {
44
+ request: Request;
45
+ shop: Shop;
46
+ private reject;
47
+ constructor(request: Request, shop: Shop);
48
+ rejectRegistration(reason: string): void;
49
+ get reason(): string | null;
50
+ }
42
51
  //# sourceMappingURL=registration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../src/registration.ts"],"names":[],"mappings":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AC,QAAQ,CAAC;IAUxD;;;;;;OAMG;IACU,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAOpD;AAED,wBAAgB,YAAY,CAAC,MAAM,SAAM,UAUxC;AAaD,qBAAa,kBAAkB,CAAC,IAAI,SAAS,aAAa,GAAG,aAAa;IAIjE,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,IAAI;IAJlB,OAAO,CAAC,MAAM,CAAuB;gBAG7B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI;IAGX,kBAAkB,CAAC,MAAM,EAAE,MAAM;IAIxC,IAAW,MAAM,kBAEhB;CACD"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Registration = void 0;
3
+ exports.ShopAuthroizeEvent = exports.Registration = void 0;
4
4
  exports.randomString = randomString;
5
5
  class Registration {
6
6
  app;
@@ -63,6 +63,12 @@ class Registration {
63
63
  return new InvalidRequestResponse("Cannot validate app signature");
64
64
  }
65
65
  shop.setShopCredentials(body.apiKey, body.secretKey);
66
+ const event = new ShopAuthroizeEvent(req, shop);
67
+ await this.app.hooks.publish("onAuthorize", event);
68
+ if (event.reason) {
69
+ await this.app.repository.deleteShop(shop.getShopId());
70
+ return new InvalidRequestResponse(event.reason, 403);
71
+ }
66
72
  await this.app.repository.updateShop(shop);
67
73
  return new Response(null, { status: 204 });
68
74
  }
@@ -125,4 +131,20 @@ class InvalidRequestResponse extends Response {
125
131
  });
126
132
  }
127
133
  }
134
+ class ShopAuthroizeEvent {
135
+ request;
136
+ shop;
137
+ reject = null;
138
+ constructor(request, shop) {
139
+ this.request = request;
140
+ this.shop = shop;
141
+ }
142
+ rejectRegistration(reason) {
143
+ this.reject = reason;
144
+ }
145
+ get reason() {
146
+ return this.reject;
147
+ }
148
+ }
149
+ exports.ShopAuthroizeEvent = ShopAuthroizeEvent;
128
150
  //# sourceMappingURL=registration.js.map
@@ -1 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B;aAClC;SACD,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import type { AppServer } from \"./app.js\";\n\nexport class Registration {\n\tconstructor(private app: AppServer) {}\n\n\t/**\n\t * This method checks the request for the handshake with the Shopware Shop.\n\t * if it's valid a Shop will be created, and a proof will be responded with a confirmation url.\n\t * then the Shop will call the confirmation url, and this should be handled by the authorizeCallback method to finish the handshake.\n\t */\n\tpublic async authorize(req: Request): Promise<Response> {\n\t\tconst url = new URL(req.url);\n\n\t\tif (\n\t\t\t!url.searchParams.has(\"shop-url\") ||\n\t\t\t!req.headers.has(\"shopware-app-signature\") ||\n\t\t\t!url.searchParams.has(\"shop-id\") ||\n\t\t\t!url.searchParams.has(\"timestamp\")\n\t\t) {\n\t\t\treturn new InvalidRequestResponse(\"Invalid Request\", 400);\n\t\t}\n\n\t\tconst shopId = url.searchParams.get(\"shop-id\") as string;\n\t\tconst shopUrl = url.searchParams.get(\"shop-url\") as string;\n\t\tconst timestamp = url.searchParams.get(\"timestamp\") as string;\n\n\t\tconst v = await this.app.signer.verify(\n\t\t\treq.headers.get(\"shopware-app-signature\") as string,\n\t\t\t`shop-id=${shopId}&shop-url=${shopUrl}&timestamp=${timestamp}`,\n\t\t\tthis.app.cfg.appSecret,\n\t\t);\n\n\t\tif (!v) {\n\t\t\treturn new InvalidRequestResponse(\"Cannot validate app signature\");\n\t\t}\n\n\t\tconst shopSecret = randomString();\n\n\t\tawait this.app.repository.createShop(shopId, shopUrl, shopSecret);\n\n\t\treturn new Response(\n\t\t\tJSON.stringify({\n\t\t\t\tproof: await this.app.signer.sign(\n\t\t\t\t\tshopId + shopUrl + this.app.cfg.appName,\n\t\t\t\t\tthis.app.cfg.appSecret,\n\t\t\t\t),\n\t\t\t\tsecret: shopSecret,\n\t\t\t\tconfirmation_url: this.app.cfg.authorizeCallbackUrl,\n\t\t\t}),\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * This method is called by the Shopware Shop to confirm the handshake.\n\t * It will update the shop with the given oauth2 credentials.\n\t */\n\tpublic async authorizeCallback(req: Request): Promise<Response> {\n\t\tconst bodyContent = await req.text();\n\n\t\tconst body = JSON.parse(bodyContent);\n\n\t\tif (\n\t\t\ttypeof body.shopId !== \"string\" ||\n\t\t\ttypeof body.apiKey !== \"string\" ||\n\t\t\ttypeof body.secretKey !== \"string\" ||\n\t\t\t!req.headers.has(\"shopware-shop-signature\")\n\t\t) {\n\t\t\treturn new InvalidRequestResponse(\"Invalid Request\", 400);\n\t\t}\n\n\t\tconst shop = await this.app.repository.getShopById(body.shopId as string);\n\n\t\tif (shop === null) {\n\t\t\treturn new InvalidRequestResponse(\"Invalid shop given\");\n\t\t}\n\n\t\tconst v = await this.app.signer.verify(\n\t\t\treq.headers.get(\"shopware-shop-signature\") as string,\n\t\t\tbodyContent,\n\t\t\tshop.getShopSecret(),\n\t\t);\n\t\tif (!v) {\n\t\t\t// Shop has failed the verify. Delete it from our DB\n\t\t\tawait this.app.repository.deleteShop(shop.getShopId());\n\n\t\t\treturn new InvalidRequestResponse(\"Cannot validate app signature\");\n\t\t}\n\n\t\tshop.setShopCredentials(body.apiKey, body.secretKey);\n\n\t\tawait this.app.repository.updateShop(shop);\n\n\t\treturn new Response(null, { status: 204 });\n\t}\n\n\t/**\n\t * This method should be called by Shopware Shop to set the shop active.\n\t *\n\t * <webhooks>\n\t * <webhook name=\"appActivate\" url=\"http://localhost:3000/app/delete\" event=\"app.activated\"/>\n\t * </webhooks>\n\t */\n\tpublic async activate(req: Request): Promise<Response> {\n\t\tconst ctx = await this.app.contextResolver.fromAPI(req);\n\n\t\tctx.shop.setShopActive(true);\n\n\t\tawait this.app.repository.updateShop(ctx.shop);\n\n\t\treturn new Response(null, { status: 204 });\n\t}\n\n\t/**\n\t * This method should be called by Shopware Shop to set the shop in-active.\n\t *\n\t * <webhooks>\n\t * <webhook name=\"appDeactivated\" url=\"http://localhost:3000/app/deactivated\" event=\"app.deactivated\"/>\n\t * </webhooks>\n\t */\n\tpublic async deactivate(req: Request): Promise<Response> {\n\t\tconst ctx = await this.app.contextResolver.fromAPI(req);\n\n\t\tctx.shop.setShopActive(false);\n\n\t\tawait this.app.repository.updateShop(ctx.shop);\n\n\t\treturn new Response(null, { status: 204 });\n\t}\n\n\t/**\n\t * This method should be called by Shopware Shop to delete the app.\n\t *\n\t * <webhooks>\n\t * <webhook name=\"appDelete\" url=\"http://localhost:3000/app/delete\" event=\"app.deleted\"/>\n\t * </webhooks>\n\t */\n\tpublic async delete(req: Request): Promise<Response> {\n\t\tconst ctx = await this.app.contextResolver.fromAPI(req);\n\n\t\tawait this.app.repository.deleteShop(ctx.shop.getShopId());\n\n\t\treturn new Response(null, { status: 204 });\n\t}\n}\n\nexport function randomString(length = 120) {\n\tlet result = \"\";\n\tconst characters =\n\t\t\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\tconst charactersLength = characters.length;\n\tfor (let i = 0; i < length; i++) {\n\t\tresult += characters.charAt(Math.floor(Math.random() * charactersLength));\n\t}\n\n\treturn result;\n}\n\nclass InvalidRequestResponse extends Response {\n\tconstructor(message: string, status = 401) {\n\t\tsuper(JSON.stringify({ message }), {\n\t\t\tstatus,\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t},\n\t\t});\n\t}\n}\n"]}
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../src/registration.ts"],"names":[],"mappings":";;;AAiKA,oCAUC;AAxKD,MAAa,YAAY;IACJ;IAApB,YAAoB,GAAoB;QAApB,QAAG,GAAH,GAAG,CAAiB;IAAG,CAAC;IAE5C;;;;OAIG;IACI,KAAK,CAAC,SAAS,CAAC,GAAY;QAClC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE7B,IACC,CAAC,GAAG,CAAC,YAAY,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AAE;YAClC,MAAM;YACN,OAAO,EAAE;gBACR,cAAc,EAAE,kBAAkB;aAClC;SACD,CAAC,CAAC;IACJ,CAAC;CACD;AAED,MAAa,kBAAkB;IAItB;IACA;IAJA,MAAM,GAAkB,IAAI,CAAC;IAErC,YACQ,OAAgB,EAChB,IAAU;QADV,YAAO,GAAP,OAAO,CAAS;QAChB,SAAI,GAAJ,IAAI,CAAM;IACf,CAAC;IAEG,kBAAkB,CAAC,MAAc;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;CACD;AAfD,gDAeC","sourcesContent":["import type { AppServer } from \"./app.js\";\nimport type { ShopInterface } from \"./repository.js\";\n\nexport class Registration<Shop extends ShopInterface = ShopInterface> {\n\tconstructor(private app: AppServer<Shop>) {}\n\n\t/**\n\t * This method checks the request for the handshake with the Shopware Shop.\n\t * if it's valid a Shop will be created, and a proof will be responded with a confirmation url.\n\t * then the Shop will call the confirmation url, and this should be handled by the authorizeCallback method to finish the handshake.\n\t */\n\tpublic async authorize(req: Request): Promise<Response> {\n\t\tconst url = new URL(req.url);\n\n\t\tif (\n\t\t\t!url.searchParams.has(\"shop-url\") ||\n\t\t\t!req.headers.has(\"shopware-app-signature\") ||\n\t\t\t!url.searchParams.has(\"shop-id\") ||\n\t\t\t!url.searchParams.has(\"timestamp\")\n\t\t) {\n\t\t\treturn new InvalidRequestResponse(\"Invalid Request\", 400);\n\t\t}\n\n\t\tconst shopId = url.searchParams.get(\"shop-id\") as string;\n\t\tconst shopUrl = url.searchParams.get(\"shop-url\") as string;\n\t\tconst timestamp = url.searchParams.get(\"timestamp\") as string;\n\n\t\tconst v = await this.app.signer.verify(\n\t\t\treq.headers.get(\"shopware-app-signature\") as string,\n\t\t\t`shop-id=${shopId}&shop-url=${shopUrl}&timestamp=${timestamp}`,\n\t\t\tthis.app.cfg.appSecret,\n\t\t);\n\n\t\tif (!v) {\n\t\t\treturn new InvalidRequestResponse(\"Cannot validate app signature\");\n\t\t}\n\n\t\tconst shopSecret = randomString();\n\n\t\tawait this.app.repository.createShop(shopId, shopUrl, shopSecret);\n\n\t\treturn new Response(\n\t\t\tJSON.stringify({\n\t\t\t\tproof: await this.app.signer.sign(\n\t\t\t\t\tshopId + shopUrl + this.app.cfg.appName,\n\t\t\t\t\tthis.app.cfg.appSecret,\n\t\t\t\t),\n\t\t\t\tsecret: shopSecret,\n\t\t\t\tconfirmation_url: this.app.cfg.authorizeCallbackUrl,\n\t\t\t}),\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * This method is called by the Shopware Shop to confirm the handshake.\n\t * It will update the shop with the given oauth2 credentials.\n\t */\n\tpublic async authorizeCallback(req: Request): Promise<Response> {\n\t\tconst bodyContent = await req.text();\n\n\t\tconst body = JSON.parse(bodyContent);\n\n\t\tif (\n\t\t\ttypeof body.shopId !== \"string\" ||\n\t\t\ttypeof body.apiKey !== \"string\" ||\n\t\t\ttypeof body.secretKey !== \"string\" ||\n\t\t\t!req.headers.has(\"shopware-shop-signature\")\n\t\t) {\n\t\t\treturn new InvalidRequestResponse(\"Invalid Request\", 400);\n\t\t}\n\n\t\tconst shop = await this.app.repository.getShopById(body.shopId as string);\n\n\t\tif (shop === null) {\n\t\t\treturn new InvalidRequestResponse(\"Invalid shop given\");\n\t\t}\n\n\t\tconst v = await this.app.signer.verify(\n\t\t\treq.headers.get(\"shopware-shop-signature\") as string,\n\t\t\tbodyContent,\n\t\t\tshop.getShopSecret(),\n\t\t);\n\n\t\tif (!v) {\n\t\t\t// Shop has failed the verify. Delete it from our DB\n\t\t\tawait this.app.repository.deleteShop(shop.getShopId());\n\n\t\t\treturn new InvalidRequestResponse(\"Cannot validate app signature\");\n\t\t}\n\n\t\tshop.setShopCredentials(body.apiKey, body.secretKey);\n\n\t\tconst event = new ShopAuthroizeEvent(req, shop);\n\t\tawait this.app.hooks.publish(\"onAuthorize\", event);\n\n\t\tif (event.reason) {\n\t\t\tawait this.app.repository.deleteShop(shop.getShopId());\n\n\t\t\treturn new InvalidRequestResponse(event.reason, 403);\n\t\t}\n\n\t\tawait this.app.repository.updateShop(shop);\n\n\t\treturn new Response(null, { status: 204 });\n\t}\n\n\t/**\n\t * This method should be called by Shopware Shop to set the shop active.\n\t *\n\t * <webhooks>\n\t * <webhook name=\"appActivate\" url=\"http://localhost:3000/app/delete\" event=\"app.activated\"/>\n\t * </webhooks>\n\t */\n\tpublic async activate(req: Request): Promise<Response> {\n\t\tconst ctx = await this.app.contextResolver.fromAPI(req);\n\n\t\tctx.shop.setShopActive(true);\n\n\t\tawait this.app.repository.updateShop(ctx.shop);\n\n\t\treturn new Response(null, { status: 204 });\n\t}\n\n\t/**\n\t * This method should be called by Shopware Shop to set the shop in-active.\n\t *\n\t * <webhooks>\n\t * <webhook name=\"appDeactivated\" url=\"http://localhost:3000/app/deactivated\" event=\"app.deactivated\"/>\n\t * </webhooks>\n\t */\n\tpublic async deactivate(req: Request): Promise<Response> {\n\t\tconst ctx = await this.app.contextResolver.fromAPI(req);\n\n\t\tctx.shop.setShopActive(false);\n\n\t\tawait this.app.repository.updateShop(ctx.shop);\n\n\t\treturn new Response(null, { status: 204 });\n\t}\n\n\t/**\n\t * This method should be called by Shopware Shop to delete the app.\n\t *\n\t * <webhooks>\n\t * <webhook name=\"appDelete\" url=\"http://localhost:3000/app/delete\" event=\"app.deleted\"/>\n\t * </webhooks>\n\t */\n\tpublic async delete(req: Request): Promise<Response> {\n\t\tconst ctx = await this.app.contextResolver.fromAPI(req);\n\n\t\tawait this.app.repository.deleteShop(ctx.shop.getShopId());\n\n\t\treturn new Response(null, { status: 204 });\n\t}\n}\n\nexport function randomString(length = 120) {\n\tlet result = \"\";\n\tconst characters =\n\t\t\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\tconst charactersLength = characters.length;\n\tfor (let i = 0; i < length; i++) {\n\t\tresult += characters.charAt(Math.floor(Math.random() * charactersLength));\n\t}\n\n\treturn result;\n}\n\nclass InvalidRequestResponse extends Response {\n\tconstructor(message: string, status = 401) {\n\t\tsuper(JSON.stringify({ message }), {\n\t\t\tstatus,\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t},\n\t\t});\n\t}\n}\n\nexport class ShopAuthroizeEvent<Shop extends ShopInterface = ShopInterface> {\n\tprivate reject: string | null = null;\n\n\tconstructor(\n\t\tpublic request: Request,\n\t\tpublic shop: Shop,\n\t) {}\n\n\tpublic rejectRegistration(reason: string) {\n\t\tthis.reject = reason;\n\t}\n\n\tpublic get reason() {\n\t\treturn this.reject;\n\t}\n}\n"]}
@@ -15,7 +15,7 @@ export interface ShopInterface {
15
15
  * ShopRepositoryInterface is the storage interface for the shops, you should implement this to save the shop data to your database
16
16
  * For testing cases the InMemoryShopRepository can be used
17
17
  */
18
- export interface ShopRepositoryInterface<Shop = ShopInterface> {
18
+ export interface ShopRepositoryInterface<Shop extends ShopInterface = ShopInterface> {
19
19
  createShop(id: string, url: string, secret: string): Promise<void>;
20
20
  getShopById(id: string): Promise<Shop | null>;
21
21
  updateShop(shop: Shop): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../src/repository.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,SAAS,IAAI,MAAM,CAAC;IACpB,UAAU,IAAI,MAAM,CAAC;IACrB,aAAa,IAAI,MAAM,CAAC;IACxB,eAAe,IAAI,MAAM,GAAG,IAAI,CAAC;IACjC,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAAC;IACrC,aAAa,IAAI,OAAO,CAAC;IACzB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACjE,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;IACb,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAgB;QAChC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QAC1B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;CACD;AA9BD,wDA8BC","sourcesContent":["/**\n * ShopInterface defines the object that given back from the ShopRepository, it should methods to get the shop data and set them\n */\nexport interface ShopInterface {\n\tgetShopId(): string;\n\tgetShopUrl(): string;\n\tgetShopSecret(): string;\n\tgetShopClientId(): string | null;\n\tgetShopClientSecret(): string | null;\n\tgetShopActive(): boolean;\n\tsetShopCredentials(clientId: string, clientSecret: string): void;\n\tsetShopActive(active: boolean): void;\n}\n\n/**\n * ShopRepositoryInterface is the storage interface for the shops, you should implement this to save the shop data to your database\n * For testing cases the InMemoryShopRepository can be used\n */\nexport interface ShopRepositoryInterface<Shop = ShopInterface> {\n\tcreateShop(id: string, url: string, secret: string): Promise<void>;\n\n\tgetShopById(id: string): Promise<Shop | null>;\n\n\tupdateShop(shop: Shop): Promise<void>;\n\n\tdeleteShop(id: string): Promise<void>;\n}\n\n/**\n * SimpleShop is a simple implementation of the ShopInterface, it stores the shop data in memory\n */\nexport class SimpleShop implements ShopInterface {\n\tprivate shopId: string;\n\tprivate shopUrl: string;\n\tprivate shopSecret: string;\n\tprivate shopClientId: string | null;\n\tprivate shopClientSecret: string | null;\n\tprivate shopActive = false;\n\n\tconstructor(shopId: string, shopUrl: string, shopSecret: string) {\n\t\tthis.shopId = shopId;\n\t\tthis.shopUrl = shopUrl;\n\t\tthis.shopSecret = shopSecret;\n\t\tthis.shopClientId = null;\n\t\tthis.shopClientSecret = null;\n\t}\n\n\tgetShopActive(): boolean {\n\t\treturn this.shopActive;\n\t}\n\tsetShopActive(active: boolean): void {\n\t\tthis.shopActive = active;\n\t}\n\n\tgetShopId(): string {\n\t\treturn this.shopId;\n\t}\n\tgetShopUrl(): string {\n\t\treturn this.shopUrl;\n\t}\n\tgetShopSecret(): string {\n\t\treturn this.shopSecret;\n\t}\n\tgetShopClientId(): string | null {\n\t\treturn this.shopClientId;\n\t}\n\tgetShopClientSecret(): string | null {\n\t\treturn this.shopClientSecret;\n\t}\n\tsetShopCredentials(clientId: string, clientSecret: string): void {\n\t\tthis.shopClientId = clientId;\n\t\tthis.shopClientSecret = clientSecret;\n\t}\n}\n\n/**\n * InMemoryShopRepository is a simple implementation of the ShopRepositoryInterface, it stores the shop data in memory\n */\nexport class InMemoryShopRepository\n\timplements ShopRepositoryInterface<SimpleShop>\n{\n\tprivate storage: Map<string, SimpleShop>;\n\n\tconstructor() {\n\t\tthis.storage = new Map<string, SimpleShop>();\n\t}\n\n\tasync createShop(id: string, url: string, secret: string) {\n\t\tthis.storage.set(id, new SimpleShop(id, url, secret));\n\t}\n\n\tasync getShopById(id: string): Promise<SimpleShop | null> {\n\t\tconst shop = this.storage.get(id);\n\n\t\tif (shop === undefined) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn shop;\n\t}\n\n\tasync updateShop(shop: SimpleShop) {\n\t\tthis.storage.set(shop.getShopId(), shop);\n\t}\n\n\tasync deleteShop(id: string) {\n\t\tthis.storage.delete(id);\n\t}\n}\n"]}
1
+ {"version":3,"file":"repository.js","sourceRoot":"","sources":["../../src/repository.ts"],"names":[],"mappings":";;;AA8BA;;GAEG;AACH,MAAa,UAAU;IACd,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,UAAU,CAAS;IACnB,YAAY,CAAgB;IAC5B,gBAAgB,CAAgB;IAChC,UAAU,GAAG,KAAK,CAAC;IAE3B,YAAY,MAAc,EAAE,OAAe,EAAE,UAAkB;QAC9D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAA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;IACb,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAgB;QAChC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EAAU;QAC1B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;CACD;AA9BD,wDA8BC","sourcesContent":["/**\n * ShopInterface defines the object that given back from the ShopRepository, it should methods to get the shop data and set them\n */\nexport interface ShopInterface {\n\tgetShopId(): string;\n\tgetShopUrl(): string;\n\tgetShopSecret(): string;\n\tgetShopClientId(): string | null;\n\tgetShopClientSecret(): string | null;\n\tgetShopActive(): boolean;\n\tsetShopCredentials(clientId: string, clientSecret: string): void;\n\tsetShopActive(active: boolean): void;\n}\n\n/**\n * ShopRepositoryInterface is the storage interface for the shops, you should implement this to save the shop data to your database\n * For testing cases the InMemoryShopRepository can be used\n */\nexport interface ShopRepositoryInterface<\n\tShop extends ShopInterface = ShopInterface,\n> {\n\tcreateShop(id: string, url: string, secret: string): Promise<void>;\n\n\tgetShopById(id: string): Promise<Shop | null>;\n\n\tupdateShop(shop: Shop): Promise<void>;\n\n\tdeleteShop(id: string): Promise<void>;\n}\n\n/**\n * SimpleShop is a simple implementation of the ShopInterface, it stores the shop data in memory\n */\nexport class SimpleShop implements ShopInterface {\n\tprivate shopId: string;\n\tprivate shopUrl: string;\n\tprivate shopSecret: string;\n\tprivate shopClientId: string | null;\n\tprivate shopClientSecret: string | null;\n\tprivate shopActive = false;\n\n\tconstructor(shopId: string, shopUrl: string, shopSecret: string) {\n\t\tthis.shopId = shopId;\n\t\tthis.shopUrl = shopUrl;\n\t\tthis.shopSecret = shopSecret;\n\t\tthis.shopClientId = null;\n\t\tthis.shopClientSecret = null;\n\t}\n\n\tgetShopActive(): boolean {\n\t\treturn this.shopActive;\n\t}\n\tsetShopActive(active: boolean): void {\n\t\tthis.shopActive = active;\n\t}\n\n\tgetShopId(): string {\n\t\treturn this.shopId;\n\t}\n\tgetShopUrl(): string {\n\t\treturn this.shopUrl;\n\t}\n\tgetShopSecret(): string {\n\t\treturn this.shopSecret;\n\t}\n\tgetShopClientId(): string | null {\n\t\treturn this.shopClientId;\n\t}\n\tgetShopClientSecret(): string | null {\n\t\treturn this.shopClientSecret;\n\t}\n\tsetShopCredentials(clientId: string, clientSecret: string): void {\n\t\tthis.shopClientId = clientId;\n\t\tthis.shopClientSecret = clientSecret;\n\t}\n}\n\n/**\n * InMemoryShopRepository is a simple implementation of the ShopRepositoryInterface, it stores the shop data in memory\n */\nexport class InMemoryShopRepository\n\timplements ShopRepositoryInterface<SimpleShop>\n{\n\tprivate storage: Map<string, SimpleShop>;\n\n\tconstructor() {\n\t\tthis.storage = new Map<string, SimpleShop>();\n\t}\n\n\tasync createShop(id: string, url: string, secret: string) {\n\t\tthis.storage.set(id, new SimpleShop(id, url, secret));\n\t}\n\n\tasync getShopById(id: string): Promise<SimpleShop | null> {\n\t\tconst shop = this.storage.get(id);\n\n\t\tif (shop === undefined) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn shop;\n\t}\n\n\tasync updateShop(shop: SimpleShop) {\n\t\tthis.storage.set(shop.getShopId(), shop);\n\t}\n\n\tasync deleteShop(id: string) {\n\t\tthis.storage.delete(id);\n\t}\n}\n"]}
package/dist/esm/app.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ContextResolver } from "./context-resolver.js";
2
+ import { Hooks } from "./hooks.js";
2
3
  import { Registration } from "./registration.js";
3
4
  import type { ShopInterface, ShopRepositoryInterface } from "./repository.js";
4
5
  import { WebCryptoHmacSigner } from "./signer.js";
@@ -8,9 +9,10 @@ import { WebCryptoHmacSigner } from "./signer.js";
8
9
  export declare class AppServer<Shop extends ShopInterface = ShopInterface> {
9
10
  cfg: Configuration;
10
11
  repository: ShopRepositoryInterface<Shop>;
11
- registration: Registration;
12
+ registration: Registration<Shop>;
12
13
  contextResolver: ContextResolver<Shop>;
13
14
  signer: WebCryptoHmacSigner;
15
+ hooks: Hooks<Shop>;
14
16
  constructor(cfg: Configuration, repository: ShopRepositoryInterface<Shop>);
15
17
  }
16
18
  interface Configuration {
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,qBAAa,SAAS,CAAC,IAAI,SAAS,aAAa,GAAG,aAAa;IAMxD,GAAG,EAAE,aAAa;IAClB,UAAU,EAAE,uBAAuB,CAAC,IAAI,CAAC;IAN1C,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,EAAE,mBAAmB,CAAC;gBAG3B,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,uBAAuB,CAAC,IAAI,CAAC;CAMjD;AAED,UAAU,aAAa;IACtB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC7B"}
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,qBAAa,SAAS,CAAC,IAAI,SAAS,aAAa,GAAG,aAAa;IAOxD,GAAG,EAAE,aAAa;IAClB,UAAU,EAAE,uBAAuB,CAAC,IAAI,CAAC;IAP1C,YAAY,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IACjC,eAAe,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;gBAGlB,GAAG,EAAE,aAAa,EAClB,UAAU,EAAE,uBAAuB,CAAC,IAAI,CAAC;CAOjD;AAED,UAAU,aAAa;IACtB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC7B"}
package/dist/esm/app.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ContextResolver } from "./context-resolver.js";
2
+ import { Hooks } from "./hooks.js";
2
3
  import { Registration } from "./registration.js";
3
4
  import { WebCryptoHmacSigner } from "./signer.js";
4
5
  /**
@@ -10,12 +11,14 @@ export class AppServer {
10
11
  registration;
11
12
  contextResolver;
12
13
  signer;
14
+ hooks;
13
15
  constructor(cfg, repository) {
14
16
  this.cfg = cfg;
15
17
  this.repository = repository;
16
18
  this.registration = new Registration(this);
17
19
  this.contextResolver = new ContextResolver(this);
18
20
  this.signer = new WebCryptoHmacSigner();
21
+ this.hooks = new Hooks();
19
22
  }
20
23
  }
21
24
  //# sourceMappingURL=app.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,SAAS;IAMb;IACA;IAND,YAAY,CAAe;IAC3B,eAAe,CAAwB;IACvC,MAAM,CAAsB;IAEnC,YACQ,GAAkB,EAClB,UAAyC;QADzC,QAAG,GAAH,GAAG,CAAe;QAClB,eAAU,GAAV,UAAU,CAA+B;QAEhD,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;IACzC,CAAC;CACD","sourcesContent":["import { ContextResolver } from \"./context-resolver.js\";\nimport { Registration } from \"./registration.js\";\nimport type { ShopInterface, ShopRepositoryInterface } from \"./repository.js\";\nimport { WebCryptoHmacSigner } from \"./signer.js\";\n\n/**\n * AppServer is the main class, this is where you start your app\n */\nexport class AppServer<Shop extends ShopInterface = ShopInterface> {\n\tpublic registration: Registration;\n\tpublic contextResolver: ContextResolver<Shop>;\n\tpublic signer: WebCryptoHmacSigner;\n\n\tconstructor(\n\t\tpublic cfg: Configuration,\n\t\tpublic repository: ShopRepositoryInterface<Shop>,\n\t) {\n\t\tthis.registration = new Registration(this);\n\t\tthis.contextResolver = new ContextResolver(this);\n\t\tthis.signer = new WebCryptoHmacSigner();\n\t}\n}\n\ninterface Configuration {\n\t/**\n\t * Your app name\n\t */\n\tappName: string;\n\n\t/**\n\t * Your app secret\n\t */\n\tappSecret: string;\n\n\t/**\n\t * URL to authorize callback url\n\t */\n\tauthorizeCallbackUrl: string;\n}\n"]}
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,MAAM,OAAO,SAAS;IAOb;IACA;IAPD,YAAY,CAAqB;IACjC,eAAe,CAAwB;IACvC,MAAM,CAAsB;IAC5B,KAAK,CAAc;IAE1B,YACQ,GAAkB,EAClB,UAAyC;QADzC,QAAG,GAAH,GAAG,CAAe;QAClB,eAAU,GAAV,UAAU,CAA+B;QAEhD,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAO,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAO,IAAI,CAAC,CAAC;QACvD,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAQ,CAAC;IAChC,CAAC;CACD","sourcesContent":["import { ContextResolver } from \"./context-resolver.js\";\nimport { Hooks } from \"./hooks.js\";\nimport { Registration } from \"./registration.js\";\nimport type { ShopInterface, ShopRepositoryInterface } from \"./repository.js\";\nimport { WebCryptoHmacSigner } from \"./signer.js\";\n\n/**\n * AppServer is the main class, this is where you start your app\n */\nexport class AppServer<Shop extends ShopInterface = ShopInterface> {\n\tpublic registration: Registration<Shop>;\n\tpublic contextResolver: ContextResolver<Shop>;\n\tpublic signer: WebCryptoHmacSigner;\n\tpublic hooks: Hooks<Shop>;\n\n\tconstructor(\n\t\tpublic cfg: Configuration,\n\t\tpublic repository: ShopRepositoryInterface<Shop>,\n\t) {\n\t\tthis.registration = new Registration<Shop>(this);\n\t\tthis.contextResolver = new ContextResolver<Shop>(this);\n\t\tthis.signer = new WebCryptoHmacSigner();\n\t\tthis.hooks = new Hooks<Shop>();\n\t}\n}\n\ninterface Configuration {\n\t/**\n\t * Your app name\n\t */\n\tappName: string;\n\n\t/**\n\t * Your app secret\n\t */\n\tappSecret: string;\n\n\t/**\n\t * URL to authorize callback url\n\t */\n\tauthorizeCallbackUrl: string;\n}\n"]}
@@ -7,7 +7,7 @@ import type { ShopInterface } from "./repository.js";
7
7
  */
8
8
  export declare class ContextResolver<Shop extends ShopInterface = ShopInterface> {
9
9
  private app;
10
- constructor(app: AppServer);
10
+ constructor(app: AppServer<Shop>);
11
11
  /**
12
12
  * Create a context from a request body
13
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"context-resolver.d.ts","sourceRoot":"","sources":["../../src/context-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,qBAAa,eAAe,CAAC,IAAI,SAAS,aAAa,GAAG,aAAa;IAC1D,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAElC;;OAEG;IACU,OAAO,CAAC,OAAO,GAAG,OAAO,EACrC,GAAG,EAAE,OAAO,GACV,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IA0ClC;;;OAGG;IACU,WAAW,CAAC,OAAO,GAAG,OAAO,EACzC,GAAG,EAAE,OAAO,GACV,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;CA6BlC;AAED;;GAEG;AACH,qBAAa,OAAO,CACnB,IAAI,SAAS,aAAa,GAAG,aAAa,EAC1C,OAAO,GAAG,OAAO;IAGT,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,UAAU;gBAFtB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU;CAE9B"}
1
+ {"version":3,"file":"context-resolver.d.ts","sourceRoot":"","sources":["../../src/context-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,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CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE3D,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,EAAE,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QAElE,MAAM,YAAY,GAA2B,EAAE,CAAC;QAEhD,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACvC,YAAY,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,OAAO,CACjB,IAAY,EACZ,YAAuB,EACvB,IAAI,UAAU,CAAC,IAAI,CAAC,CACpB,CAAC;IACH,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,OAAO;IAKX;IACA;IACA;IAHR,YACQ,IAAU,EACV,OAAgB,EAChB,UAAsB;QAFtB,SAAI,GAAJ,IAAI,CAAM;QACV,YAAO,GAAP,OAAO,CAAS;QAChB,eAAU,GAAV,UAAU,CAAY;IAC3B,CAAC;CACJ","sourcesContent":["import type { AppServer } from \"./app.js\";\nimport { HttpClient } from \"./http-client.js\";\nimport type { ShopInterface } from \"./repository.js\";\n\n/**\n * ContextResolver is a helper class to create a Context object from a request.\n * The context contains the shop, the payload and an instance of the HttpClient\n */\nexport class ContextResolver<Shop extends ShopInterface = ShopInterface> {\n\tconstructor(private app: AppServer) {}\n\n\t/**\n\t * Create a context from a request body\n\t */\n\tpublic async fromAPI<Payload = unknown>(\n\t\treq: Request,\n\t): Promise<Context<Shop, Payload>> {\n\t\tconst webHookContent = await req.text();\n\t\tconst webHookBody = JSON.parse(webHookContent);\n\n\t\tif (\n\t\t\twebHookBody.source === undefined ||\n\t\t\twebHookBody.source.shopId === undefined\n\t\t) {\n\t\t\tthrow new Error(\"Invalid request\");\n\t\t}\n\n\t\tconst shop = await this.app.repository.getShopById(\n\t\t\twebHookBody.source.shopId,\n\t\t);\n\n\t\tif (shop === null) {\n\t\t\tthrow new Error(`Cannot find shop by id ${webHookBody.source.shopId}`);\n\t\t}\n\n\t\tconst signature = req.headers.get(\"shopware-shop-signature\");\n\n\t\tif (signature === null) {\n\t\t\tthrow new Error(\"Missing shopware-shop-signature header\");\n\t\t}\n\n\t\tif (\n\t\t\t!(await this.app.signer.verify(\n\t\t\t\tsignature,\n\t\t\t\twebHookContent,\n\t\t\t\tshop.getShopSecret(),\n\t\t\t))\n\t\t) {\n\t\t\tthrow new Error(\"Invalid signature\");\n\t\t}\n\n\t\treturn new Context<Shop, Payload>(\n\t\t\tshop as Shop,\n\t\t\twebHookBody,\n\t\t\tnew HttpClient(shop),\n\t\t);\n\t}\n\n\t/**\n\t * Create a context from a request query parameters\n\t * This is usually a module request from the shopware admin\n\t */\n\tpublic async fromBrowser<Payload = unknown>(\n\t\treq: Request,\n\t): Promise<Context<Shop, Payload>> {\n\t\tconst url = new URL(req.url);\n\n\t\tconst shopId = url.searchParams.get(\"shop-id\");\n\n\t\tif (shopId === null) {\n\t\t\tthrow new Error(\"Missing shop-id query parameter\");\n\t\t}\n\n\t\tconst shop = await this.app.repository.getShopById(shopId);\n\n\t\tif (shop === null) {\n\t\t\tthrow new Error(`Cannot find shop by id ${shopId}`);\n\t\t}\n\n\t\tawait this.app.signer.verifyGetRequest(req, shop.getShopSecret());\n\n\t\tconst paramsObject: Record<string, string> = {};\n\n\t\turl.searchParams.forEach((value, key) => {\n\t\t\tparamsObject[key] = value;\n\t\t});\n\n\t\treturn new Context<Shop, Payload>(\n\t\t\tshop as Shop,\n\t\t\tparamsObject as Payload,\n\t\t\tnew HttpClient(shop),\n\t\t);\n\t}\n}\n\n/**\n * Context is the parsed data from the request\n */\nexport class Context<\n\tShop extends ShopInterface = ShopInterface,\n\tPayload = unknown,\n> {\n\tconstructor(\n\t\tpublic shop: Shop,\n\t\tpublic payload: Payload,\n\t\tpublic httpClient: HttpClient,\n\t) {}\n}\n"]}
1
+ {"version":3,"file":"context-resolver.js","sourceRoot":"","sources":["../../src/context-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;;GAGG;AACH,MAAM,OAAO,eAAe;IACP;IAApB,YAAoB,GAAoB;QAApB,QAAG,GAAH,GAAG,CAAiB;IAAG,CAAC;IAE5C;;OAEG;IACI,KAAK,CAAC,OAAO,CACnB,GAAY;QAEZ,MAAM,cAAc,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAE/C,IACC,WAAW,CAAC,MAAM,KAAK,SAAS;YAChC,WAAW,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,EACtC,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CACjD,WAAW,CAAC,MAAM,CAAC,MAAM,CACzB,CAAC;QAEF,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,0BAA0B,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;QAE7D,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC3D,CAAC;QAED,IACC,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAC7B,SAAS,EACT,cAAc,EACd,IAAI,CAAC,aAAa,EAAE,CACpB,CAAC,E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M;QACV,YAAO,GAAP,OAAO,CAAS;QAChB,eAAU,GAAV,UAAU,CAAY;IAC3B,CAAC;CACJ","sourcesContent":["import type { AppServer } from \"./app.js\";\nimport { HttpClient } from \"./http-client.js\";\nimport type { ShopInterface } from \"./repository.js\";\n\n/**\n * ContextResolver is a helper class to create a Context object from a request.\n * The context contains the shop, the payload and an instance of the HttpClient\n */\nexport class ContextResolver<Shop extends ShopInterface = ShopInterface> {\n\tconstructor(private app: AppServer<Shop>) {}\n\n\t/**\n\t * Create a context from a request body\n\t */\n\tpublic async fromAPI<Payload = unknown>(\n\t\treq: Request,\n\t): Promise<Context<Shop, Payload>> {\n\t\tconst webHookContent = await req.text();\n\t\tconst webHookBody = JSON.parse(webHookContent);\n\n\t\tif (\n\t\t\twebHookBody.source === undefined ||\n\t\t\twebHookBody.source.shopId === undefined\n\t\t) {\n\t\t\tthrow new Error(\"Invalid request\");\n\t\t}\n\n\t\tconst shop = await this.app.repository.getShopById(\n\t\t\twebHookBody.source.shopId,\n\t\t);\n\n\t\tif (shop === null) {\n\t\t\tthrow new Error(`Cannot find shop by id ${webHookBody.source.shopId}`);\n\t\t}\n\n\t\tconst signature = req.headers.get(\"shopware-shop-signature\");\n\n\t\tif (signature === null) {\n\t\t\tthrow new Error(\"Missing shopware-shop-signature header\");\n\t\t}\n\n\t\tif (\n\t\t\t!(await this.app.signer.verify(\n\t\t\t\tsignature,\n\t\t\t\twebHookContent,\n\t\t\t\tshop.getShopSecret(),\n\t\t\t))\n\t\t) {\n\t\t\tthrow new Error(\"Invalid signature\");\n\t\t}\n\n\t\treturn new Context<Shop, Payload>(\n\t\t\tshop as Shop,\n\t\t\twebHookBody,\n\t\t\tnew HttpClient(shop),\n\t\t);\n\t}\n\n\t/**\n\t * Create a context from a request query parameters\n\t * This is usually a module request from the shopware admin\n\t */\n\tpublic async fromBrowser<Payload = unknown>(\n\t\treq: Request,\n\t): Promise<Context<Shop, Payload>> {\n\t\tconst url = new URL(req.url);\n\n\t\tconst shopId = url.searchParams.get(\"shop-id\");\n\n\t\tif (shopId === null) {\n\t\t\tthrow new Error(\"Missing shop-id query parameter\");\n\t\t}\n\n\t\tconst shop = await this.app.repository.getShopById(shopId);\n\n\t\tif (shop === null) {\n\t\t\tthrow new Error(`Cannot find shop by id ${shopId}`);\n\t\t}\n\n\t\tawait this.app.signer.verifyGetRequest(req, shop.getShopSecret());\n\n\t\tconst paramsObject: Record<string, string> = {};\n\n\t\turl.searchParams.forEach((value, key) => {\n\t\t\tparamsObject[key] = value;\n\t\t});\n\n\t\treturn new Context<Shop, Payload>(\n\t\t\tshop as Shop,\n\t\t\tparamsObject as Payload,\n\t\t\tnew HttpClient(shop),\n\t\t);\n\t}\n}\n\n/**\n * Context is the parsed data from the request\n */\nexport class Context<\n\tShop extends ShopInterface = ShopInterface,\n\tPayload = unknown,\n> {\n\tconstructor(\n\t\tpublic shop: Shop,\n\t\tpublic payload: Payload,\n\t\tpublic httpClient: HttpClient,\n\t) {}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"criteria.d.ts","sourceRoot":"","sources":["../../../src/helper/criteria.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IAEzB,cAAc,IAAI;IAElB,iBAAiB,IAAI;IAErB,sBAAsB,IAAI;CAC1B;AAED,UAAU,OAAO;IAChB,QAAQ,EAAE;QACT,IAAI,EAAE,UAAU,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,EAAE;QACP,IAAI,EAAE,QAAQ,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,EAAE;QACP,IAAI,EAAE,QAAQ,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACd,CAAC;IACF,SAAS,EAAE;QACV,IAAI,EAAE,WAAW,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC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,KAAK,EAAE,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CACZ,KAAa,EACb,KAAuC;QAEvC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IACzC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,GAAG,CACT,QAAoC,EACpC,UAA0B,EAAE;QAE5B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAC9D,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,KAAK,CACX,QAAsC,EACtC,UAA0B,EAAE;QAE5B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC7C,CAAC;CACD","sourcesContent":["export enum TotalCountMode {\n\t/* No total count will be selected. Should be used if no pagination required (fastest) */\n\tNO_TOTAL_COUNT = 0,\n\t/* Exact total count will be selected. Should be used if an exact pagination is required (slow) */\n\tEXACT_TOTAL_COUNT = 1,\n\t/* Fetches limit * 5 + 1. Should be used if pagination can work with \"next page exists\" (fast) */\n\tPAGINATION_TOTAL_COUNT = 2,\n}\n\ninterface Filters {\n\tcontains: {\n\t\ttype: \"contains\";\n\t\tfield: string;\n\t\tvalue: string;\n\t};\n\tprefix: {\n\t\ttype: \"prefix\";\n\t\tfield: string;\n\t\tvalue: string;\n\t};\n\tsuffix: {\n\t\ttype: \"suffix\";\n\t\tfield: string;\n\t\tvalue: string;\n\t};\n\tequalsAny: {\n\t\ttype: \"equalsAny\";\n\t\tfield: string;\n\t\tvalue: (string | number | boolean | null)[];\n\t};\n\tequals: {\n\t\ttype: \"equals\";\n\t\tfield: string;\n\t\tvalue: string | number | boolean | null;\n\t};\n\trange: {\n\t\ttype: \"range\";\n\t\tfield: string;\n\t\tparameters: {\n\t\t\tlte?: string | number;\n\t\t\tlt?: string | number;\n\t\t\tgte?: string | number;\n\t\t\tgt?: string | number;\n\t\t};\n\t};\n\tnot: {\n\t\ttype: \"not\";\n\t\toperator: \"and\" | \"AND\" | \"or\" | \"OR\";\n\t\tqueries: SingleFilter[];\n\t};\n\tmulti: {\n\t\ttype: \"multi\";\n\t\toperator: \"and\" | \"AND\" | \"or\" | \"OR\";\n\t\tqueries: SingleFilter[];\n\t};\n}\n\ninterface Aggregations {\n\thistogram: {\n\t\ttype: \"histogram\";\n\t\tname: string;\n\t\tfield: string;\n\t\tinterval: string | null;\n\t\tformat: string | null;\n\t\taggregation: Aggregation | null;\n\t\ttimeZone: string | null;\n\t};\n\tterms: {\n\t\ttype: \"terms\";\n\t\tname: string;\n\t\tfield: string;\n\t\tlimit?: number | null;\n\t\tsort?: Sorting | null;\n\t\taggregation?: Aggregation | null;\n\t};\n\tsum: {\n\t\ttype: \"sum\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tstats: {\n\t\ttype: \"stats\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tmin: {\n\t\ttype: \"min\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tmax: {\n\t\ttype: \"max\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tcount: {\n\t\ttype: \"count\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tavg: {\n\t\ttype: \"avg\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tentity: {\n\t\ttype: \"entity\";\n\t\tname: string;\n\t\tfield: string;\n\t\tdefinition: string;\n\t};\n\tfilter: {\n\t\ttype: \"filter\";\n\t\tname: string;\n\t\tfilter: SingleFilter[];\n\t\taggregation: Aggregation;\n\t};\n}\n\ntype ValueOf<T> = T[keyof T];\nexport type SingleFilter = ValueOf<Filters>;\ntype Aggregation = ValueOf<Aggregations>;\n\ninterface Include {\n\t[entityName: string]: string[];\n}\ninterface Association {\n\tassociation: string;\n\tcriteria: Criteria;\n}\ninterface Query {\n\tscore: number;\n\tquery: SingleFilter;\n\tscoreField?: string;\n}\ninterface Sorting {\n\tfield: string;\n\torder: \"ASC\" | \"DESC\";\n\tnaturalSorting: boolean;\n\ttype?: string;\n}\ntype GroupField = string;\ninterface RequestParams {\n\tids?: string[];\n\tpage?: number;\n\tlimit?: number;\n\tterm?: string;\n\tquery?: Query[];\n\tfilter?: SingleFilter[];\n\t\"post-filter\"?: SingleFilter[];\n\tsort?: Sorting[];\n\taggregations?: Aggregation[];\n\tgrouping?: string[];\n\tfields?: string[];\n\tassociations?: {\n\t\t[association: string]: RequestParams;\n\t};\n\tincludes?: Include;\n\t\"total-count-mode\"?: TotalCountMode;\n}\n\nexport class Criteria {\n\ttitle: string | null;\n\n\tpage: number | null;\n\n\tlimit: number | null;\n\n\tterm: string | null;\n\n\tfilters: SingleFilter[];\n\n\tids: string[];\n\n\tqueries: Query[];\n\n\tassociations: Association[];\n\n\tpostFilter: SingleFilter[];\n\n\tsortings: Sorting[];\n\n\taggregations: Aggregation[];\n\n\tgrouping: string[];\n\n\tfields: string[];\n\n\ttotalCountMode: TotalCountMode | null;\n\n\tincludes: Include | null;\n\n\tconstructor(ids: string[] = []) {\n\t\tthis.page = null;\n\t\tthis.limit = null;\n\t\tthis.term = null;\n\t\tthis.title = null;\n\t\tthis.filters = [];\n\t\tthis.includes = null;\n\t\tthis.ids = ids;\n\t\tthis.queries = [];\n\t\tthis.associations = [];\n\t\tthis.postFilter = [];\n\t\tthis.sortings = [];\n\t\tthis.aggregations = [];\n\t\tthis.grouping = [];\n\t\tthis.fields = [];\n\t\tthis.totalCountMode = null;\n\t}\n\n\t/**\n\t * Parses the current criteria and generates an object which can be provided to the api\n\t */\n\ttoPayload(): RequestParams {\n\t\tconst params: RequestParams = {};\n\n\t\tif (this.ids.length > 0) {\n\t\t\tparams.ids = this.ids;\n\t\t}\n\t\tif (this.page !== null) {\n\t\t\tparams.page = this.page;\n\t\t}\n\t\tif (this.limit !== null) {\n\t\t\tparams.limit = this.limit;\n\t\t}\n\t\tif (this.term !== null) {\n\t\t\tparams.term = this.term;\n\t\t}\n\t\tif (this.queries.length > 0) {\n\t\t\tparams.query = this.queries;\n\t\t}\n\t\tif (this.filters.length > 0) {\n\t\t\tparams.filter = this.filters;\n\t\t}\n\t\tif (this.postFilter.length > 0) {\n\t\t\tparams[\"post-filter\"] = this.postFilter;\n\t\t}\n\t\tif (this.sortings.length > 0) {\n\t\t\tparams.sort = this.sortings;\n\t\t}\n\t\tif (this.aggregations.length > 0) {\n\t\t\tparams.aggregations = this.aggregations;\n\t\t}\n\t\tif (this.grouping.length > 0) {\n\t\t\tparams.grouping = this.grouping;\n\t\t}\n\t\tif (this.fields.length > 0) {\n\t\t\tparams.fields = this.fields;\n\t\t}\n\t\tif (this.associations.length > 0) {\n\t\t\tparams.associations = {};\n\n\t\t\tfor (const item of this.associations) {\n\t\t\t\tif (!params.associations) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tparams.associations[item.association] = item.criteria.toPayload();\n\t\t\t}\n\t\t}\n\t\tif (this.includes !== null) {\n\t\t\tparams.includes = this.includes;\n\t\t}\n\n\t\tif (this.totalCountMode !== null) {\n\t\t\tparams[\"total-count-mode\"] = this.totalCountMode;\n\t\t}\n\n\t\treturn params;\n\t}\n\n\t/**\n\t * Allows to provide a title for the criteria. This title will be shown in the `repository.search` request url so it can be used for debugging in network's tab\n\t */\n\tsetTitle(title: string): this {\n\t\tthis.title = title;\n\t\treturn this;\n\t}\n\n\tgetTitle(): string | null {\n\t\treturn this.title;\n\t}\n\t/**\n\t * Allows to provide a list of ids which are used as a filter\n\t */\n\tsetIds(ids: string[]): this {\n\t\tthis.ids = ids;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Allows to configure the total value of a search result.\n\t * 0 - no total count will be selected. Should be used if no pagination required (fastest)\n\t * 1 - exact total count will be selected. Should be used if an exact pagination is required (slow)\n\t * 2 - fetches limit * 5 + 1. Should be used if pagination can work with \"next page exists\" (fast)\n\t */\n\tsetTotalCountMode(mode: TotalCountMode): this {\n\t\tif (typeof mode !== \"number\") {\n\t\t\tthis.totalCountMode = null;\n\t\t}\n\n\t\tthis.totalCountMode = mode < 0 || mode > 2 ? null : mode;\n\t\treturn this;\n\t}\n\n\tsetPage(page: number): this {\n\t\tthis.page = page;\n\t\treturn this;\n\t}\n\n\tsetLimit(limit: number): this {\n\t\tthis.limit = limit;\n\t\treturn this;\n\t}\n\n\tsetTerm(term: string): this {\n\t\tthis.term = term;\n\t\treturn this;\n\t}\n\n\taddFilter(filter: SingleFilter): this {\n\t\tthis.filters.push(filter);\n\n\t\treturn this;\n\t}\n\n\taddIncludes(include: Include): this {\n\t\tfor (const [entityName, includeValues] of Object.entries(include)) {\n\t\t\tif (this.includes === null) {\n\t\t\t\tthis.includes = {};\n\t\t\t}\n\t\t\tif (!this.includes[entityName]) {\n\t\t\t\tthis.includes[entityName] = [];\n\t\t\t}\n\n\t\t\tthis.includes[entityName].push(...includeValues);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds the provided filter as post filter.\n\t * Post filter will be considered for the documents query but not for the aggregations.\n\t */\n\taddPostFilter(filter: SingleFilter): this {\n\t\tthis.postFilter.push(filter);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Allows to add different sortings for the criteria, to sort the entity result.\n\t */\n\taddSorting(sorting: Sorting): this {\n\t\tthis.sortings.push(sorting);\n\t\treturn this;\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Query\\ScoreQuery.\n\t * These queries are used to search for documents and score them with a ranking\n\t */\n\taddQuery(\n\t\tfilter: SingleFilter,\n\t\tscore: number,\n\t\tscoreField: string | null = null,\n\t): this {\n\t\tconst query: Query = { score: score, query: filter };\n\n\t\tif (scoreField) {\n\t\t\tquery.scoreField = scoreField;\n\t\t}\n\n\t\tthis.queries.push(query);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Allows grouping the result by a specific field\n\t */\n\taddGrouping(field: string): this {\n\t\tthis.grouping.push(field);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Allows loading partial fields for the result.\n\t */\n\taddFields(...field: string[]): this {\n\t\tthis.fields.push(...field);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * @param {Object} aggregation\n\t */\n\taddAggregation(aggregation: Aggregation): this {\n\t\tthis.aggregations.push(aggregation);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Ensures that a criterion is created for each segment of the passed path.\n\t * Existing Criteria objects are not overwritten.\n\t * Returns the own instance\n\t */\n\taddAssociation(path: string): this {\n\t\tthis.getAssociation(path);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Ensures that a criterion is created for each segment of the passed path.\n\t * Returns the criteria instance of the last path segment\n\t */\n\tgetAssociation(path: string): Criteria {\n\t\tconst parts = path.split(\".\");\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-this-alias\n\t\tlet criteria = this;\n\n\t\tfor (const part of parts) {\n\t\t\tif (!criteria.hasAssociation(part)) {\n\t\t\t\tcriteria.associations.push({\n\t\t\t\t\tassociation: part,\n\t\t\t\t\tcriteria: new Criteria(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// @ts-expect-error - another this instance\n\t\t\tcriteria = criteria.getAssociationCriteria(part);\n\t\t}\n\n\t\treturn criteria;\n\t}\n\n\tprivate getAssociationCriteria(part: string): Criteria {\n\t\tlet criteria = null;\n\n\t\tfor (const association of this.associations) {\n\t\t\tif (association.association === part) {\n\t\t\t\tcriteria = association.criteria;\n\t\t\t}\n\t\t}\n\n\t\tif (!criteria) {\n\t\t\tcriteria = new Criteria();\n\t\t\tthis.associations.push({\n\t\t\t\tassociation: part,\n\t\t\t\tcriteria,\n\t\t\t});\n\t\t}\n\n\t\treturn criteria;\n\t}\n\n\tgetLimit(): number {\n\t\treturn this.limit ?? 0;\n\t}\n\n\tgetPage(): number {\n\t\treturn this.page ?? 0;\n\t}\n\n\thasAssociation(property: string): boolean {\n\t\treturn this.associations.some((assocation) => {\n\t\t\treturn assocation.association === property;\n\t\t});\n\t}\n\n\t/**\n\t * Resets the sorting parameter\n\t */\n\tresetSorting(): void {\n\t\tthis.sortings = [];\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\AvgAggregation\n\t * Allows to calculate the avg value for the provided field\n\t */\n\tstatic avg(name: string, field: string): Aggregations[\"avg\"] {\n\t\treturn { type: \"avg\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\CountAggregation\n\t * Allows to calculate the count value for the provided field\n\t */\n\tstatic count(name: string, field: string): Aggregations[\"count\"] {\n\t\treturn { type: \"count\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\MaxAggregation\n\t * Allows to calculate the max value for the provided field\n\t */\n\tstatic max(name: string, field: string): Aggregations[\"max\"] {\n\t\treturn { type: \"max\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\MinAggregation\n\t * Allows to calculate the min value for the provided field\n\t */\n\tstatic min(name: string, field: string): Aggregations[\"min\"] {\n\t\treturn { type: \"min\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\StatsAggregation\n\t * Allows to calculate the sum, max, min, avg, count values for the provided field\n\t */\n\tstatic stats(name: string, field: string): Aggregations[\"stats\"] {\n\t\treturn { type: \"stats\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\SumAggregation\n\t * Allows to calculate the sum value for the provided field\n\t */\n\tstatic sum(name: string, field: string): Aggregations[\"sum\"] {\n\t\treturn { type: \"sum\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Bucket\\TermsAggregation\n\t * Allows to fetch term buckets for the provided field\n\t */\n\tstatic terms(\n\t\tname: string,\n\t\tfield: string,\n\t\tlimit: number | null = null,\n\t\tsort: Sorting | null = null,\n\t\taggregation: Aggregation | null = null,\n\t): Aggregations[\"terms\"] {\n\t\treturn { type: \"terms\", name, field, limit, sort, aggregation };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\EntityAggregation\n\t * Allows to filter an aggregation result\n\t */\n\tstatic entityAggregation(\n\t\tname: string,\n\t\tfield: string,\n\t\tdefinition: string,\n\t): Aggregations[\"entity\"] {\n\t\treturn { type: \"entity\", name, field, definition };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Bucket\\FilterAggregation\n\t * Allows to filter an aggregation result\n\t */\n\tstatic filter(\n\t\tname: string,\n\t\tfilter: SingleFilter[],\n\t\taggregation: Aggregation,\n\t): Aggregations[\"filter\"] {\n\t\treturn { type: \"filter\", name, filter, aggregation };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Bucket\\DateHistogramAggregation\n\t * Allows to fetch date buckets for the provided date interval\n\t */\n\tstatic histogram(\n\t\tname: string,\n\t\tfield: string,\n\t\tinterval: string | null = null,\n\t\tformat: string | null = null,\n\t\taggregation: Aggregation | null = null,\n\t\ttimeZone: string | null = null,\n\t): Aggregations[\"histogram\"] {\n\t\treturn {\n\t\t\ttype: \"histogram\",\n\t\t\tname,\n\t\t\tfield,\n\t\t\tinterval,\n\t\t\tformat,\n\t\t\taggregation,\n\t\t\ttimeZone,\n\t\t};\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Sorting\\FieldSorting.\n\t * Allows to sort the documents by the provided field\n\t */\n\tstatic sort(\n\t\tfield: string,\n\t\torder: Sorting[\"order\"] = \"ASC\",\n\t\tnaturalSorting = false,\n\t): Sorting {\n\t\treturn { field, order, naturalSorting };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Sorting\\FieldSorting.\n\t * Allows to sort the documents by the provided field naturally\n\t */\n\tstatic naturalSorting(\n\t\tfield: string,\n\t\torder: Sorting[\"order\"] = \"ASC\",\n\t): Sorting {\n\t\treturn { field, order, naturalSorting: true };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Sorting\\CountSorting.\n\t * Allows to sort the documents by counting associations via the provided field\n\t *\n\t * Sql representation: `ORDER BY COUNT({field}) {order}`\n\t */\n\tstatic countSorting(field: string, order: Sorting[\"order\"] = \"ASC\"): Sorting {\n\t\treturn { field, order, naturalSorting: false, type: \"count\" };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\ContainsFilter.\n\t * This allows to filter documents where the value are contained in the provided field.\n\t *\n\t * Sql representation: `{field} LIKE %{value}%`\n\t */\n\tstatic contains(field: string, value: string): Filters[\"contains\"] {\n\t\treturn { type: \"contains\", field, value };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\PrefixFilter.\n\t * This allows to filter documents where the value marks the beginning of the provided field.\n\t *\n\t * Sql representation: `{field} LIKE {value}%`\n\t */\n\tstatic prefix(field: string, value: string): Filters[\"prefix\"] {\n\t\treturn { type: \"prefix\", field, value };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\SuffixFilter.\n\t * This allows to filter documents where the value marks the end of the provided field.\n\t *\n\t * Sql representation: `{field} LIKE %{value}`\n\t */\n\tstatic suffix(field: string, value: string): Filters[\"suffix\"] {\n\t\treturn { type: \"suffix\", field, value };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\EqualsAnyFilter.\n\t * This allows to filter documents where the field matches one of the provided values\n\t *\n\t * Sql representation: `{field} IN ({value}, {value})`\n\t */\n\tstatic equalsAny(\n\t\tfield: string,\n\t\tvalue: (string | number | boolean | null)[],\n\t): Filters[\"equalsAny\"] {\n\t\treturn { type: \"equalsAny\", field, value: value };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\RangeFilter.\n\t * This allows to filter documents where the field matches a defined range\n\t *\n\t * Sql representation: `{field} >= {value}`, `{field} <= {value}`, ...\n\t */\n\tstatic range(\n\t\tfield: string,\n\t\trange: Filters[\"range\"][\"parameters\"],\n\t): Filters[\"range\"] {\n\t\treturn { type: \"range\", field, parameters: range };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\EqualsFilter.\n\t * This allows to filter documents where the field matches a defined range\n\t *\n\t * Sql representation: `{field} = {value}`\n\t */\n\tstatic equals(\n\t\tfield: string,\n\t\tvalue: string | number | boolean | null,\n\t): Filters[\"equals\"] {\n\t\treturn { type: \"equals\", field, value };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\NotFilter.\n\t * This allows to filter documents which not matches for the provided filters\n\t * All above listed queries can be provided (equals, equalsAny, range, contains)\n\t *\n\t * Sql representation: `NOT({query} {operator} {query} {operator} {query})`\n\t *\n\t * @param {string} operator - and/or\n\t * @param {array} queries\n\t *\n\t * @returns {Object}\n\t */\n\tstatic not(\n\t\toperator: Filters[\"not\"][\"operator\"],\n\t\tqueries: SingleFilter[] = [],\n\t): Filters[\"not\"] {\n\t\treturn { type: \"not\", operator: operator, queries: queries };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\NotFilter.\n\t * This allows to filter documents which matches for the provided filters\n\t * All above listed queries can be provided (equals, equalsAny, range, contains)\n\t *\n\t * Sql representation: `({query} {operator} {query} {operator} {query})`\n\t *\n\t * @param {string} operator - and/or\n\t * @param {array} queries\n\t *\n\t * @returns {Object}\n\t */\n\tstatic multi(\n\t\toperator: Filters[\"multi\"][\"operator\"],\n\t\tqueries: SingleFilter[] = [],\n\t): Filters[\"multi\"] {\n\t\treturn { type: \"multi\", operator, queries };\n\t}\n}\n"]}
1
+ {"version":3,"file":"criteria.js","sourceRoot":"","sources":["../../../src/helper/criteria.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAOX;AAPD,WAAY,cAAc;IACzB,yFAAyF;IACzF,uEAAkB,CAAA;IAClB,kGAAkG;IAClG,6EAAqB,CAAA;IACrB,iGAAiG;IACjG,uFAA0B,CAAA;AAC3B,CAAC,EAPW,cAAc,KAAd,cAAc,QAOzB;AAyJD,MAAM,OAAO,QAAQ;IACpB,KAAK,CAAgB;IAErB,IAAI,CAAgB;IAEpB,KAAK,CAAgB;IAErB,IAAI,CAAgB;IAEpB,OAAO,CAAiB;IAExB,GAAG,CAAW;IAEd,OAAO,CAAU;IAEjB,YAAY,CAAgB;IAE5B,UAAU,CAAiB;IAE3B,QAAQ,CAAY;IAEpB,YAAY,CAAgB;IAE5B,QAAQ,CAAW;IAEnB,MAAM,CAAW;IAEjB,cAAc,CAAwB;IAEtC,QAAQ,CAAiB;IAEzB,YAAY,MAAgB,EAAE;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IA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sC,EACtC,UAA0B,EAAE;QAE5B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC7C,CAAC;CACD","sourcesContent":["export enum TotalCountMode {\n\t/* No total count will be selected. Should be used if no pagination required (fastest) */\n\tNO_TOTAL_COUNT = 0,\n\t/* Exact total count will be selected. Should be used if an exact pagination is required (slow) */\n\tEXACT_TOTAL_COUNT = 1,\n\t/* Fetches limit * 5 + 1. Should be used if pagination can work with \"next page exists\" (fast) */\n\tPAGINATION_TOTAL_COUNT = 2,\n}\n\ninterface Filters {\n\tcontains: {\n\t\ttype: \"contains\";\n\t\tfield: string;\n\t\tvalue: string;\n\t};\n\tprefix: {\n\t\ttype: \"prefix\";\n\t\tfield: string;\n\t\tvalue: string;\n\t};\n\tsuffix: {\n\t\ttype: \"suffix\";\n\t\tfield: string;\n\t\tvalue: string;\n\t};\n\tequalsAny: {\n\t\ttype: \"equalsAny\";\n\t\tfield: string;\n\t\tvalue: (string | number | boolean | null)[];\n\t};\n\tequals: {\n\t\ttype: \"equals\";\n\t\tfield: string;\n\t\tvalue: string | number | boolean | null;\n\t};\n\trange: {\n\t\ttype: \"range\";\n\t\tfield: string;\n\t\tparameters: {\n\t\t\tlte?: string | number;\n\t\t\tlt?: string | number;\n\t\t\tgte?: string | number;\n\t\t\tgt?: string | number;\n\t\t};\n\t};\n\tnot: {\n\t\ttype: \"not\";\n\t\toperator: \"and\" | \"AND\" | \"or\" | \"OR\";\n\t\tqueries: SingleFilter[];\n\t};\n\tmulti: {\n\t\ttype: \"multi\";\n\t\toperator: \"and\" | \"AND\" | \"or\" | \"OR\";\n\t\tqueries: SingleFilter[];\n\t};\n}\n\ninterface Aggregations {\n\thistogram: {\n\t\ttype: \"histogram\";\n\t\tname: string;\n\t\tfield: string;\n\t\tinterval: string | null;\n\t\tformat: string | null;\n\t\taggregation: Aggregation | null;\n\t\ttimeZone: string | null;\n\t};\n\tterms: {\n\t\ttype: \"terms\";\n\t\tname: string;\n\t\tfield: string;\n\t\tlimit?: number | null;\n\t\tsort?: Sorting | null;\n\t\taggregation?: Aggregation | null;\n\t};\n\tsum: {\n\t\ttype: \"sum\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tstats: {\n\t\ttype: \"stats\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tmin: {\n\t\ttype: \"min\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tmax: {\n\t\ttype: \"max\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tcount: {\n\t\ttype: \"count\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tavg: {\n\t\ttype: \"avg\";\n\t\tname: string;\n\t\tfield: string;\n\t};\n\tentity: {\n\t\ttype: \"entity\";\n\t\tname: string;\n\t\tfield: string;\n\t\tdefinition: string;\n\t};\n\tfilter: {\n\t\ttype: \"filter\";\n\t\tname: string;\n\t\tfilter: SingleFilter[];\n\t\taggregation: Aggregation;\n\t};\n}\n\ntype ValueOf<T> = T[keyof T];\nexport type SingleFilter = ValueOf<Filters>;\ntype Aggregation = ValueOf<Aggregations>;\n\ninterface Include {\n\t[entityName: string]: string[];\n}\ninterface Association {\n\tassociation: string;\n\tcriteria: Criteria;\n}\ninterface Query {\n\tscore: number;\n\tquery: SingleFilter;\n\tscoreField?: string;\n}\ninterface Sorting {\n\tfield: string;\n\torder: \"ASC\" | \"DESC\";\n\tnaturalSorting: boolean;\n\ttype?: string;\n}\ninterface RequestParams {\n\tids?: string[];\n\tpage?: number;\n\tlimit?: number;\n\tterm?: string;\n\tquery?: Query[];\n\tfilter?: SingleFilter[];\n\t\"post-filter\"?: SingleFilter[];\n\tsort?: Sorting[];\n\taggregations?: Aggregation[];\n\tgrouping?: string[];\n\tfields?: string[];\n\tassociations?: {\n\t\t[association: string]: RequestParams;\n\t};\n\tincludes?: Include;\n\t\"total-count-mode\"?: TotalCountMode;\n}\n\nexport class Criteria {\n\ttitle: string | null;\n\n\tpage: number | null;\n\n\tlimit: number | null;\n\n\tterm: string | null;\n\n\tfilters: SingleFilter[];\n\n\tids: string[];\n\n\tqueries: Query[];\n\n\tassociations: Association[];\n\n\tpostFilter: SingleFilter[];\n\n\tsortings: Sorting[];\n\n\taggregations: Aggregation[];\n\n\tgrouping: string[];\n\n\tfields: string[];\n\n\ttotalCountMode: TotalCountMode | null;\n\n\tincludes: Include | null;\n\n\tconstructor(ids: string[] = []) {\n\t\tthis.page = null;\n\t\tthis.limit = null;\n\t\tthis.term = null;\n\t\tthis.title = null;\n\t\tthis.filters = [];\n\t\tthis.includes = null;\n\t\tthis.ids = ids;\n\t\tthis.queries = [];\n\t\tthis.associations = [];\n\t\tthis.postFilter = [];\n\t\tthis.sortings = [];\n\t\tthis.aggregations = [];\n\t\tthis.grouping = [];\n\t\tthis.fields = [];\n\t\tthis.totalCountMode = null;\n\t}\n\n\t/**\n\t * Parses the current criteria and generates an object which can be provided to the api\n\t */\n\ttoPayload(): RequestParams {\n\t\tconst params: RequestParams = {};\n\n\t\tif (this.ids.length > 0) {\n\t\t\tparams.ids = this.ids;\n\t\t}\n\t\tif (this.page !== null) {\n\t\t\tparams.page = this.page;\n\t\t}\n\t\tif (this.limit !== null) {\n\t\t\tparams.limit = this.limit;\n\t\t}\n\t\tif (this.term !== null) {\n\t\t\tparams.term = this.term;\n\t\t}\n\t\tif (this.queries.length > 0) {\n\t\t\tparams.query = this.queries;\n\t\t}\n\t\tif (this.filters.length > 0) {\n\t\t\tparams.filter = this.filters;\n\t\t}\n\t\tif (this.postFilter.length > 0) {\n\t\t\tparams[\"post-filter\"] = this.postFilter;\n\t\t}\n\t\tif (this.sortings.length > 0) {\n\t\t\tparams.sort = this.sortings;\n\t\t}\n\t\tif (this.aggregations.length > 0) {\n\t\t\tparams.aggregations = this.aggregations;\n\t\t}\n\t\tif (this.grouping.length > 0) {\n\t\t\tparams.grouping = this.grouping;\n\t\t}\n\t\tif (this.fields.length > 0) {\n\t\t\tparams.fields = this.fields;\n\t\t}\n\t\tif (this.associations.length > 0) {\n\t\t\tparams.associations = {};\n\n\t\t\tfor (const item of this.associations) {\n\t\t\t\tif (!params.associations) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tparams.associations[item.association] = item.criteria.toPayload();\n\t\t\t}\n\t\t}\n\t\tif (this.includes !== null) {\n\t\t\tparams.includes = this.includes;\n\t\t}\n\n\t\tif (this.totalCountMode !== null) {\n\t\t\tparams[\"total-count-mode\"] = this.totalCountMode;\n\t\t}\n\n\t\treturn params;\n\t}\n\n\t/**\n\t * Allows to provide a title for the criteria. This title will be shown in the `repository.search` request url so it can be used for debugging in network's tab\n\t */\n\tsetTitle(title: string): this {\n\t\tthis.title = title;\n\t\treturn this;\n\t}\n\n\tgetTitle(): string | null {\n\t\treturn this.title;\n\t}\n\t/**\n\t * Allows to provide a list of ids which are used as a filter\n\t */\n\tsetIds(ids: string[]): this {\n\t\tthis.ids = ids;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Allows to configure the total value of a search result.\n\t * 0 - no total count will be selected. Should be used if no pagination required (fastest)\n\t * 1 - exact total count will be selected. Should be used if an exact pagination is required (slow)\n\t * 2 - fetches limit * 5 + 1. Should be used if pagination can work with \"next page exists\" (fast)\n\t */\n\tsetTotalCountMode(mode: TotalCountMode): this {\n\t\tif (typeof mode !== \"number\") {\n\t\t\tthis.totalCountMode = null;\n\t\t}\n\n\t\tthis.totalCountMode = mode < 0 || mode > 2 ? null : mode;\n\t\treturn this;\n\t}\n\n\tsetPage(page: number): this {\n\t\tthis.page = page;\n\t\treturn this;\n\t}\n\n\tsetLimit(limit: number): this {\n\t\tthis.limit = limit;\n\t\treturn this;\n\t}\n\n\tsetTerm(term: string): this {\n\t\tthis.term = term;\n\t\treturn this;\n\t}\n\n\taddFilter(filter: SingleFilter): this {\n\t\tthis.filters.push(filter);\n\n\t\treturn this;\n\t}\n\n\taddIncludes(include: Include): this {\n\t\tfor (const [entityName, includeValues] of Object.entries(include)) {\n\t\t\tif (this.includes === null) {\n\t\t\t\tthis.includes = {};\n\t\t\t}\n\t\t\tif (!this.includes[entityName]) {\n\t\t\t\tthis.includes[entityName] = [];\n\t\t\t}\n\n\t\t\tthis.includes[entityName].push(...includeValues);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds the provided filter as post filter.\n\t * Post filter will be considered for the documents query but not for the aggregations.\n\t */\n\taddPostFilter(filter: SingleFilter): this {\n\t\tthis.postFilter.push(filter);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Allows to add different sortings for the criteria, to sort the entity result.\n\t */\n\taddSorting(sorting: Sorting): this {\n\t\tthis.sortings.push(sorting);\n\t\treturn this;\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Query\\ScoreQuery.\n\t * These queries are used to search for documents and score them with a ranking\n\t */\n\taddQuery(\n\t\tfilter: SingleFilter,\n\t\tscore: number,\n\t\tscoreField: string | null = null,\n\t): this {\n\t\tconst query: Query = { score: score, query: filter };\n\n\t\tif (scoreField) {\n\t\t\tquery.scoreField = scoreField;\n\t\t}\n\n\t\tthis.queries.push(query);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Allows grouping the result by a specific field\n\t */\n\taddGrouping(field: string): this {\n\t\tthis.grouping.push(field);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Allows loading partial fields for the result.\n\t */\n\taddFields(...field: string[]): this {\n\t\tthis.fields.push(...field);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * @param {Object} aggregation\n\t */\n\taddAggregation(aggregation: Aggregation): this {\n\t\tthis.aggregations.push(aggregation);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Ensures that a criterion is created for each segment of the passed path.\n\t * Existing Criteria objects are not overwritten.\n\t * Returns the own instance\n\t */\n\taddAssociation(path: string): this {\n\t\tthis.getAssociation(path);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Ensures that a criterion is created for each segment of the passed path.\n\t * Returns the criteria instance of the last path segment\n\t */\n\tgetAssociation(path: string): Criteria {\n\t\tconst parts = path.split(\".\");\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-this-alias\n\t\tlet criteria = this;\n\n\t\tfor (const part of parts) {\n\t\t\tif (!criteria.hasAssociation(part)) {\n\t\t\t\tcriteria.associations.push({\n\t\t\t\t\tassociation: part,\n\t\t\t\t\tcriteria: new Criteria(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// @ts-expect-error - another this instance\n\t\t\tcriteria = criteria.getAssociationCriteria(part);\n\t\t}\n\n\t\treturn criteria;\n\t}\n\n\tprivate getAssociationCriteria(part: string): Criteria {\n\t\tlet criteria = null;\n\n\t\tfor (const association of this.associations) {\n\t\t\tif (association.association === part) {\n\t\t\t\tcriteria = association.criteria;\n\t\t\t}\n\t\t}\n\n\t\tif (!criteria) {\n\t\t\tcriteria = new Criteria();\n\t\t\tthis.associations.push({\n\t\t\t\tassociation: part,\n\t\t\t\tcriteria,\n\t\t\t});\n\t\t}\n\n\t\treturn criteria;\n\t}\n\n\tgetLimit(): number {\n\t\treturn this.limit ?? 0;\n\t}\n\n\tgetPage(): number {\n\t\treturn this.page ?? 0;\n\t}\n\n\thasAssociation(property: string): boolean {\n\t\treturn this.associations.some((assocation) => {\n\t\t\treturn assocation.association === property;\n\t\t});\n\t}\n\n\t/**\n\t * Resets the sorting parameter\n\t */\n\tresetSorting(): void {\n\t\tthis.sortings = [];\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\AvgAggregation\n\t * Allows to calculate the avg value for the provided field\n\t */\n\tstatic avg(name: string, field: string): Aggregations[\"avg\"] {\n\t\treturn { type: \"avg\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\CountAggregation\n\t * Allows to calculate the count value for the provided field\n\t */\n\tstatic count(name: string, field: string): Aggregations[\"count\"] {\n\t\treturn { type: \"count\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\MaxAggregation\n\t * Allows to calculate the max value for the provided field\n\t */\n\tstatic max(name: string, field: string): Aggregations[\"max\"] {\n\t\treturn { type: \"max\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\MinAggregation\n\t * Allows to calculate the min value for the provided field\n\t */\n\tstatic min(name: string, field: string): Aggregations[\"min\"] {\n\t\treturn { type: \"min\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\StatsAggregation\n\t * Allows to calculate the sum, max, min, avg, count values for the provided field\n\t */\n\tstatic stats(name: string, field: string): Aggregations[\"stats\"] {\n\t\treturn { type: \"stats\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\SumAggregation\n\t * Allows to calculate the sum value for the provided field\n\t */\n\tstatic sum(name: string, field: string): Aggregations[\"sum\"] {\n\t\treturn { type: \"sum\", name, field };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Bucket\\TermsAggregation\n\t * Allows to fetch term buckets for the provided field\n\t */\n\tstatic terms(\n\t\tname: string,\n\t\tfield: string,\n\t\tlimit: number | null = null,\n\t\tsort: Sorting | null = null,\n\t\taggregation: Aggregation | null = null,\n\t): Aggregations[\"terms\"] {\n\t\treturn { type: \"terms\", name, field, limit, sort, aggregation };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Metric\\EntityAggregation\n\t * Allows to filter an aggregation result\n\t */\n\tstatic entityAggregation(\n\t\tname: string,\n\t\tfield: string,\n\t\tdefinition: string,\n\t): Aggregations[\"entity\"] {\n\t\treturn { type: \"entity\", name, field, definition };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Bucket\\FilterAggregation\n\t * Allows to filter an aggregation result\n\t */\n\tstatic filter(\n\t\tname: string,\n\t\tfilter: SingleFilter[],\n\t\taggregation: Aggregation,\n\t): Aggregations[\"filter\"] {\n\t\treturn { type: \"filter\", name, filter, aggregation };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Aggregation\\Bucket\\DateHistogramAggregation\n\t * Allows to fetch date buckets for the provided date interval\n\t */\n\tstatic histogram(\n\t\tname: string,\n\t\tfield: string,\n\t\tinterval: string | null = null,\n\t\tformat: string | null = null,\n\t\taggregation: Aggregation | null = null,\n\t\ttimeZone: string | null = null,\n\t): Aggregations[\"histogram\"] {\n\t\treturn {\n\t\t\ttype: \"histogram\",\n\t\t\tname,\n\t\t\tfield,\n\t\t\tinterval,\n\t\t\tformat,\n\t\t\taggregation,\n\t\t\ttimeZone,\n\t\t};\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Sorting\\FieldSorting.\n\t * Allows to sort the documents by the provided field\n\t */\n\tstatic sort(\n\t\tfield: string,\n\t\torder: Sorting[\"order\"] = \"ASC\",\n\t\tnaturalSorting = false,\n\t): Sorting {\n\t\treturn { field, order, naturalSorting };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Sorting\\FieldSorting.\n\t * Allows to sort the documents by the provided field naturally\n\t */\n\tstatic naturalSorting(\n\t\tfield: string,\n\t\torder: Sorting[\"order\"] = \"ASC\",\n\t): Sorting {\n\t\treturn { field, order, naturalSorting: true };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Sorting\\CountSorting.\n\t * Allows to sort the documents by counting associations via the provided field\n\t *\n\t * Sql representation: `ORDER BY COUNT({field}) {order}`\n\t */\n\tstatic countSorting(field: string, order: Sorting[\"order\"] = \"ASC\"): Sorting {\n\t\treturn { field, order, naturalSorting: false, type: \"count\" };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\ContainsFilter.\n\t * This allows to filter documents where the value are contained in the provided field.\n\t *\n\t * Sql representation: `{field} LIKE %{value}%`\n\t */\n\tstatic contains(field: string, value: string): Filters[\"contains\"] {\n\t\treturn { type: \"contains\", field, value };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\PrefixFilter.\n\t * This allows to filter documents where the value marks the beginning of the provided field.\n\t *\n\t * Sql representation: `{field} LIKE {value}%`\n\t */\n\tstatic prefix(field: string, value: string): Filters[\"prefix\"] {\n\t\treturn { type: \"prefix\", field, value };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\SuffixFilter.\n\t * This allows to filter documents where the value marks the end of the provided field.\n\t *\n\t * Sql representation: `{field} LIKE %{value}`\n\t */\n\tstatic suffix(field: string, value: string): Filters[\"suffix\"] {\n\t\treturn { type: \"suffix\", field, value };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\EqualsAnyFilter.\n\t * This allows to filter documents where the field matches one of the provided values\n\t *\n\t * Sql representation: `{field} IN ({value}, {value})`\n\t */\n\tstatic equalsAny(\n\t\tfield: string,\n\t\tvalue: (string | number | boolean | null)[],\n\t): Filters[\"equalsAny\"] {\n\t\treturn { type: \"equalsAny\", field, value: value };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\RangeFilter.\n\t * This allows to filter documents where the field matches a defined range\n\t *\n\t * Sql representation: `{field} >= {value}`, `{field} <= {value}`, ...\n\t */\n\tstatic range(\n\t\tfield: string,\n\t\trange: Filters[\"range\"][\"parameters\"],\n\t): Filters[\"range\"] {\n\t\treturn { type: \"range\", field, parameters: range };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\EqualsFilter.\n\t * This allows to filter documents where the field matches a defined range\n\t *\n\t * Sql representation: `{field} = {value}`\n\t */\n\tstatic equals(\n\t\tfield: string,\n\t\tvalue: string | number | boolean | null,\n\t): Filters[\"equals\"] {\n\t\treturn { type: \"equals\", field, value };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\NotFilter.\n\t * This allows to filter documents which not matches for the provided filters\n\t * All above listed queries can be provided (equals, equalsAny, range, contains)\n\t *\n\t * Sql representation: `NOT({query} {operator} {query} {operator} {query})`\n\t *\n\t * @param {string} operator - and/or\n\t * @param {array} queries\n\t *\n\t * @returns {Object}\n\t */\n\tstatic not(\n\t\toperator: Filters[\"not\"][\"operator\"],\n\t\tqueries: SingleFilter[] = [],\n\t): Filters[\"not\"] {\n\t\treturn { type: \"not\", operator: operator, queries: queries };\n\t}\n\n\t/**\n\t * @see \\Shopware\\Core\\Framework\\DataAbstractionLayer\\Search\\Filter\\NotFilter.\n\t * This allows to filter documents which matches for the provided filters\n\t * All above listed queries can be provided (equals, equalsAny, range, contains)\n\t *\n\t * Sql representation: `({query} {operator} {query} {operator} {query})`\n\t *\n\t * @param {string} operator - and/or\n\t * @param {array} queries\n\t *\n\t * @returns {Object}\n\t */\n\tstatic multi(\n\t\toperator: Filters[\"multi\"][\"operator\"],\n\t\tqueries: SingleFilter[] = [],\n\t): Filters[\"multi\"] {\n\t\treturn { type: \"multi\", operator, queries };\n\t}\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { ShopAuthroizeEvent } from "./registration.js";
2
+ import type { ShopInterface } from "./repository.js";
3
+ interface HookRegistry<Shop extends ShopInterface> {
4
+ onAuthorize: (event: ShopAuthroizeEvent<Shop>) => Promise<void>;
5
+ }
6
+ export declare class Hooks<Shop extends ShopInterface = ShopInterface> {
7
+ private eventListeners;
8
+ hasListeners(event: keyof HookRegistry<Shop>): boolean;
9
+ on(event: keyof HookRegistry<Shop>, cb: HookRegistry<Shop>[keyof HookRegistry<Shop>]): void;
10
+ publish(event: keyof HookRegistry<Shop>, ...args: Parameters<HookRegistry<Shop>[keyof HookRegistry<Shop>]>): Promise<void>;
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,UAAU,YAAY,CAAC,IAAI,SAAS,aAAa;IAChD,WAAW,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE;AAED,qBAAa,KAAK,CAAC,IAAI,SAAS,aAAa,GAAG,aAAa;IAC5D,OAAO,CAAC,cAAc,CAGlB;IAEJ,YAAY,CAAC,KAAK,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,GAAG,OAAO;IAItD,EAAE,CACD,KAAK,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,EAC/B,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IAS3C,OAAO,CACZ,KAAK,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,EAC/B,GAAG,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,GAC/D,OAAO,CAAC,IAAI,CAAC;CAehB"}
@@ -0,0 +1,25 @@
1
+ export class Hooks {
2
+ eventListeners = new Map();
3
+ hasListeners(event) {
4
+ return this.eventListeners.has(event);
5
+ }
6
+ on(event, cb) {
7
+ if (!this.eventListeners.has(event)) {
8
+ this.eventListeners.set(event, []);
9
+ }
10
+ this.eventListeners.get(event)?.push(cb);
11
+ }
12
+ async publish(event, ...args) {
13
+ const events = this.eventListeners.get(event);
14
+ if (!events) {
15
+ return;
16
+ }
17
+ for (const cb of events) {
18
+ const res = cb(...args);
19
+ if (res instanceof Promise) {
20
+ await res;
21
+ }
22
+ }
23
+ }
24
+ }
25
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,KAAK;IACT,cAAc,GAAG,IAAI,GAAG,EAG7B,CAAC;IAEJ,YAAY,CAAC,KAA+B;QAC3C,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,EAAE,CACD,KAA+B,EAC/B,EAAgD;QAEhD,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpC,CAAC;QAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,OAAO,CACZ,KAA+B,EAC/B,GAAG,IAA8D;QAEjE,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAE9C,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,OAAO;QACR,CAAC;QAED,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE,CAAC;YACzB,MAAM,GAAG,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YAExB,IAAI,GAAG,YAAY,OAAO,EAAE,CAAC;gBAC5B,MAAM,GAAG,CAAC;YACX,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { ShopAuthroizeEvent } from \"./registration.js\";\nimport type { ShopInterface } from \"./repository.js\";\n\ninterface HookRegistry<Shop extends ShopInterface> {\n\tonAuthorize: (event: ShopAuthroizeEvent<Shop>) => Promise<void>;\n}\n\nexport class Hooks<Shop extends ShopInterface = ShopInterface> {\n\tprivate eventListeners = new Map<\n\t\tkeyof HookRegistry<Shop>,\n\t\tHookRegistry<Shop>[keyof HookRegistry<Shop>][]\n\t>();\n\n\thasListeners(event: keyof HookRegistry<Shop>): boolean {\n\t\treturn this.eventListeners.has(event);\n\t}\n\n\ton(\n\t\tevent: keyof HookRegistry<Shop>,\n\t\tcb: HookRegistry<Shop>[keyof HookRegistry<Shop>],\n\t) {\n\t\tif (!this.eventListeners.has(event)) {\n\t\t\tthis.eventListeners.set(event, []);\n\t\t}\n\n\t\tthis.eventListeners.get(event)?.push(cb);\n\t}\n\n\tasync publish(\n\t\tevent: keyof HookRegistry<Shop>,\n\t\t...args: Parameters<HookRegistry<Shop>[keyof HookRegistry<Shop>]>\n\t): Promise<void> {\n\t\tconst events = this.eventListeners.get(event);\n\n\t\tif (!events) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const cb of events) {\n\t\t\tconst res = cb(...args);\n\n\t\t\tif (res instanceof Promise) {\n\t\t\t\tawait res;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/http-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;GAEG;AACH,qBAAa,UAAU;IAGV,OAAO,CAAC,IAAI;IAFxB,OAAO,CAAC,OAAO,CAAmD;gBAE9C,IAAI,EAAE,aAAa;IAOvC;;OAEG;IACG,GAAG,CAAC,YAAY,EACrB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GA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  async request(method, url, body = "", headers = {}) {
57
57
  const f = await globalThis.fetch(`${this.shop.getShopUrl()}/api${url}`, {
58
+ redirect: "manual",
58
59
  body,
59
60
  headers: Object.assign({
60
61
  Authorization: `Bearer ${await this.getToken()}`,
61
62
  }, headers),
62
63
  method,
63
64
  });
65
+ if (f.status === 301 || f.status === 302) {
66
+ throw new ApiClientRequestFailed(this.shop.getShopId(), new HttpClientResponse(f.status, {
67
+ errors: [
68
+ {
69
+ code: "301",
70
+ status: "301",
71
+ title: "301",
72
+ detail: "Got a redirect response from the URL, the URL should point to the Shop without redirect",
73
+ },
74
+ ],
75
+ }, f.headers));
76
+ }
64
77
  // Obtain new token
65
78
  if (!f.ok && f.status === 401) {
66
79
  this.storage.expiresIn = null;
@@ -81,6 +94,7 @@ export class HttpClient {
81
94
  if (this.storage.expiresIn === null) {
82
95
  const auth = await globalThis.fetch(`${this.shop.getShopUrl()}/api/oauth/token`, {
83
96
  method: "POST",
97
+ redirect: "manual",
84
98
  headers: {
85
99
  "content-type": "application/json",
86
100
  },
@@ -90,6 +104,18 @@ export class HttpClient {
90
104
  client_secret: this.shop.getShopClientSecret(),
91
105
  }),
92
106
  });
107
+ if (auth.status === 301 || auth.status === 302) {
108
+ throw new ApiClientRequestFailed(this.shop.getShopId(), new HttpClientResponse(auth.status, {
109
+ errors: [
110
+ {
111
+ code: "301",
112
+ status: "301",
113
+ title: "301",
114
+ detail: "Got a redirect response from the URL, the URL should point to the Shop without redirect",
115
+ },
116
+ ],
117
+ }, auth.headers));
118
+ }
93
119
  if (!auth.ok) {
94
120
  const contentType = auth.headers.get("content-type") || "text/plain";
95
121
  let body = "";