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

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 (97) hide show
  1. package/dist/commonjs/integration/better-sqlite3.d.ts +11 -0
  2. package/dist/commonjs/integration/better-sqlite3.d.ts.map +1 -0
  3. package/dist/commonjs/integration/better-sqlite3.js +58 -0
  4. package/dist/commonjs/integration/better-sqlite3.js.map +1 -0
  5. package/dist/esm/integration/better-sqlite3.d.ts +11 -0
  6. package/dist/esm/integration/better-sqlite3.d.ts.map +1 -0
  7. package/dist/esm/integration/better-sqlite3.js +51 -0
  8. package/dist/esm/integration/better-sqlite3.js.map +1 -0
  9. package/package.json +173 -141
  10. package/dist/commonjs/context-resolver.test.d.ts +0 -2
  11. package/dist/commonjs/context-resolver.test.d.ts.map +0 -1
  12. package/dist/commonjs/context-resolver.test.js +0 -81
  13. package/dist/commonjs/context-resolver.test.js.map +0 -1
  14. package/dist/commonjs/helper/app-actions.test.d.ts +0 -2
  15. package/dist/commonjs/helper/app-actions.test.d.ts.map +0 -1
  16. package/dist/commonjs/helper/app-actions.test.js +0 -31
  17. package/dist/commonjs/helper/app-actions.test.js.map +0 -1
  18. package/dist/commonjs/http-client.test.d.ts +0 -2
  19. package/dist/commonjs/http-client.test.d.ts.map +0 -1
  20. package/dist/commonjs/http-client.test.js +0 -71
  21. package/dist/commonjs/http-client.test.js.map +0 -1
  22. package/dist/commonjs/integration/bun-sqlite.test.d.ts +0 -2
  23. package/dist/commonjs/integration/bun-sqlite.test.d.ts.map +0 -1
  24. package/dist/commonjs/integration/bun-sqlite.test.js +0 -24
  25. package/dist/commonjs/integration/bun-sqlite.test.js.map +0 -1
  26. package/dist/commonjs/integration/cloudflare.test.d.ts +0 -2
  27. package/dist/commonjs/integration/cloudflare.test.d.ts.map +0 -1
  28. package/dist/commonjs/integration/cloudflare.test.js +0 -39
  29. package/dist/commonjs/integration/cloudflare.test.js.map +0 -1
  30. package/dist/commonjs/integration/deno.test.d.ts +0 -2
  31. package/dist/commonjs/integration/deno.test.d.ts.map +0 -1
  32. package/dist/commonjs/integration/deno.test.js +0 -48
  33. package/dist/commonjs/integration/deno.test.js.map +0 -1
  34. package/dist/commonjs/integration/dynamodb.test.d.ts +0 -2
  35. package/dist/commonjs/integration/dynamodb.test.d.ts.map +0 -1
  36. package/dist/commonjs/integration/dynamodb.test.js +0 -132
  37. package/dist/commonjs/integration/dynamodb.test.js.map +0 -1
  38. package/dist/commonjs/integration/hono.test.d.ts +0 -2
  39. package/dist/commonjs/integration/hono.test.d.ts.map +0 -1
  40. package/dist/commonjs/integration/hono.test.js +0 -86
  41. package/dist/commonjs/integration/hono.test.js.map +0 -1
  42. package/dist/commonjs/registration.test.d.ts +0 -2
  43. package/dist/commonjs/registration.test.d.ts.map +0 -1
  44. package/dist/commonjs/registration.test.js +0 -59
  45. package/dist/commonjs/registration.test.js.map +0 -1
  46. package/dist/commonjs/repository.test.d.ts +0 -2
  47. package/dist/commonjs/repository.test.d.ts.map +0 -1
  48. package/dist/commonjs/repository.test.js +0 -32
  49. package/dist/commonjs/repository.test.js.map +0 -1
  50. package/dist/commonjs/signer.test.d.ts +0 -2
  51. package/dist/commonjs/signer.test.d.ts.map +0 -1
  52. package/dist/commonjs/signer.test.js +0 -25
  53. package/dist/commonjs/signer.test.js.map +0 -1
  54. package/dist/esm/context-resolver.test.d.ts +0 -2
  55. package/dist/esm/context-resolver.test.d.ts.map +0 -1
  56. package/dist/esm/context-resolver.test.js +0 -79
  57. package/dist/esm/context-resolver.test.js.map +0 -1
  58. package/dist/esm/helper/app-actions.test.d.ts +0 -2
  59. package/dist/esm/helper/app-actions.test.d.ts.map +0 -1
  60. package/dist/esm/helper/app-actions.test.js +0 -29
  61. package/dist/esm/helper/app-actions.test.js.map +0 -1
  62. package/dist/esm/http-client.test.d.ts +0 -2
  63. package/dist/esm/http-client.test.d.ts.map +0 -1
  64. package/dist/esm/http-client.test.js +0 -69
  65. package/dist/esm/http-client.test.js.map +0 -1
  66. package/dist/esm/integration/bun-sqlite.test.d.ts +0 -2
  67. package/dist/esm/integration/bun-sqlite.test.d.ts.map +0 -1
  68. package/dist/esm/integration/bun-sqlite.test.js +0 -22
  69. package/dist/esm/integration/bun-sqlite.test.js.map +0 -1
  70. package/dist/esm/integration/cloudflare.test.d.ts +0 -2
  71. package/dist/esm/integration/cloudflare.test.d.ts.map +0 -1
  72. package/dist/esm/integration/cloudflare.test.js +0 -37
  73. package/dist/esm/integration/cloudflare.test.js.map +0 -1
  74. package/dist/esm/integration/deno.test.d.ts +0 -2
  75. package/dist/esm/integration/deno.test.d.ts.map +0 -1
  76. package/dist/esm/integration/deno.test.js +0 -46
  77. package/dist/esm/integration/deno.test.js.map +0 -1
  78. package/dist/esm/integration/dynamodb.test.d.ts +0 -2
  79. package/dist/esm/integration/dynamodb.test.d.ts.map +0 -1
  80. package/dist/esm/integration/dynamodb.test.js +0 -130
  81. package/dist/esm/integration/dynamodb.test.js.map +0 -1
  82. package/dist/esm/integration/hono.test.d.ts +0 -2
  83. package/dist/esm/integration/hono.test.d.ts.map +0 -1
  84. package/dist/esm/integration/hono.test.js +0 -84
  85. package/dist/esm/integration/hono.test.js.map +0 -1
  86. package/dist/esm/registration.test.d.ts +0 -2
  87. package/dist/esm/registration.test.d.ts.map +0 -1
  88. package/dist/esm/registration.test.js +0 -57
  89. package/dist/esm/registration.test.js.map +0 -1
  90. package/dist/esm/repository.test.d.ts +0 -2
  91. package/dist/esm/repository.test.d.ts.map +0 -1
  92. package/dist/esm/repository.test.js +0 -30
  93. package/dist/esm/repository.test.js.map +0 -1
  94. package/dist/esm/signer.test.d.ts +0 -2
  95. package/dist/esm/signer.test.d.ts.map +0 -1
  96. package/dist/esm/signer.test.js +0 -23
  97. package/dist/esm/signer.test.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-actions.test.js","sourceRoot":"","sources":["../../../src/helper/app-actions.test.ts"],"names":[],"mapp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AAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClE,IAAA,iBAAM,EAAC,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,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const bun_test_1 = require("bun:test");
4
- const http_client_js_1 = require("../src/http-client.js");
5
- const repository_js_1 = require("../src/repository.js");
6
- (0, bun_test_1.describe)("HTTP Client", async () => {
7
- (0, bun_test_1.test)("getToken", async () => {
8
- const mockFetch = (0, bun_test_1.spyOn)(global, "fetch").mockImplementation(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": 3600}')));
9
- const client = new http_client_js_1.HttpClient(new repository_js_1.SimpleShop("blaa", "test", "test"));
10
- (0, bun_test_1.expect)(client.getToken()).resolves.toBe("test");
11
- // We fetched already once the token, so the second time we should get it from the storage
12
- await client.getToken();
13
- (0, bun_test_1.expect)(mockFetch.mock.calls).toBeArrayOfSize(1);
14
- mockFetch.mockRestore();
15
- });
16
- (0, bun_test_1.test)("getToken: failed request", async () => {
17
- const mockFetch = (0, bun_test_1.spyOn)(global, "fetch").mockImplementation(() => Promise.resolve(new Response('{"error": "invalid_grant"}', { status: 400 })));
18
- const client = new http_client_js_1.HttpClient(new repository_js_1.SimpleShop("blaa", "test", "test"));
19
- (0, bun_test_1.expect)(client.getToken()).rejects.toThrowError("The api client authentication to shop with id: blaa");
20
- mockFetch.mockRestore();
21
- });
22
- (0, bun_test_1.test)("getToken: expired refetch", async () => {
23
- const mockFetch = (0, bun_test_1.spyOn)(global, "fetch").mockImplementation(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": -500}')));
24
- const client = new http_client_js_1.HttpClient(new repository_js_1.SimpleShop("blaa", "test", "test"));
25
- (0, bun_test_1.expect)(client.getToken()).resolves.toBe("test");
26
- (0, bun_test_1.expect)(mockFetch.mock.calls).toBeArrayOfSize(1);
27
- (0, bun_test_1.expect)(client.getToken()).resolves.toBe("test");
28
- (0, bun_test_1.expect)(mockFetch.mock.calls).toBeArrayOfSize(2);
29
- mockFetch.mockRestore();
30
- });
31
- (0, bun_test_1.test)("get, post, put, patch, delete", async () => {
32
- const mockFetch = (0, bun_test_1.spyOn)(global, "fetch").mockImplementationOnce(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": 5000}')));
33
- const client = new http_client_js_1.HttpClient(new repository_js_1.SimpleShop("blaa", "test", "test"));
34
- mockFetch.mockImplementation(() => Promise.resolve(new Response('{"data": "test"}')));
35
- (0, bun_test_1.expect)(client.get("/test")).resolves.toEqual({
36
- body: { data: "test" },
37
- headers: new Headers(),
38
- statusCode: 200,
39
- });
40
- (0, bun_test_1.expect)(client.post("/test", { data: "test" })).resolves.toEqual({
41
- body: { data: "test" },
42
- headers: new Headers(),
43
- statusCode: 200,
44
- });
45
- (0, bun_test_1.expect)(client.put("/test", { data: "test" })).resolves.toEqual({
46
- body: { data: "test" },
47
- headers: new Headers(),
48
- statusCode: 200,
49
- });
50
- (0, bun_test_1.expect)(client.patch("/test", { data: "test" })).resolves.toEqual({
51
- body: { data: "test" },
52
- headers: new Headers(),
53
- statusCode: 200,
54
- });
55
- (0, bun_test_1.expect)(client.delete("/test")).resolves.toEqual({
56
- body: { data: "test" },
57
- headers: new Headers(),
58
- statusCode: 200,
59
- });
60
- (0, bun_test_1.expect)(mockFetch.mock.calls).toBeArrayOfSize(6);
61
- mockFetch.mockRestore();
62
- });
63
- (0, bun_test_1.test)("get: request failed", async () => {
64
- const mockFetch = (0, bun_test_1.spyOn)(global, "fetch").mockImplementationOnce(() => Promise.resolve(new Response('{"access_token": "test", "expires_in": 5000}')));
65
- const client = new http_client_js_1.HttpClient(new repository_js_1.SimpleShop("blaa", "test", "test"));
66
- mockFetch.mockImplementation(() => Promise.resolve(new Response('{"data": "test"}', { status: 400 })));
67
- (0, bun_test_1.expect)(client.get("/test")).rejects.toThrowError("The api request failed with status code: 400 for shop with id: blaa");
68
- mockFetch.mockRestore();
69
- });
70
- });
71
- //# 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,uCAAyD;AACzD,0DAAmD;AACnD,wDAAkD;AAElD,IAAA,mBAAQ,EAAC,aAAa,EAAE,KAAK,IAAI,EAAE;IAClC,IAAA,eAAI,EAAC,UAAU,EAAE,KAAK,IAAI,EAAE;QAC3B,MAAM,SAAS,GAAG,IAAA,gBAAK,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAChE,OAAO,CAAC,OAAO,CACd,IAAI,QAAQ,CAAC,8CAA8C,CAAC,CAC5D,CACD,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,2BAAU,CAAC,IAAI,0BAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACtE,IAAA,iBAAM,EAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEhD,0FAA0F;QAC1F,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QAExB,IAAA,iBAAM,EAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAEhD,SAAS,CAAC,WAAW,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,IAAA,eAAI,EAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,SAAS,GAAG,IAAA,gBAAK,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAChE,OAAO,CAAC,OAAO,CACd,IAAI,QAAQ,CAAC,4BAA4B,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAC3D,CACD,CAAC;QAEF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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,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const bun_test_1 = require("bun:test");
4
- const repository_js_1 = require("../repository.js");
5
- const bun_sqlite_js_1 = require("./bun-sqlite.js");
6
- (0, bun_test_1.describe)("Bun SQLite", async () => {
7
- (0, bun_test_1.test)("createShop", async () => {
8
- const repo = new bun_sqlite_js_1.BunSqliteRepository(":memory:");
9
- await repo.createShop("test", "test", "test");
10
- const shop = await repo.getShopById("test");
11
- (0, bun_test_1.expect)(shop).not.toBeNull();
12
- (0, bun_test_1.expect)(shop?.getShopId()).toBe("test");
13
- (0, bun_test_1.expect)(shop?.getShopUrl()).toBe("test");
14
- (0, bun_test_1.expect)(shop?.getShopSecret()).toBe("test");
15
- await repo.deleteShop("test");
16
- (0, bun_test_1.expect)(repo.getShopById("test")).resolves.toBeNull();
17
- await repo.createShop("test", "test", "test");
18
- (0, bun_test_1.expect)(repo.getShopById("test")).resolves.not.toBeNull();
19
- await repo.updateShop(new repository_js_1.SimpleShop("test", "foo.com", "test"));
20
- const updatedShop = await repo.getShopById("test");
21
- (0, bun_test_1.expect)(updatedShop?.getShopUrl()).toBe("foo.com");
22
- });
23
- });
24
- //# 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,uCAAkD;AAClD,oDAA8C;AAC9C,mDAAsD;AAEtD,IA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C,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,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //
4
- const bun_test_1 = require("bun:test");
5
- const cloudflare_kv_js_1 = require("../../src/integration/cloudflare-kv.js");
6
- const repository_js_1 = require("../../src/repository.js");
7
- (0, bun_test_1.describe)("Cloudflare", async () => {
8
- (0, bun_test_1.test)("createShop", async () => {
9
- const repo = new cloudflare_kv_js_1.CloudflareShopRepository(new MockedKVNamespace());
10
- await repo.createShop("test", "test", "test");
11
- const shop = await repo.getShopById("test");
12
- (0, bun_test_1.expect)(shop).not.toBeNull();
13
- (0, bun_test_1.expect)(shop?.getShopId()).toBe("test");
14
- (0, bun_test_1.expect)(shop?.getShopUrl()).toBe("test");
15
- (0, bun_test_1.expect)(shop?.getShopSecret()).toBe("test");
16
- await repo.deleteShop("test");
17
- (0, bun_test_1.expect)(repo.getShopById("test")).resolves.toBeNull();
18
- await repo.updateShop(new repository_js_1.SimpleShop("test", "test", "test"));
19
- (0, bun_test_1.expect)(repo.getShopById("test")).resolves.not.toBeNull();
20
- });
21
- });
22
- class MockedKVNamespace {
23
- storage;
24
- constructor() {
25
- this.storage = new Map();
26
- }
27
- get(key, options) {
28
- return Promise.resolve(this.storage.get(key) || null);
29
- }
30
- put(key, value, options) {
31
- this.storage.set(key, value);
32
- return Promise.resolve();
33
- }
34
- delete(key) {
35
- this.storage.delete(key);
36
- return Promise.resolve();
37
- }
38
- }
39
- //# 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,uCAAkD;AAClD,6EAAkF;AAClF,2DAAqD;AAErD,IAAA,mBAAQ,EAAC,YAAY,EAAE,KAAK,IAAI,EAAE;IACjC,IAAA,eAAI,EAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,IAAI,GAAG,IAAI,2CAAwB,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,IAAA,iBAAM,EAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC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,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,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const bun_test_1 = require("bun:test");
4
- const repository_js_1 = require("../repository.js");
5
- const deno_kv_js_1 = require("./deno-kv.js");
6
- (0, bun_test_1.describe)("Deno", async () => {
7
- const kv = {
8
- storage: new Map(),
9
- set(key, value) {
10
- this.storage.set(key.join(""), value);
11
- },
12
- get(key) {
13
- if (!this.storage.has(key.join(""))) {
14
- return {
15
- key: null,
16
- value: null,
17
- };
18
- }
19
- return Promise.resolve({
20
- key: key.join(""),
21
- value: this.storage.get(key.join("")),
22
- });
23
- },
24
- delete(key) {
25
- this.storage.delete(key.join(""));
26
- },
27
- };
28
- // @ts-ignore
29
- globalThis.Deno = {
30
- openKv() {
31
- return Promise.resolve(kv);
32
- },
33
- };
34
- (0, bun_test_1.test)("test repository", async () => {
35
- const repo = new deno_kv_js_1.DenoKVRepository();
36
- await repo.createShop("test", "test", "test");
37
- const shop = await repo.getShopById("test");
38
- (0, bun_test_1.expect)(shop).not.toBeNull();
39
- (0, bun_test_1.expect)(shop?.getShopId()).toBe("test");
40
- (0, bun_test_1.expect)(shop?.getShopUrl()).toBe("test");
41
- (0, bun_test_1.expect)(shop?.getShopSecret()).toBe("test");
42
- await repo.deleteShop("test");
43
- (0, bun_test_1.expect)(repo.getShopById("test")).resolves.toBeNull();
44
- await repo.updateShop(new repository_js_1.SimpleShop("test", "test", "test"));
45
- (0, bun_test_1.expect)(repo.getShopById("test")).resolves.not.toBeNull();
46
- });
47
- });
48
- //# 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,uCAAkD;AAClD,oDAA8C;AAC9C,6CAAgD;AAEhD,IAAA,mBAAQ,EAAC,MAAM,EAAE,KAAK,IAAI,EAAE;IAC3B,MAAM,EAAE,GAAG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AA,iBAAM,EAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,IAAA,iBAAM,EAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACxC,IAAA,iBAAM,EAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3C,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAE9B,IAAA,iBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAErD,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,0BAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAE9D,IAAA,iBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,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,132 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const bun_test_1 = require("bun:test");
4
- const dynamodb_js_1 = require("./dynamodb.js");
5
- const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
6
- const repository_js_1 = require("../repository.js");
7
- (0, bun_test_1.describe)("DynamoDB", async () => {
8
- (0, bun_test_1.test)("getShopById does not exists", async () => {
9
- bun_test_1.mock.module("@aws-sdk/lib-dynamodb", () => {
10
- return {
11
- DynamoDBDocumentClient: {
12
- from() {
13
- return {
14
- async send() {
15
- return {};
16
- },
17
- };
18
- },
19
- },
20
- };
21
- });
22
- const repo = new dynamodb_js_1.DynamoDBRepository(new client_dynamodb_1.DynamoDBClient(), "foo");
23
- (0, bun_test_1.expect)(repo.getShopById("test")).resolves.toBeNull();
24
- });
25
- (0, bun_test_1.test)("getShopById exists", async () => {
26
- bun_test_1.mock.module("@aws-sdk/lib-dynamodb", () => {
27
- return {
28
- DynamoDBDocumentClient: {
29
- from() {
30
- return {
31
- async send() {
32
- return {
33
- Item: {
34
- id: "a",
35
- url: "b",
36
- secret: "c",
37
- },
38
- };
39
- },
40
- };
41
- },
42
- },
43
- };
44
- });
45
- const repo = new dynamodb_js_1.DynamoDBRepository(new client_dynamodb_1.DynamoDBClient(), "foo");
46
- (0, bun_test_1.expect)(repo.getShopById("test")).resolves.not.toBeNull();
47
- });
48
- (0, bun_test_1.test)("createShop", async () => {
49
- let cmd;
50
- bun_test_1.mock.module("@aws-sdk/lib-dynamodb", () => {
51
- return {
52
- DynamoDBDocumentClient: {
53
- from() {
54
- return {
55
- async send(inner) {
56
- cmd = inner;
57
- return {};
58
- },
59
- };
60
- },
61
- },
62
- };
63
- });
64
- const repo = new dynamodb_js_1.DynamoDBRepository(new client_dynamodb_1.DynamoDBClient(), "foo");
65
- await repo.createShop("a", "b", "c");
66
- // @ts-expect-error
67
- (0, bun_test_1.expect)(cmd).toBeDefined();
68
- // @ts-expect-error
69
- (0, bun_test_1.expect)(cmd.input.Item).toEqual({
70
- id: "a",
71
- active: true,
72
- url: "b",
73
- secret: "c",
74
- clientId: null,
75
- clientSecret: null,
76
- });
77
- });
78
- (0, bun_test_1.test)("updateShop", async () => {
79
- let cmd;
80
- bun_test_1.mock.module("@aws-sdk/lib-dynamodb", () => {
81
- return {
82
- DynamoDBDocumentClient: {
83
- from() {
84
- return {
85
- async send(inner) {
86
- cmd = inner;
87
- return {};
88
- },
89
- };
90
- },
91
- },
92
- };
93
- });
94
- const repo = new dynamodb_js_1.DynamoDBRepository(new client_dynamodb_1.DynamoDBClient(), "foo");
95
- await repo.updateShop(new repository_js_1.SimpleShop("a", "b", "c"));
96
- // @ts-expect-error
97
- (0, bun_test_1.expect)(cmd).toBeDefined();
98
- // @ts-expect-error
99
- (0, bun_test_1.expect)(cmd.input.Item).toEqual({
100
- id: "a",
101
- active: true,
102
- url: "b",
103
- secret: "c",
104
- clientId: null,
105
- clientSecret: null,
106
- });
107
- });
108
- (0, bun_test_1.test)("deleteShop", async () => {
109
- let cmd;
110
- bun_test_1.mock.module("@aws-sdk/lib-dynamodb", () => {
111
- return {
112
- DynamoDBDocumentClient: {
113
- from() {
114
- return {
115
- async send(inner) {
116
- cmd = inner;
117
- return {};
118
- },
119
- };
120
- },
121
- },
122
- };
123
- });
124
- const repo = new dynamodb_js_1.DynamoDBRepository(new client_dynamodb_1.DynamoDBClient(), "foo");
125
- await repo.deleteShop("a");
126
- // @ts-expect-error
127
- (0, bun_test_1.expect)(cmd).toBeDefined();
128
- // @ts-expect-error
129
- (0, bun_test_1.expect)(cmd.input.Key).toEqual({ id: "a" });
130
- });
131
- });
132
- //# 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,uCAAwD;AACxD,+CAAmD;AAEnD,8DAA0D;AAE1D,oDAA8C;AAE9C,IAAA,mBAAQ,EAAC,UAAU,EAAE,KAAK,IAAI,EAAE;IAC/B,IAAA,eAAI,EAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC9C,eAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,GAAG,EAAE;YACzC,OAAO;gBACN,sBAAsB,EAAE;oBACvB,IAAI;wBACH,OAAO;4BACN,KAAK,CAAC,IAAI;gCACT,OAAO,EAAE,CAAC;4BACX,CAAC;yBACD,CAAC;oBACH,CAAC;iBACD;aACD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,IAAI,gCAAkB,CAAC,IAAI,gCAAc,EAAE,EAAE,KAAK,CAAC,CAAC;QAEjE,IAAA,iBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACtD,CAAC,CAAC,CAAC;IA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IAAI,EAAE;QAC7B,IAAI,GAAkB,CAAC;QAEvB,eAAI,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,gCAAkB,CAAC,IAAI,gCAAc,EAAE,EAAE,KAAK,CAAC,CAAC;QAEjE,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAE3B,mBAAmB;QACnB,IAAA,iBAAM,EAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1B,mBAAmB;QACnB,IAAA,iBAAM,EAAC,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":""}
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const bun_test_1 = require("bun:test");
4
- const hono_1 = require("hono");
5
- const repository_js_1 = require("../repository.js");
6
- const hono_js_1 = require("./hono.js");
7
- (0, bun_test_1.describe)("Hono", async () => {
8
- const repo = new repository_js_1.InMemoryShopRepository();
9
- await repo.createShop("a", "a", "a");
10
- (0, bun_test_1.test)("configre by functions", async () => {
11
- const hono = new hono_1.Hono();
12
- (0, hono_js_1.configureAppServer)(hono, {
13
- appName: () => "test",
14
- appSecret: () => "test",
15
- shopRepository: () => repo,
16
- });
17
- const resp = await hono.fetch(new Request("http://localhost/app/register"));
18
- (0, bun_test_1.expect)(resp.status).toBe(400);
19
- });
20
- (0, bun_test_1.test)("register", async () => {
21
- const hono = new hono_1.Hono();
22
- (0, hono_js_1.configureAppServer)(hono, {
23
- appName: "test",
24
- appSecret: "test",
25
- shopRepository: repo,
26
- });
27
- const resp = await hono.fetch(new Request("http://localhost/app/register"));
28
- (0, bun_test_1.expect)(resp.status).toBe(400);
29
- });
30
- (0, bun_test_1.test)("register: success", async () => {
31
- const hono = new hono_1.Hono();
32
- (0, hono_js_1.configureAppServer)(hono, {
33
- appName: "My App",
34
- appSecret: "my-secret",
35
- shopRepository: repo,
36
- });
37
- const resp = await hono.fetch(new Request("http://localhost/app/register?shop-id=123&shop-url=https://my-shop.com&timestamp=1234567890", {
38
- headers: new Headers({
39
- "shopware-app-signature": "96c91f86c822e11444b7a57b54ef125ed86b1a639c5360d45c5397daa8c3f70b",
40
- }),
41
- }));
42
- (0, bun_test_1.expect)(resp.status).toBe(200);
43
- const body = (await resp.json());
44
- (0, bun_test_1.expect)(body).toBeObject();
45
- (0, bun_test_1.expect)(body.proof).not.toBeNull();
46
- });
47
- (0, bun_test_1.test)("registerConfirm", async () => {
48
- const hono = new hono_1.Hono();
49
- (0, hono_js_1.configureAppServer)(hono, {
50
- appName: "test",
51
- appSecret: "test",
52
- shopRepository: repo,
53
- });
54
- const resp = await hono.fetch(new Request("http://localhost/app/register/confirm", {
55
- method: "POST",
56
- body: "{}",
57
- }));
58
- (0, bun_test_1.expect)(resp.status).toBe(400);
59
- });
60
- (0, bun_test_1.test)("signature failure", async () => {
61
- const hono = new hono_1.Hono();
62
- (0, hono_js_1.configureAppServer)(hono, {
63
- appName: "test",
64
- appSecret: "test",
65
- shopRepository: repo,
66
- });
67
- hono.get("/app/test", (c) => c.text("ok"));
68
- const resp = await hono.fetch(new Request("http://localhost/app/test?shopware-shop-signature=invalid&shop-id=a"));
69
- (0, bun_test_1.expect)(resp.status).toBe(400);
70
- (0, bun_test_1.expect)(await resp.text()).toBe('{"message":"Invalid request"}');
71
- });
72
- (0, bun_test_1.test)("signature success", async () => {
73
- const hono = new hono_1.Hono();
74
- (0, hono_js_1.configureAppServer)(hono, {
75
- appName: "test",
76
- appSecret: "test",
77
- shopRepository: repo,
78
- });
79
- hono.get("/app/test", (c) => c.text("ok"));
80
- const resp = await hono.fetch(new Request("http://localhost/app/test?shopware-shop-signature=8b523d99aeef5b456288fcec48236c3367a914c6b2c9fded63d81257ac019b25&shop-id=a"));
81
- (0, bun_test_1.expect)(resp.status).toBe(200);
82
- (0, bun_test_1.expect)(await resp.text()).toBe("ok");
83
- (0, bun_test_1.expect)(resp.headers.get("shopware-app-signature")).toBe("4a43a105ccce57e8e38d4a1f7b3565d743b1e15fb1fec36f41fdf20164fa1c8b");
84
- });
85
- });
86
- //# sourceMappingURL=hono.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hono.test.js","sourceRoot":"","sources":["../../../src/integration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MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAA,iBAAM,EAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CACtD,kEAAkE,CAClE,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { Hono } from \"hono\";\nimport { InMemoryShopRepository } from \"../repository.js\";\nimport { configureAppServer } from \"./hono.js\";\n\ndescribe(\"Hono\", async () => {\n\tconst repo = new InMemoryShopRepository();\n\n\tawait repo.createShop(\"a\", \"a\", \"a\");\n\n\ttest(\"configre by functions\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: () => \"test\",\n\t\t\tappSecret: () => \"test\",\n\t\t\tshopRepository: () => repo,\n\t\t});\n\n\t\tconst resp = await hono.fetch(new Request(\"http://localhost/app/register\"));\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"register\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: \"test\",\n\t\t\tappSecret: \"test\",\n\t\t\tshopRepository: repo,\n\t\t});\n\n\t\tconst resp = await hono.fetch(new Request(\"http://localhost/app/register\"));\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"register: success\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: \"My App\",\n\t\t\tappSecret: \"my-secret\",\n\t\t\tshopRepository: repo,\n\t\t});\n\n\t\tconst resp = await hono.fetch(\n\t\t\tnew Request(\n\t\t\t\t\"http://localhost/app/register?shop-id=123&shop-url=https://my-shop.com&timestamp=1234567890\",\n\t\t\t\t{\n\t\t\t\t\theaders: new Headers({\n\t\t\t\t\t\t\"shopware-app-signature\":\n\t\t\t\t\t\t\t\"96c91f86c822e11444b7a57b54ef125ed86b1a639c5360d45c5397daa8c3f70b\",\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\n\t\texpect(resp.status).toBe(200);\n\n\t\tconst body = (await resp.json()) as { proof: string };\n\n\t\texpect(body).toBeObject();\n\n\t\texpect(body.proof).not.toBeNull();\n\t});\n\n\ttest(\"registerConfirm\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: \"test\",\n\t\t\tappSecret: \"test\",\n\t\t\tshopRepository: repo,\n\t\t});\n\n\t\tconst resp = await hono.fetch(\n\t\t\tnew Request(\"http://localhost/app/register/confirm\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: \"{}\",\n\t\t\t}),\n\t\t);\n\n\t\texpect(resp.status).toBe(400);\n\t});\n\n\ttest(\"signature failure\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: \"test\",\n\t\t\tappSecret: \"test\",\n\t\t\tshopRepository: repo,\n\t\t});\n\n\t\thono.get(\"/app/test\", (c) => c.text(\"ok\"));\n\n\t\tconst resp = await hono.fetch(\n\t\t\tnew Request(\n\t\t\t\t\"http://localhost/app/test?shopware-shop-signature=invalid&shop-id=a\",\n\t\t\t),\n\t\t);\n\n\t\texpect(resp.status).toBe(400);\n\t\texpect(await resp.text()).toBe('{\"message\":\"Invalid request\"}');\n\t});\n\n\ttest(\"signature success\", async () => {\n\t\tconst hono = new Hono();\n\n\t\tconfigureAppServer(hono, {\n\t\t\tappName: \"test\",\n\t\t\tappSecret: \"test\",\n\t\t\tshopRepository: repo,\n\t\t});\n\n\t\thono.get(\"/app/test\", (c) => c.text(\"ok\"));\n\n\t\tconst resp = await hono.fetch(\n\t\t\tnew Request(\n\t\t\t\t\"http://localhost/app/test?shopware-shop-signature=8b523d99aeef5b456288fcec48236c3367a914c6b2c9fded63d81257ac019b25&shop-id=a\",\n\t\t\t),\n\t\t);\n\n\t\texpect(resp.status).toBe(200);\n\t\texpect(await resp.text()).toBe(\"ok\");\n\t\texpect(resp.headers.get(\"shopware-app-signature\")).toBe(\n\t\t\t\"4a43a105ccce57e8e38d4a1f7b3565d743b1e15fb1fec36f41fdf20164fa1c8b\",\n\t\t);\n\t});\n});\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=registration.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registration.test.d.ts","sourceRoot":"","sources":["../../src/registration.test.ts"],"names":[],"mappings":""}
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const bun_test_1 = require("bun:test");
4
- const app_js_1 = require("../src/app.js");
5
- const repository_js_1 = require("../src/repository.js");
6
- (0, bun_test_1.describe)("Registration", async () => {
7
- const app = new app_js_1.AppServer({ appName: "test", appSecret: "test", authorizeCallbackUrl: "test" }, new repository_js_1.InMemoryShopRepository());
8
- (0, bun_test_1.test)("authorize: invalid request", async () => {
9
- const resp = await app.registration.authorize(new Request("http://localhost"));
10
- (0, bun_test_1.expect)(resp.status).toBe(400);
11
- });
12
- (0, bun_test_1.test)("authorize: invalid signature", async () => {
13
- const resp = await app.registration.authorize(new Request("http://localhost?shop-url=test&shop-id=test&timestamp=test", { headers: new Headers({ "shopware-app-signature": "test" }) }));
14
- (0, bun_test_1.expect)(resp.status).toBe(401);
15
- });
16
- (0, bun_test_1.test)("authorize: valid request", async () => {
17
- app.signer.verify = bun_test_1.jest.fn().mockResolvedValue(true);
18
- const resp = await app.registration.authorize(new Request("http://localhost?shop-url=test&shop-id=test&timestamp=test", { headers: new Headers({ "shopware-app-signature": "test" }) }));
19
- (0, bun_test_1.expect)(resp.status).toBe(200);
20
- });
21
- (0, bun_test_1.test)("authorizeCallback: invalid request", async () => {
22
- const resp = await app.registration.authorizeCallback(new Request("http://localhost", { body: "{}" }));
23
- (0, bun_test_1.expect)(resp.status).toBe(400);
24
- });
25
- (0, bun_test_1.test)("authorizeCallback: shop does not exist", async () => {
26
- const resp = await app.registration.authorizeCallback(new Request("http://localhost", {
27
- body: '{"shopId": "test", "apiKey": "test", "secretKey": "test"}',
28
- }));
29
- (0, bun_test_1.expect)(resp.status).toBe(400);
30
- });
31
- (0, bun_test_1.test)("activateShop", async () => {
32
- await app.repository.createShop("1", "http://localhost", "test");
33
- const shop = await app.repository.getShopById("1");
34
- shop?.setShopActive(false);
35
- app.contextResolver.fromAPI = bun_test_1.jest.fn().mockResolvedValue({ shop });
36
- const resp = await app.registration.activate(new Request("http://localhost", { body: '{"source": {"shopId": "1"}}' }));
37
- (0, bun_test_1.expect)(resp.status).toBe(204);
38
- (0, bun_test_1.expect)(shop?.getShopActive()).toBe(true);
39
- });
40
- (0, bun_test_1.test)("deactivateShop", async () => {
41
- await app.repository.createShop("1", "http://localhost", "test");
42
- const shop = await app.repository.getShopById("1");
43
- shop?.setShopActive(true);
44
- app.contextResolver.fromAPI = bun_test_1.jest.fn().mockResolvedValue({ shop });
45
- const resp = await app.registration.deactivate(new Request("http://localhost", { body: '{"source": {"shopId": "1"}}' }));
46
- (0, bun_test_1.expect)(resp.status).toBe(204);
47
- (0, bun_test_1.expect)(shop?.getShopActive()).toBe(false);
48
- });
49
- (0, bun_test_1.test)("deletedShop", async () => {
50
- await app.repository.createShop("1", "http://localhost", "test");
51
- const shop = await app.repository.getShopById("1");
52
- (0, bun_test_1.expect)(shop).not.toBeNull();
53
- app.contextResolver.fromAPI = bun_test_1.jest.fn().mockResolvedValue({ shop });
54
- const resp = await app.registration.delete(new Request("http://localhost", { body: '{"source": {"shopId": "1"}}' }));
55
- (0, bun_test_1.expect)(resp.status).toBe(204);
56
- (0, bun_test_1.expect)(app.repository.getShopById("1")).resolves.toBeNull();
57
- });
58
- });
59
- //# sourceMappingURL=registration.test.js.map