@shopware-ag/app-server-sdk 1.1.0 → 1.1.2

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 (117) hide show
  1. package/dist/commonjs/helper/admin-api.d.ts +56 -0
  2. package/dist/commonjs/helper/admin-api.d.ts.map +1 -0
  3. package/dist/commonjs/helper/admin-api.js +126 -0
  4. package/dist/commonjs/helper/admin-api.js.map +1 -0
  5. package/dist/commonjs/helper/criteria.d.ts +377 -0
  6. package/dist/commonjs/helper/criteria.d.ts.map +1 -0
  7. package/dist/commonjs/helper/criteria.js +456 -0
  8. package/dist/commonjs/helper/criteria.js.map +1 -0
  9. package/dist/commonjs/http-client.js +2 -1
  10. package/dist/commonjs/http-client.js.map +1 -1
  11. package/dist/commonjs/integration/better-sqlite3.d.ts +11 -0
  12. package/dist/commonjs/integration/better-sqlite3.d.ts.map +1 -0
  13. package/dist/commonjs/integration/better-sqlite3.js +58 -0
  14. package/dist/commonjs/integration/better-sqlite3.js.map +1 -0
  15. package/dist/esm/helper/admin-api.d.ts +56 -0
  16. package/dist/esm/helper/admin-api.d.ts.map +1 -0
  17. package/dist/esm/helper/admin-api.js +117 -0
  18. package/dist/esm/helper/admin-api.js.map +1 -0
  19. package/dist/esm/helper/criteria.d.ts +377 -0
  20. package/dist/esm/helper/criteria.d.ts.map +1 -0
  21. package/dist/esm/helper/criteria.js +452 -0
  22. package/dist/esm/helper/criteria.js.map +1 -0
  23. package/dist/esm/http-client.js +2 -1
  24. package/dist/esm/http-client.js.map +1 -1
  25. package/dist/esm/integration/better-sqlite3.d.ts +11 -0
  26. package/dist/esm/integration/better-sqlite3.d.ts.map +1 -0
  27. package/dist/esm/integration/better-sqlite3.js +51 -0
  28. package/dist/esm/integration/better-sqlite3.js.map +1 -0
  29. package/package.json +206 -141
  30. package/dist/commonjs/context-resolver.test.d.ts +0 -2
  31. package/dist/commonjs/context-resolver.test.d.ts.map +0 -1
  32. package/dist/commonjs/context-resolver.test.js +0 -81
  33. package/dist/commonjs/context-resolver.test.js.map +0 -1
  34. package/dist/commonjs/helper/app-actions.test.d.ts +0 -2
  35. package/dist/commonjs/helper/app-actions.test.d.ts.map +0 -1
  36. package/dist/commonjs/helper/app-actions.test.js +0 -31
  37. package/dist/commonjs/helper/app-actions.test.js.map +0 -1
  38. package/dist/commonjs/http-client.test.d.ts +0 -2
  39. package/dist/commonjs/http-client.test.d.ts.map +0 -1
  40. package/dist/commonjs/http-client.test.js +0 -71
  41. package/dist/commonjs/http-client.test.js.map +0 -1
  42. package/dist/commonjs/integration/bun-sqlite.test.d.ts +0 -2
  43. package/dist/commonjs/integration/bun-sqlite.test.d.ts.map +0 -1
  44. package/dist/commonjs/integration/bun-sqlite.test.js +0 -24
  45. package/dist/commonjs/integration/bun-sqlite.test.js.map +0 -1
  46. package/dist/commonjs/integration/cloudflare.test.d.ts +0 -2
  47. package/dist/commonjs/integration/cloudflare.test.d.ts.map +0 -1
  48. package/dist/commonjs/integration/cloudflare.test.js +0 -39
  49. package/dist/commonjs/integration/cloudflare.test.js.map +0 -1
  50. package/dist/commonjs/integration/deno.test.d.ts +0 -2
  51. package/dist/commonjs/integration/deno.test.d.ts.map +0 -1
  52. package/dist/commonjs/integration/deno.test.js +0 -48
  53. package/dist/commonjs/integration/deno.test.js.map +0 -1
  54. package/dist/commonjs/integration/dynamodb.test.d.ts +0 -2
  55. package/dist/commonjs/integration/dynamodb.test.d.ts.map +0 -1
  56. package/dist/commonjs/integration/dynamodb.test.js +0 -132
  57. package/dist/commonjs/integration/dynamodb.test.js.map +0 -1
  58. package/dist/commonjs/integration/hono.test.d.ts +0 -2
  59. package/dist/commonjs/integration/hono.test.d.ts.map +0 -1
  60. package/dist/commonjs/integration/hono.test.js +0 -86
  61. package/dist/commonjs/integration/hono.test.js.map +0 -1
  62. package/dist/commonjs/registration.test.d.ts +0 -2
  63. package/dist/commonjs/registration.test.d.ts.map +0 -1
  64. package/dist/commonjs/registration.test.js +0 -59
  65. package/dist/commonjs/registration.test.js.map +0 -1
  66. package/dist/commonjs/repository.test.d.ts +0 -2
  67. package/dist/commonjs/repository.test.d.ts.map +0 -1
  68. package/dist/commonjs/repository.test.js +0 -32
  69. package/dist/commonjs/repository.test.js.map +0 -1
  70. package/dist/commonjs/signer.test.d.ts +0 -2
  71. package/dist/commonjs/signer.test.d.ts.map +0 -1
  72. package/dist/commonjs/signer.test.js +0 -25
  73. package/dist/commonjs/signer.test.js.map +0 -1
  74. package/dist/esm/context-resolver.test.d.ts +0 -2
  75. package/dist/esm/context-resolver.test.d.ts.map +0 -1
  76. package/dist/esm/context-resolver.test.js +0 -79
  77. package/dist/esm/context-resolver.test.js.map +0 -1
  78. package/dist/esm/helper/app-actions.test.d.ts +0 -2
  79. package/dist/esm/helper/app-actions.test.d.ts.map +0 -1
  80. package/dist/esm/helper/app-actions.test.js +0 -29
  81. package/dist/esm/helper/app-actions.test.js.map +0 -1
  82. package/dist/esm/http-client.test.d.ts +0 -2
  83. package/dist/esm/http-client.test.d.ts.map +0 -1
  84. package/dist/esm/http-client.test.js +0 -69
  85. package/dist/esm/http-client.test.js.map +0 -1
  86. package/dist/esm/integration/bun-sqlite.test.d.ts +0 -2
  87. package/dist/esm/integration/bun-sqlite.test.d.ts.map +0 -1
  88. package/dist/esm/integration/bun-sqlite.test.js +0 -22
  89. package/dist/esm/integration/bun-sqlite.test.js.map +0 -1
  90. package/dist/esm/integration/cloudflare.test.d.ts +0 -2
  91. package/dist/esm/integration/cloudflare.test.d.ts.map +0 -1
  92. package/dist/esm/integration/cloudflare.test.js +0 -37
  93. package/dist/esm/integration/cloudflare.test.js.map +0 -1
  94. package/dist/esm/integration/deno.test.d.ts +0 -2
  95. package/dist/esm/integration/deno.test.d.ts.map +0 -1
  96. package/dist/esm/integration/deno.test.js +0 -46
  97. package/dist/esm/integration/deno.test.js.map +0 -1
  98. package/dist/esm/integration/dynamodb.test.d.ts +0 -2
  99. package/dist/esm/integration/dynamodb.test.d.ts.map +0 -1
  100. package/dist/esm/integration/dynamodb.test.js +0 -130
  101. package/dist/esm/integration/dynamodb.test.js.map +0 -1
  102. package/dist/esm/integration/hono.test.d.ts +0 -2
  103. package/dist/esm/integration/hono.test.d.ts.map +0 -1
  104. package/dist/esm/integration/hono.test.js +0 -84
  105. package/dist/esm/integration/hono.test.js.map +0 -1
  106. package/dist/esm/registration.test.d.ts +0 -2
  107. package/dist/esm/registration.test.d.ts.map +0 -1
  108. package/dist/esm/registration.test.js +0 -57
  109. package/dist/esm/registration.test.js.map +0 -1
  110. package/dist/esm/repository.test.d.ts +0 -2
  111. package/dist/esm/repository.test.d.ts.map +0 -1
  112. package/dist/esm/repository.test.js +0 -30
  113. package/dist/esm/repository.test.js.map +0 -1
  114. package/dist/esm/signer.test.d.ts +0 -2
  115. package/dist/esm/signer.test.d.ts.map +0 -1
  116. package/dist/esm/signer.test.js +0 -23
  117. package/dist/esm/signer.test.js.map +0 -1
@@ -1,79 +0,0 @@
1
- import { describe, expect, jest, test } from "bun:test";
2
- import { AppServer } from "../src/app.js";
3
- import { ContextResolver } from "../src/context-resolver.js";
4
- import { InMemoryShopRepository } from "../src/repository.js";
5
- describe("Context Resolver", async () => {
6
- const app = new AppServer({
7
- appName: "test",
8
- appSecret: "test",
9
- authorizeCallbackUrl: "test",
10
- }, new InMemoryShopRepository());
11
- await app.repository.createShop("blaa", "test", "test");
12
- const contextResolver = new ContextResolver(app);
13
- test("fromBrowser: shop does not exist", async () => {
14
- expect(contextResolver.fromBrowser(new Request("https://example.com/?shop-id=test&shopware-shop-signature=aaa"))).rejects.toThrowError("Cannot find shop by id test");
15
- });
16
- test("fromBrowser: missing header", async () => {
17
- expect(contextResolver.fromBrowser(new Request("https://example.com/?shop-id=blaa"))).rejects.toThrowError("Missing shopware-shop-signature query parameter");
18
- });
19
- test("fromBrowser: shop exists", async () => {
20
- app.signer.verifyGetRequest = jest.fn().mockResolvedValue(true);
21
- const context = await contextResolver.fromBrowser(new Request("https://example.com/?shop-id=blaa&shopware-shop-signature=aaa"));
22
- expect(context.payload).toEqual({
23
- "shop-id": "blaa",
24
- "shopware-shop-signature": "aaa",
25
- });
26
- });
27
- test("fromSource: missing signature header", async () => {
28
- expect(contextResolver.fromAPI(new Request("https://example.com/", {
29
- body: JSON.stringify({
30
- source: {
31
- shopId: "blaa",
32
- },
33
- }),
34
- }))).rejects.toThrowError("Missing shopware-shop-signature header");
35
- });
36
- test("fromSource: shop does not exists", async () => {
37
- expect(contextResolver.fromAPI(new Request("https://example.com/", {
38
- headers: {
39
- "shopware-shop-signature": "aaa",
40
- },
41
- body: JSON.stringify({
42
- source: {
43
- shopId: "test",
44
- },
45
- }),
46
- }))).rejects.toThrowError("Cannot find shop by id test");
47
- });
48
- test("fromSource: invalid signature", async () => {
49
- expect(contextResolver.fromAPI(new Request("https://example.com/", {
50
- headers: {
51
- "shopware-shop-signature": "aaa",
52
- },
53
- body: JSON.stringify({
54
- source: {
55
- shopId: "blaa",
56
- },
57
- }),
58
- }))).rejects.toThrowError("Invalid signature");
59
- });
60
- test("fromSource: resolved", async () => {
61
- app.signer.verify = jest.fn().mockResolvedValue(true);
62
- const ctx = await contextResolver.fromAPI(new Request("https://example.com/", {
63
- headers: {
64
- "shopware-shop-signature": "aaa",
65
- },
66
- body: JSON.stringify({
67
- source: {
68
- shopId: "blaa",
69
- },
70
- }),
71
- }));
72
- expect(ctx.payload).toEqual({
73
- source: {
74
- shopId: "blaa",
75
- },
76
- });
77
- });
78
- });
79
- //# sourceMappingURL=context-resolver.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-resolver.test.js","sourceRoot":"","sources":["../../src/context-resolver.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,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QAEtD,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,OAAO,CACxC,IAAI,OAAO,CAAC,sBAAsB,EAAE;YACnC,OAAO,EAAE;gBACR,yBAAyB,EAAE,KAAK;aAChC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACpB,MAAM,EAAE;oBACP,MAAM,EAAE,MAAM;iBACd;aACD,CAAC;SACF,CAAC,CACF,CAAC;QAEF,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;YAC3B,MAAM,EAAE;gBACP,MAAM,EAAE,MAAM;aACd;SACD,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, jest, test } from \"bun:test\";\nimport { AppServer } from \"../src/app.js\";\nimport { ContextResolver } from \"../src/context-resolver.js\";\nimport { InMemoryShopRepository, SimpleShop } from \"../src/repository.js\";\n\ndescribe(\"Context Resolver\", async () => {\n\tconst app = new AppServer(\n\t\t{\n\t\t\tappName: \"test\",\n\t\t\tappSecret: \"test\",\n\t\t\tauthorizeCallbackUrl: \"test\",\n\t\t},\n\t\tnew InMemoryShopRepository(),\n\t);\n\n\tawait app.repository.createShop(\"blaa\", \"test\", \"test\");\n\n\tconst contextResolver = new ContextResolver(app);\n\n\ttest(\"fromBrowser: shop does not exist\", async () => {\n\t\texpect(\n\t\t\tcontextResolver.fromBrowser(\n\t\t\t\tnew Request(\n\t\t\t\t\t\"https://example.com/?shop-id=test&shopware-shop-signature=aaa\",\n\t\t\t\t),\n\t\t\t),\n\t\t).rejects.toThrowError(\"Cannot find shop by id test\");\n\t});\n\n\ttest(\"fromBrowser: missing header\", async () => {\n\t\texpect(\n\t\t\tcontextResolver.fromBrowser(\n\t\t\t\tnew Request(\"https://example.com/?shop-id=blaa\"),\n\t\t\t),\n\t\t).rejects.toThrowError(\"Missing shopware-shop-signature query parameter\");\n\t});\n\n\ttest(\"fromBrowser: shop exists\", async () => {\n\t\tapp.signer.verifyGetRequest = jest.fn().mockResolvedValue(true);\n\n\t\tconst context = await contextResolver.fromBrowser(\n\t\t\tnew Request(\n\t\t\t\t\"https://example.com/?shop-id=blaa&shopware-shop-signature=aaa\",\n\t\t\t),\n\t\t);\n\n\t\texpect(context.payload).toEqual({\n\t\t\t\"shop-id\": \"blaa\",\n\t\t\t\"shopware-shop-signature\": \"aaa\",\n\t\t});\n\t});\n\n\ttest(\"fromSource: missing signature header\", async () => {\n\t\texpect(\n\t\t\tcontextResolver.fromAPI(\n\t\t\t\tnew Request(\"https://example.com/\", {\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\tshopId: \"blaa\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t),\n\t\t).rejects.toThrowError(\"Missing shopware-shop-signature header\");\n\t});\n\n\ttest(\"fromSource: shop does not exists\", async () => {\n\t\texpect(\n\t\t\tcontextResolver.fromAPI(\n\t\t\t\tnew Request(\"https://example.com/\", {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"shopware-shop-signature\": \"aaa\",\n\t\t\t\t\t},\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\tshopId: \"test\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t),\n\t\t).rejects.toThrowError(\"Cannot find shop by id test\");\n\t});\n\n\ttest(\"fromSource: invalid signature\", async () => {\n\t\texpect(\n\t\t\tcontextResolver.fromAPI(\n\t\t\t\tnew Request(\"https://example.com/\", {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"shopware-shop-signature\": \"aaa\",\n\t\t\t\t\t},\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\tshopId: \"blaa\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t),\n\t\t).rejects.toThrowError(\"Invalid signature\");\n\t});\n\n\ttest(\"fromSource: resolved\", async () => {\n\t\tapp.signer.verify = jest.fn().mockResolvedValue(true);\n\n\t\tconst ctx = await contextResolver.fromAPI(\n\t\t\tnew Request(\"https://example.com/\", {\n\t\t\t\theaders: {\n\t\t\t\t\t\"shopware-shop-signature\": \"aaa\",\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tsource: {\n\t\t\t\t\t\tshopId: \"blaa\",\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t}),\n\t\t);\n\n\t\texpect(ctx.payload).toEqual({\n\t\t\tsource: {\n\t\t\t\tshopId: \"blaa\",\n\t\t\t},\n\t\t});\n\t});\n});\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=app-actions.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-actions.test.d.ts","sourceRoot":"","sources":["../../../src/helper/app-actions.test.ts"],"names":[],"mappings":""}
@@ -1,29 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { createModalResponse, createNewTabResponse, createNotificationResponse, } from "../../src/helper/app-actions.js";
3
- describe("AppActions", async () => {
4
- test("createNewTabResponse", async () => {
5
- const resp = createNewTabResponse("test");
6
- expect(resp.headers.get("content-type")).toBe("application/json");
7
- expect(await resp.text()).toBe(JSON.stringify({
8
- actionType: "openNewTab",
9
- payload: { redirectUrl: "test" },
10
- }));
11
- });
12
- test("createNotificationResponse", async () => {
13
- const resp = createNotificationResponse("success", "test");
14
- expect(resp.headers.get("content-type")).toBe("application/json");
15
- expect(await resp.text()).toBe(JSON.stringify({
16
- actionType: "notification",
17
- payload: { status: "success", message: "test" },
18
- }));
19
- });
20
- test("createModalResponse", async () => {
21
- const resp = createModalResponse("test", "small", true);
22
- expect(resp.headers.get("content-type")).toBe("application/json");
23
- expect(await resp.text()).toBe(JSON.stringify({
24
- actionType: "openModal",
25
- payload: { iframeUrl: "test", size: "small", expand: true },
26
- }));
27
- });
28
- });
29
- //# sourceMappingURL=app-actions.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-actions.test.js","sourceRoot":"","sources":["../../../src/helper/app-actions.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACN,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,GAC1B,MAAM,iCAAiC,CAAC;AAEzC,QAAQ,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;IACjC,IAAI,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,IAAI,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAE1C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClE,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAC7B,IAAI,CAAC,SAAS,CAAC;YACd,UAAU,EAAE,YAAY;YACxB,OAAO,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE;SAChC,CAAC,CACF,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,IAAI,GAAG,0BAA0B,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAE3D,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClE,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAC7B,IAAI,CAAC,SAAS,CAAC;YACd,UAAU,EAAE,cAAc;YAC1B,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE;SAC/C,CAAC,CACF,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAExD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClE,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAC7B,IAAI,CAAC,SAAS,CAAC;YACd,UAAU,EAAE,WAAW;YACvB,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE;SAC3D,CAAC,CACF,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport {\n\tcreateModalResponse,\n\tcreateNewTabResponse,\n\tcreateNotificationResponse,\n} from \"../../src/helper/app-actions.js\";\n\ndescribe(\"AppActions\", async () => {\n\ttest(\"createNewTabResponse\", async () => {\n\t\tconst resp = createNewTabResponse(\"test\");\n\n\t\texpect(resp.headers.get(\"content-type\")).toBe(\"application/json\");\n\t\texpect(await resp.text()).toBe(\n\t\t\tJSON.stringify({\n\t\t\t\tactionType: \"openNewTab\",\n\t\t\t\tpayload: { redirectUrl: \"test\" },\n\t\t\t}),\n\t\t);\n\t});\n\n\ttest(\"createNotificationResponse\", async () => {\n\t\tconst resp = createNotificationResponse(\"success\", \"test\");\n\n\t\texpect(resp.headers.get(\"content-type\")).toBe(\"application/json\");\n\t\texpect(await resp.text()).toBe(\n\t\t\tJSON.stringify({\n\t\t\t\tactionType: \"notification\",\n\t\t\t\tpayload: { status: \"success\", message: \"test\" },\n\t\t\t}),\n\t\t);\n\t});\n\n\ttest(\"createModalResponse\", async () => {\n\t\tconst resp = createModalResponse(\"test\", \"small\", true);\n\n\t\texpect(resp.headers.get(\"content-type\")).toBe(\"application/json\");\n\t\texpect(await resp.text()).toBe(\n\t\t\tJSON.stringify({\n\t\t\t\tactionType: \"openModal\",\n\t\t\t\tpayload: { iframeUrl: \"test\", size: \"small\", expand: true },\n\t\t\t}),\n\t\t);\n\t});\n});\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=http-client.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-client.test.d.ts","sourceRoot":"","sources":["../../src/http-client.test.ts"],"names":[],"mappings":""}
@@ -1,69 +0,0 @@
1
- import { describe, expect, spyOn, test } from "bun:test";
2
- import { HttpClient } from "../src/http-client.js";
3
- import { SimpleShop } from "../src/repository.js";
4
- describe("HTTP Client", async () => {
5
- test("getToken", async () => {
6
- const mockFetch = spyOn(global, "fetch").mockImplementation(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": 3600}')));
7
- const client = new HttpClient(new SimpleShop("blaa", "test", "test"));
8
- expect(client.getToken()).resolves.toBe("test");
9
- // We fetched already once the token, so the second time we should get it from the storage
10
- await client.getToken();
11
- expect(mockFetch.mock.calls).toBeArrayOfSize(1);
12
- mockFetch.mockRestore();
13
- });
14
- test("getToken: failed request", async () => {
15
- const mockFetch = spyOn(global, "fetch").mockImplementation(() => Promise.resolve(new Response('{"error": "invalid_grant"}', { status: 400 })));
16
- const client = new HttpClient(new SimpleShop("blaa", "test", "test"));
17
- expect(client.getToken()).rejects.toThrowError("The api client authentication to shop with id: blaa");
18
- mockFetch.mockRestore();
19
- });
20
- test("getToken: expired refetch", async () => {
21
- const mockFetch = spyOn(global, "fetch").mockImplementation(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": -500}')));
22
- const client = new HttpClient(new SimpleShop("blaa", "test", "test"));
23
- expect(client.getToken()).resolves.toBe("test");
24
- expect(mockFetch.mock.calls).toBeArrayOfSize(1);
25
- expect(client.getToken()).resolves.toBe("test");
26
- expect(mockFetch.mock.calls).toBeArrayOfSize(2);
27
- mockFetch.mockRestore();
28
- });
29
- test("get, post, put, patch, delete", async () => {
30
- const mockFetch = spyOn(global, "fetch").mockImplementationOnce(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": 5000}')));
31
- const client = new HttpClient(new SimpleShop("blaa", "test", "test"));
32
- mockFetch.mockImplementation(() => Promise.resolve(new Response('{"data": "test"}')));
33
- expect(client.get("/test")).resolves.toEqual({
34
- body: { data: "test" },
35
- headers: new Headers(),
36
- statusCode: 200,
37
- });
38
- expect(client.post("/test", { data: "test" })).resolves.toEqual({
39
- body: { data: "test" },
40
- headers: new Headers(),
41
- statusCode: 200,
42
- });
43
- expect(client.put("/test", { data: "test" })).resolves.toEqual({
44
- body: { data: "test" },
45
- headers: new Headers(),
46
- statusCode: 200,
47
- });
48
- expect(client.patch("/test", { data: "test" })).resolves.toEqual({
49
- body: { data: "test" },
50
- headers: new Headers(),
51
- statusCode: 200,
52
- });
53
- expect(client.delete("/test")).resolves.toEqual({
54
- body: { data: "test" },
55
- headers: new Headers(),
56
- statusCode: 200,
57
- });
58
- expect(mockFetch.mock.calls).toBeArrayOfSize(6);
59
- mockFetch.mockRestore();
60
- });
61
- test("get: request failed", async () => {
62
- const mockFetch = spyOn(global, "fetch").mockImplementationOnce(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": 5000}')));
63
- const client = new HttpClient(new SimpleShop("blaa", "test", "test"));
64
- mockFetch.mockImplementation(() => Promise.resolve(new Response('{"data": "test"}', { status: 400 })));
65
- expect(client.get("/test")).rejects.toThrowError("The api request failed with status code: 400 for shop with id: blaa");
66
- mockFetch.mockRestore();
67
- });
68
- });
69
- //# sourceMappingURL=http-client.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-client.test.js","sourceRoot":"","sources":["../../src/http-client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,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UAAU,EAAE,GAAG;SACf,CAAC,CAAC;QAEH,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAEhD,SAAS,CAAC,WAAW,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,sBAAsB,CAAC,GAAG,EAAE,CACpE,OAAO,CAAC,OAAO,CACd,IAAI,QAAQ,CAAC,8CAA8C,CAAC,CAC5D,CACD,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAEtE,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,CACjC,OAAO,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAClE,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAC/C,qEAAqE,CACrE,CAAC;QAEF,SAAS,CAAC,WAAW,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, spyOn, test } from \"bun:test\";\nimport { HttpClient } from \"../src/http-client.js\";\nimport { SimpleShop } from \"../src/repository.js\";\n\ndescribe(\"HTTP Client\", async () => {\n\ttest(\"getToken\", async () => {\n\t\tconst mockFetch = spyOn(global, \"fetch\").mockImplementation(() =>\n\t\t\tPromise.resolve(\n\t\t\t\tnew Response('{\"access_token\": \"test\", \"expires_in\": 3600}'),\n\t\t\t),\n\t\t);\n\n\t\tconst client = new HttpClient(new SimpleShop(\"blaa\", \"test\", \"test\"));\n\t\texpect(client.getToken()).resolves.toBe(\"test\");\n\n\t\t// We fetched already once the token, so the second time we should get it from the storage\n\t\tawait client.getToken();\n\n\t\texpect(mockFetch.mock.calls).toBeArrayOfSize(1);\n\n\t\tmockFetch.mockRestore();\n\t});\n\n\ttest(\"getToken: failed request\", async () => {\n\t\tconst mockFetch = spyOn(global, \"fetch\").mockImplementation(() =>\n\t\t\tPromise.resolve(\n\t\t\t\tnew Response('{\"error\": \"invalid_grant\"}', { status: 400 }),\n\t\t\t),\n\t\t);\n\n\t\tconst client = new HttpClient(new SimpleShop(\"blaa\", \"test\", \"test\"));\n\t\texpect(client.getToken()).rejects.toThrowError(\n\t\t\t\"The api client authentication to shop with id: blaa\",\n\t\t);\n\n\t\tmockFetch.mockRestore();\n\t});\n\n\ttest(\"getToken: expired refetch\", async () => {\n\t\tconst mockFetch = spyOn(global, \"fetch\").mockImplementation(() =>\n\t\t\tPromise.resolve(\n\t\t\t\tnew Response('{\"access_token\": \"test\", \"expires_in\": -500}'),\n\t\t\t),\n\t\t);\n\n\t\tconst client = new HttpClient(new SimpleShop(\"blaa\", \"test\", \"test\"));\n\t\texpect(client.getToken()).resolves.toBe(\"test\");\n\n\t\texpect(mockFetch.mock.calls).toBeArrayOfSize(1);\n\n\t\texpect(client.getToken()).resolves.toBe(\"test\");\n\n\t\texpect(mockFetch.mock.calls).toBeArrayOfSize(2);\n\n\t\tmockFetch.mockRestore();\n\t});\n\n\ttest(\"get, post, put, patch, delete\", async () => {\n\t\tconst mockFetch = spyOn(global, \"fetch\").mockImplementationOnce(() =>\n\t\t\tPromise.resolve(\n\t\t\t\tnew Response('{\"access_token\": \"test\", \"expires_in\": 5000}'),\n\t\t\t),\n\t\t);\n\n\t\tconst client = new HttpClient(new SimpleShop(\"blaa\", \"test\", \"test\"));\n\n\t\tmockFetch.mockImplementation(() =>\n\t\t\tPromise.resolve(new Response('{\"data\": \"test\"}')),\n\t\t);\n\n\t\texpect(client.get(\"/test\")).resolves.toEqual({\n\t\t\tbody: { data: \"test\" },\n\t\t\theaders: new Headers(),\n\t\t\tstatusCode: 200,\n\t\t});\n\t\texpect(client.post(\"/test\", { data: \"test\" })).resolves.toEqual({\n\t\t\tbody: { data: \"test\" },\n\t\t\theaders: new Headers(),\n\t\t\tstatusCode: 200,\n\t\t});\n\t\texpect(client.put(\"/test\", { data: \"test\" })).resolves.toEqual({\n\t\t\tbody: { data: \"test\" },\n\t\t\theaders: new Headers(),\n\t\t\tstatusCode: 200,\n\t\t});\n\t\texpect(client.patch(\"/test\", { data: \"test\" })).resolves.toEqual({\n\t\t\tbody: { data: \"test\" },\n\t\t\theaders: new Headers(),\n\t\t\tstatusCode: 200,\n\t\t});\n\t\texpect(client.delete(\"/test\")).resolves.toEqual({\n\t\t\tbody: { data: \"test\" },\n\t\t\theaders: new Headers(),\n\t\t\tstatusCode: 200,\n\t\t});\n\n\t\texpect(mockFetch.mock.calls).toBeArrayOfSize(6);\n\n\t\tmockFetch.mockRestore();\n\t});\n\n\ttest(\"get: request failed\", async () => {\n\t\tconst mockFetch = spyOn(global, \"fetch\").mockImplementationOnce(() =>\n\t\t\tPromise.resolve(\n\t\t\t\tnew Response('{\"access_token\": \"test\", \"expires_in\": 5000}'),\n\t\t\t),\n\t\t);\n\n\t\tconst client = new HttpClient(new SimpleShop(\"blaa\", \"test\", \"test\"));\n\n\t\tmockFetch.mockImplementation(() =>\n\t\t\tPromise.resolve(new Response('{\"data\": \"test\"}', { status: 400 })),\n\t\t);\n\n\t\texpect(client.get(\"/test\")).rejects.toThrowError(\n\t\t\t\"The api request failed with status code: 400 for shop with id: blaa\",\n\t\t);\n\n\t\tmockFetch.mockRestore();\n\t});\n});\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=bun-sqlite.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bun-sqlite.test.d.ts","sourceRoot":"","sources":["../../../src/integration/bun-sqlite.test.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { SimpleShop } from "../repository.js";
3
- import { BunSqliteRepository } from "./bun-sqlite.js";
4
- describe("Bun SQLite", async () => {
5
- test("createShop", async () => {
6
- const repo = new BunSqliteRepository(":memory:");
7
- await repo.createShop("test", "test", "test");
8
- const shop = await repo.getShopById("test");
9
- expect(shop).not.toBeNull();
10
- expect(shop?.getShopId()).toBe("test");
11
- expect(shop?.getShopUrl()).toBe("test");
12
- expect(shop?.getShopSecret()).toBe("test");
13
- await repo.deleteShop("test");
14
- expect(repo.getShopById("test")).resolves.toBeNull();
15
- await repo.createShop("test", "test", "test");
16
- expect(repo.getShopById("test")).resolves.not.toBeNull();
17
- await repo.updateShop(new SimpleShop("test", "foo.com", "test"));
18
- const updatedShop = await repo.getShopById("test");
19
- expect(updatedShop?.getShopUrl()).toBe("foo.com");
20
- });
21
- });
22
- //# sourceMappingURL=bun-sqlite.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bun-sqlite.test.js","sourceRoot":"","sources":["../../../src/integration/bun-sqlite.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,QAAQ,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;IACjC,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,IAAI,GAAG,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAEjD,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAE9C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE5C,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAE5B,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACxC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3C,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAE9B,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAErD,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAE9C,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAEzD,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;QAEjE,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAEnD,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { SimpleShop } from \"../repository.js\";\nimport { BunSqliteRepository } from \"./bun-sqlite.js\";\n\ndescribe(\"Bun SQLite\", async () => {\n\ttest(\"createShop\", async () => {\n\t\tconst repo = new BunSqliteRepository(\":memory:\");\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\tconst shop = await repo.getShopById(\"test\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\texpect(shop?.getShopId()).toBe(\"test\");\n\t\texpect(shop?.getShopUrl()).toBe(\"test\");\n\t\texpect(shop?.getShopSecret()).toBe(\"test\");\n\n\t\tawait repo.deleteShop(\"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\n\t\tawait repo.updateShop(new SimpleShop(\"test\", \"foo.com\", \"test\"));\n\n\t\tconst updatedShop = await repo.getShopById(\"test\");\n\n\t\texpect(updatedShop?.getShopUrl()).toBe(\"foo.com\");\n\t});\n});\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=cloudflare.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloudflare.test.d.ts","sourceRoot":"","sources":["../../../src/integration/cloudflare.test.ts"],"names":[],"mappings":""}
@@ -1,37 +0,0 @@
1
- //
2
- import { describe, expect, test } from "bun:test";
3
- import { CloudflareShopRepository } from "../../src/integration/cloudflare-kv.js";
4
- import { SimpleShop } from "../../src/repository.js";
5
- describe("Cloudflare", async () => {
6
- test("createShop", async () => {
7
- const repo = new CloudflareShopRepository(new MockedKVNamespace());
8
- await repo.createShop("test", "test", "test");
9
- const shop = await repo.getShopById("test");
10
- expect(shop).not.toBeNull();
11
- expect(shop?.getShopId()).toBe("test");
12
- expect(shop?.getShopUrl()).toBe("test");
13
- expect(shop?.getShopSecret()).toBe("test");
14
- await repo.deleteShop("test");
15
- expect(repo.getShopById("test")).resolves.toBeNull();
16
- await repo.updateShop(new SimpleShop("test", "test", "test"));
17
- expect(repo.getShopById("test")).resolves.not.toBeNull();
18
- });
19
- });
20
- class MockedKVNamespace {
21
- storage;
22
- constructor() {
23
- this.storage = new Map();
24
- }
25
- get(key, options) {
26
- return Promise.resolve(this.storage.get(key) || null);
27
- }
28
- put(key, value, options) {
29
- this.storage.set(key, value);
30
- return Promise.resolve();
31
- }
32
- delete(key) {
33
- this.storage.delete(key);
34
- return Promise.resolve();
35
- }
36
- }
37
- //# sourceMappingURL=cloudflare.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloudflare.test.js","sourceRoot":"","sources":["../../../src/integration/cloudflare.test.ts"],"names":[],"mappings":"AAAA,EAAE;AACF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,QAAQ,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;IACjC,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,IAAI,GAAG,IAAI,wBAAwB,CACxC,IAAI,iBAAiB,EAA4B,CACjD,CAAC;QAEF,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAE9C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE5C,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAE5B,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACxC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3C,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAE9B,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAErD,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAE9D,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,iBAAiB;IACtB,OAAO,CAAsB;IAC7B;QACC,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1B,CAAC;IAED,GAAG,CACF,GAAW,EACX,OAAmD;QAEnD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,GAAG,CACF,GAAW,EACX,KAA8D,EAC9D,OAA+B;QAE/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAe,CAAC,CAAC;QACvC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,CAAC,GAAW;QACjB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACzB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;CACD","sourcesContent":["//\nimport { describe, expect, test } from \"bun:test\";\nimport { CloudflareShopRepository } from \"../../src/integration/cloudflare-kv.js\";\nimport { SimpleShop } from \"../../src/repository.js\";\n\ndescribe(\"Cloudflare\", async () => {\n\ttest(\"createShop\", async () => {\n\t\tconst repo = new CloudflareShopRepository(\n\t\t\tnew MockedKVNamespace() as unknown as KVNamespace,\n\t\t);\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\tconst shop = await repo.getShopById(\"test\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\texpect(shop?.getShopId()).toBe(\"test\");\n\t\texpect(shop?.getShopUrl()).toBe(\"test\");\n\t\texpect(shop?.getShopSecret()).toBe(\"test\");\n\n\t\tawait repo.deleteShop(\"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repo.updateShop(new SimpleShop(\"test\", \"test\", \"test\"));\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\t});\n});\n\nclass MockedKVNamespace {\n\tstorage: Map<string, string>;\n\tconstructor() {\n\t\tthis.storage = new Map();\n\t}\n\n\tget(\n\t\tkey: string,\n\t\toptions?: Partial<KVNamespaceGetOptions<undefined>>,\n\t): Promise<string | null> {\n\t\treturn Promise.resolve(this.storage.get(key) || null);\n\t}\n\tput(\n\t\tkey: string,\n\t\tvalue: string | ArrayBuffer | ArrayBufferView | ReadableStream,\n\t\toptions?: KVNamespacePutOptions,\n\t): Promise<void> {\n\t\tthis.storage.set(key, value as string);\n\t\treturn Promise.resolve();\n\t}\n\tdelete(key: string): Promise<void> {\n\t\tthis.storage.delete(key);\n\t\treturn Promise.resolve();\n\t}\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=deno.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deno.test.d.ts","sourceRoot":"","sources":["../../../src/integration/deno.test.ts"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- import { describe, expect, test } from "bun:test";
2
- import { SimpleShop } from "../repository.js";
3
- import { DenoKVRepository } from "./deno-kv.js";
4
- describe("Deno", async () => {
5
- const kv = {
6
- storage: new Map(),
7
- set(key, value) {
8
- this.storage.set(key.join(""), value);
9
- },
10
- get(key) {
11
- if (!this.storage.has(key.join(""))) {
12
- return {
13
- key: null,
14
- value: null,
15
- };
16
- }
17
- return Promise.resolve({
18
- key: key.join(""),
19
- value: this.storage.get(key.join("")),
20
- });
21
- },
22
- delete(key) {
23
- this.storage.delete(key.join(""));
24
- },
25
- };
26
- // @ts-ignore
27
- globalThis.Deno = {
28
- openKv() {
29
- return Promise.resolve(kv);
30
- },
31
- };
32
- test("test repository", async () => {
33
- const repo = new DenoKVRepository();
34
- await repo.createShop("test", "test", "test");
35
- const shop = await repo.getShopById("test");
36
- expect(shop).not.toBeNull();
37
- expect(shop?.getShopId()).toBe("test");
38
- expect(shop?.getShopUrl()).toBe("test");
39
- expect(shop?.getShopSecret()).toBe("test");
40
- await repo.deleteShop("test");
41
- expect(repo.getShopById("test")).resolves.toBeNull();
42
- await repo.updateShop(new SimpleShop("test", "test", "test"));
43
- expect(repo.getShopById("test")).resolves.not.toBeNull();
44
- });
45
- });
46
- //# sourceMappingURL=deno.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deno.test.js","sourceRoot":"","sources":["../../../src/integration/deno.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,QAAQ,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;IAC3B,MAAM,EAAE,GAAG;QACV,OAAO,EAAE,IAAI,GAAG,EAAE;QAClB,GAAG,CAAC,GAAa,EAAE,KAAa;YAC/B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,GAAG,CAAC,GAAa;YAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;gBACrC,OAAO;oBACN,GAAG,EAAE,IAAI;oBACT,KAAK,EAAE,IAAI;iBACX,CAAC;YACH,CAAC;YAED,OAAO,OAAO,CAAC,OAAO,CAAC;gBACtB,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aACr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CAAC;IAC1D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { SimpleShop } from \"../repository.js\";\nimport { DenoKVRepository } from \"./deno-kv.js\";\n\ndescribe(\"Deno\", async () => {\n\tconst kv = {\n\t\tstorage: new Map(),\n\t\tset(key: string[], value: string) {\n\t\t\tthis.storage.set(key.join(\"\"), value);\n\t\t},\n\n\t\tget(key: string[]) {\n\t\t\tif (!this.storage.has(key.join(\"\"))) {\n\t\t\t\treturn {\n\t\t\t\t\tkey: null,\n\t\t\t\t\tvalue: null,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn Promise.resolve({\n\t\t\t\tkey: key.join(\"\"),\n\t\t\t\tvalue: this.storage.get(key.join(\"\")),\n\t\t\t});\n\t\t},\n\n\t\tdelete(key: string[]) {\n\t\t\tthis.storage.delete(key.join(\"\"));\n\t\t},\n\t};\n\n\t// @ts-ignore\n\tglobalThis.Deno = {\n\t\topenKv() {\n\t\t\treturn Promise.resolve(kv);\n\t\t},\n\t};\n\n\ttest(\"test repository\", async () => {\n\t\tconst repo = new DenoKVRepository();\n\n\t\tawait repo.createShop(\"test\", \"test\", \"test\");\n\n\t\tconst shop = await repo.getShopById(\"test\");\n\n\t\texpect(shop).not.toBeNull();\n\n\t\texpect(shop?.getShopId()).toBe(\"test\");\n\t\texpect(shop?.getShopUrl()).toBe(\"test\");\n\t\texpect(shop?.getShopSecret()).toBe(\"test\");\n\n\t\tawait repo.deleteShop(\"test\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\n\t\tawait repo.updateShop(new SimpleShop(\"test\", \"test\", \"test\"));\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\t});\n});\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=dynamodb.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamodb.test.d.ts","sourceRoot":"","sources":["../../../src/integration/dynamodb.test.ts"],"names":[],"mappings":""}
@@ -1,130 +0,0 @@
1
- import { describe, expect, mock, test } from "bun:test";
2
- import { DynamoDBRepository } from "./dynamodb.js";
3
- import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
4
- import { SimpleShop } from "../repository.js";
5
- describe("DynamoDB", async () => {
6
- test("getShopById does not exists", async () => {
7
- mock.module("@aws-sdk/lib-dynamodb", () => {
8
- return {
9
- DynamoDBDocumentClient: {
10
- from() {
11
- return {
12
- async send() {
13
- return {};
14
- },
15
- };
16
- },
17
- },
18
- };
19
- });
20
- const repo = new DynamoDBRepository(new DynamoDBClient(), "foo");
21
- expect(repo.getShopById("test")).resolves.toBeNull();
22
- });
23
- test("getShopById exists", async () => {
24
- mock.module("@aws-sdk/lib-dynamodb", () => {
25
- return {
26
- DynamoDBDocumentClient: {
27
- from() {
28
- return {
29
- async send() {
30
- return {
31
- Item: {
32
- id: "a",
33
- url: "b",
34
- secret: "c",
35
- },
36
- };
37
- },
38
- };
39
- },
40
- },
41
- };
42
- });
43
- const repo = new DynamoDBRepository(new DynamoDBClient(), "foo");
44
- expect(repo.getShopById("test")).resolves.not.toBeNull();
45
- });
46
- test("createShop", async () => {
47
- let cmd;
48
- mock.module("@aws-sdk/lib-dynamodb", () => {
49
- return {
50
- DynamoDBDocumentClient: {
51
- from() {
52
- return {
53
- async send(inner) {
54
- cmd = inner;
55
- return {};
56
- },
57
- };
58
- },
59
- },
60
- };
61
- });
62
- const repo = new DynamoDBRepository(new DynamoDBClient(), "foo");
63
- await repo.createShop("a", "b", "c");
64
- // @ts-expect-error
65
- expect(cmd).toBeDefined();
66
- // @ts-expect-error
67
- expect(cmd.input.Item).toEqual({
68
- id: "a",
69
- active: true,
70
- url: "b",
71
- secret: "c",
72
- clientId: null,
73
- clientSecret: null,
74
- });
75
- });
76
- test("updateShop", async () => {
77
- let cmd;
78
- mock.module("@aws-sdk/lib-dynamodb", () => {
79
- return {
80
- DynamoDBDocumentClient: {
81
- from() {
82
- return {
83
- async send(inner) {
84
- cmd = inner;
85
- return {};
86
- },
87
- };
88
- },
89
- },
90
- };
91
- });
92
- const repo = new DynamoDBRepository(new DynamoDBClient(), "foo");
93
- await repo.updateShop(new SimpleShop("a", "b", "c"));
94
- // @ts-expect-error
95
- expect(cmd).toBeDefined();
96
- // @ts-expect-error
97
- expect(cmd.input.Item).toEqual({
98
- id: "a",
99
- active: true,
100
- url: "b",
101
- secret: "c",
102
- clientId: null,
103
- clientSecret: null,
104
- });
105
- });
106
- test("deleteShop", async () => {
107
- let cmd;
108
- mock.module("@aws-sdk/lib-dynamodb", () => {
109
- return {
110
- DynamoDBDocumentClient: {
111
- from() {
112
- return {
113
- async send(inner) {
114
- cmd = inner;
115
- return {};
116
- },
117
- };
118
- },
119
- },
120
- };
121
- });
122
- const repo = new DynamoDBRepository(new DynamoDBClient(), "foo");
123
- await repo.deleteShop("a");
124
- // @ts-expect-error
125
- expect(cmd).toBeDefined();
126
- // @ts-expect-error
127
- expect(cmd.input.Key).toEqual({ id: "a" });
128
- });
129
- });
130
- //# sourceMappingURL=dynamodb.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamodb.test.js","sourceRoot":"","sources":["../../../src/integration/dynamodb.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,QAAQ,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE;IAC/B,IAAI,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC9C,IAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,GAAG,EAAE;YACzC,OAAO;gBACN,sBAAsB,EAAE;oBACvB,IAAI;w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M,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;YAC9B,EAAE,EAAE,GAAG;YACP,MAAM,EAAE,IAAI;YACZ,GAAG,EAAE,GAAG;YACR,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,IAAI;SAClB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC7B,IAAI,GAAkB,CAAC;QAEvB,IAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,GAAG,EAAE;YACzC,OAAO;gBACN,sBAAsB,EAAE;oBACvB,IAAI;wBACH,OAAO;4BACN,KAAK,CAAC,IAAI,CAAC,KAAoB;gCAC9B,GAAG,GAAG,KAAK,CAAC;gCACZ,OAAO,EAAE,CAAC;4BACX,CAAC;yBACD,CAAC;oBACH,CAAC;iBACD;aACD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,IAAI,kBAAkB,CAAC,IAAI,cAAc,EAAE,EAAE,KAAK,CAAC,CAAC;QAEjE,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAE3B,mBAAmB;QACnB,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1B,mBAAmB;QACnB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, mock, test } from \"bun:test\";\nimport { DynamoDBRepository } from \"./dynamodb.js\";\n\nimport { DynamoDBClient } from \"@aws-sdk/client-dynamodb\";\nimport type { DeleteCommand, PutCommand } from \"@aws-sdk/lib-dynamodb\";\nimport { SimpleShop } from \"../repository.js\";\n\ndescribe(\"DynamoDB\", async () => {\n\ttest(\"getShopById does not exists\", async () => {\n\t\tmock.module(\"@aws-sdk/lib-dynamodb\", () => {\n\t\t\treturn {\n\t\t\t\tDynamoDBDocumentClient: {\n\t\t\t\t\tfrom() {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tasync send() {\n\t\t\t\t\t\t\t\treturn {};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tconst repo = new DynamoDBRepository(new DynamoDBClient(), \"foo\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.toBeNull();\n\t});\n\n\ttest(\"getShopById exists\", async () => {\n\t\tmock.module(\"@aws-sdk/lib-dynamodb\", () => {\n\t\t\treturn {\n\t\t\t\tDynamoDBDocumentClient: {\n\t\t\t\t\tfrom() {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tasync send() {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tItem: {\n\t\t\t\t\t\t\t\t\t\tid: \"a\",\n\t\t\t\t\t\t\t\t\t\turl: \"b\",\n\t\t\t\t\t\t\t\t\t\tsecret: \"c\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tconst repo = new DynamoDBRepository(new DynamoDBClient(), \"foo\");\n\n\t\texpect(repo.getShopById(\"test\")).resolves.not.toBeNull();\n\t});\n\n\ttest(\"createShop\", async () => {\n\t\tlet cmd: PutCommand;\n\n\t\tmock.module(\"@aws-sdk/lib-dynamodb\", () => {\n\t\t\treturn {\n\t\t\t\tDynamoDBDocumentClient: {\n\t\t\t\t\tfrom() {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tasync send(inner: PutCommand) {\n\t\t\t\t\t\t\t\tcmd = inner;\n\t\t\t\t\t\t\t\treturn {};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tconst repo = new DynamoDBRepository(new DynamoDBClient(), \"foo\");\n\n\t\tawait repo.createShop(\"a\", \"b\", \"c\");\n\n\t\t// @ts-expect-error\n\t\texpect(cmd).toBeDefined();\n\t\t// @ts-expect-error\n\t\texpect(cmd.input.Item).toEqual({\n\t\t\tid: \"a\",\n\t\t\tactive: true,\n\t\t\turl: \"b\",\n\t\t\tsecret: \"c\",\n\t\t\tclientId: null,\n\t\t\tclientSecret: null,\n\t\t});\n\t});\n\n\ttest(\"updateShop\", async () => {\n\t\tlet cmd: PutCommand;\n\n\t\tmock.module(\"@aws-sdk/lib-dynamodb\", () => {\n\t\t\treturn {\n\t\t\t\tDynamoDBDocumentClient: {\n\t\t\t\t\tfrom() {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tasync send(inner: PutCommand) {\n\t\t\t\t\t\t\t\tcmd = inner;\n\t\t\t\t\t\t\t\treturn {};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tconst repo = new DynamoDBRepository(new DynamoDBClient(), \"foo\");\n\n\t\tawait repo.updateShop(new SimpleShop(\"a\", \"b\", \"c\"));\n\n\t\t// @ts-expect-error\n\t\texpect(cmd).toBeDefined();\n\t\t// @ts-expect-error\n\t\texpect(cmd.input.Item).toEqual({\n\t\t\tid: \"a\",\n\t\t\tactive: true,\n\t\t\turl: \"b\",\n\t\t\tsecret: \"c\",\n\t\t\tclientId: null,\n\t\t\tclientSecret: null,\n\t\t});\n\t});\n\n\ttest(\"deleteShop\", async () => {\n\t\tlet cmd: DeleteCommand;\n\n\t\tmock.module(\"@aws-sdk/lib-dynamodb\", () => {\n\t\t\treturn {\n\t\t\t\tDynamoDBDocumentClient: {\n\t\t\t\t\tfrom() {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tasync send(inner: DeleteCommand) {\n\t\t\t\t\t\t\t\tcmd = inner;\n\t\t\t\t\t\t\t\treturn {};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\tconst repo = new DynamoDBRepository(new DynamoDBClient(), \"foo\");\n\n\t\tawait repo.deleteShop(\"a\");\n\n\t\t// @ts-expect-error\n\t\texpect(cmd).toBeDefined();\n\t\t// @ts-expect-error\n\t\texpect(cmd.input.Key).toEqual({ id: \"a\" });\n\t});\n});\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=hono.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hono.test.d.ts","sourceRoot":"","sources":["../../../src/integration/hono.test.ts"],"names":[],"mappings":""}