@ketrics/ketrics-cli 0.2.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +623 -607
  2. package/dist/src/version.d.ts +1 -1
  3. package/dist/src/version.js +1 -1
  4. package/package.json +1 -1
  5. package/templates/HelloWorld/README.md +83 -106
  6. package/templates/HelloWorld/backend/package.json +1 -1
  7. package/templates/HelloWorld/backend/src/database.ts +108 -0
  8. package/templates/HelloWorld/backend/src/excel.ts +118 -0
  9. package/templates/HelloWorld/backend/src/http.ts +22 -0
  10. package/templates/HelloWorld/backend/src/index.ts +105 -29
  11. package/templates/HelloWorld/backend/src/jobs.ts +47 -0
  12. package/templates/HelloWorld/backend/src/messages.ts +59 -0
  13. package/templates/HelloWorld/backend/src/pdf.ts +212 -0
  14. package/templates/HelloWorld/backend/src/secrets.ts +21 -14
  15. package/templates/HelloWorld/backend/src/volumes.ts +107 -0
  16. package/templates/HelloWorld/frontend/package.json +1 -3
  17. package/templates/HelloWorld/frontend/src/App.css +62 -37
  18. package/templates/HelloWorld/frontend/src/App.tsx +131 -111
  19. package/templates/HelloWorld/frontend/src/mocks/handlers.ts +149 -0
  20. package/templates/HelloWorld/frontend/src/mocks/mock-client.ts +45 -0
  21. package/templates/HelloWorld/frontend/src/services/index.ts +38 -20
  22. package/templates/HelloWorld/frontend/src/vite-env.d.ts +1 -0
  23. package/templates/HelloWorld/tests/test.createInvoicePdf.json +18 -0
  24. package/templates/HelloWorld/tests/{test.getSecretWithoutGrant.json → test.createSimplePdf.json} +4 -2
  25. package/templates/HelloWorld/tests/test.createSpreadsheet.json +11 -0
  26. package/templates/HelloWorld/tests/test.echo.json +2 -2
  27. package/templates/HelloWorld/tests/test.fetchExternalApi.json +13 -0
  28. package/templates/HelloWorld/tests/test.getSecret.json +5 -1
  29. package/templates/HelloWorld/tests/test.info.json +3 -1
  30. package/templates/HelloWorld/tests/test.listFiles.json +13 -0
  31. package/templates/HelloWorld/tests/{test.echo2.json → test.queryUsers.json} +3 -3
  32. package/templates/HelloWorld/tests/{test.greet.json → test.readFile.json} +2 -2
  33. package/templates/HelloWorld/tests/{test.testWriteFileWithoutVolumeGrant.json → test.saveFile.json} +4 -2
  34. package/templates/HelloWorld/tests/test.sendNotification.json +14 -0
  35. package/templates/HelloWorld/backend/src/volume.ts +0 -55
@@ -1,13 +1,13 @@
1
1
  {
2
- "endpoint": "/tenants/{{tenantId}}/applications/{{applicationId}}/functions/echo2",
2
+ "endpoint": "/tenants/{{tenantId}}/applications/{{applicationId}}/functions/queryUsers",
3
3
  "method": "POST",
4
4
  "headers": {
5
5
  "Authorization": "Bearer {{token}}",
6
6
  "Content-Type": "application/json"
7
7
  },
8
8
  "body": {
9
- "data": {
10
- "hello": "world"
9
+ "payload": {
10
+ "limit": 5
11
11
  }
12
12
  }
13
13
  }
@@ -1,11 +1,11 @@
1
1
  {
2
- "endpoint": "/tenants/{{tenantId}}/applications/{{applicationId}}/functions/greet",
2
+ "endpoint": "/tenants/{{tenantId}}/applications/{{applicationId}}/functions/readFile",
3
3
  "method": "POST",
4
4
  "headers": {
5
5
  "Authorization": "Bearer {{token}}",
6
6
  "Content-Type": "application/json"
7
7
  },
8
8
  "body": {
9
- "name": "Localhost"
9
+ "payload": null
10
10
  }
11
11
  }
@@ -1,9 +1,11 @@
1
1
  {
2
- "endpoint": "/tenants/{{tenantId}}/applications/{{applicationId}}/functions/testWriteFileWithoutVolumeGrant",
2
+ "endpoint": "/tenants/{{tenantId}}/applications/{{applicationId}}/functions/saveFile",
3
3
  "method": "POST",
4
4
  "headers": {
5
5
  "Authorization": "Bearer {{token}}",
6
6
  "Content-Type": "application/json"
7
7
  },
8
- "body": {}
8
+ "body": {
9
+ "payload": null
10
+ }
9
11
  }
@@ -0,0 +1,14 @@
1
+ {
2
+ "endpoint": "/tenants/{{tenantId}}/applications/{{applicationId}}/functions/sendNotification",
3
+ "method": "POST",
4
+ "headers": {
5
+ "Authorization": "Bearer {{token}}",
6
+ "Content-Type": "application/json"
7
+ },
8
+ "body": {
9
+ "payload": {
10
+ "subject": "Test Notification",
11
+ "body": "This is a test notification from the Ketrics CLI."
12
+ }
13
+ }
14
+ }
@@ -1,55 +0,0 @@
1
- const testWriteFileWithoutVolumeGrant = async () => {
2
- const volume = await ketrics.Volume.connect("test2");
3
- const buffer = Buffer.from("This should fail");
4
- const putResults = await volume.put("files/fail.txt", buffer);
5
- return { putResults };
6
- };
7
-
8
- const saveFile = async () => {
9
- const volume = await ketrics.Volume.connect("test-volume");
10
-
11
- const data = {
12
- id: ketrics.application.id,
13
- code: ketrics.application.code,
14
- name: ketrics.application.name,
15
- version: ketrics.application.version,
16
- deploymentId: ketrics.application.deploymentId,
17
- };
18
-
19
- // Write text/JSON content
20
- const resultData = await volume.put("output/data.json", JSON.stringify(data), {
21
- contentType: "application/json",
22
- });
23
- console.log(resultData.key, resultData.etag, resultData.size);
24
-
25
- // Write binary content
26
- const buffer = Buffer.from("Hello World");
27
- const resultBuffer = await volume.put("files/hello.txt", buffer);
28
-
29
- return {
30
- data,
31
- dataFile: { key: resultData.key, etag: resultData.etag, size: resultData.size },
32
- bufferFile: { key: resultBuffer.key, etag: resultBuffer.etag, size: resultBuffer.size },
33
- };
34
- };
35
-
36
- const readFile = async () => {
37
- const volume = await ketrics.Volume.connect("test-volume");
38
- const file = await volume.get("output/data.json");
39
- if (!file) {
40
- throw new Error("File not found");
41
- }
42
- const content = await file.content.toString();
43
- return {
44
- content: content,
45
- parsed: JSON.parse(content),
46
- };
47
- };
48
-
49
- const generateDownloadUrl = async () => {
50
- const volume = await ketrics.Volume.connect("test-volume");
51
- const results = await volume.generateDownloadUrl("output/data.json"); // URL valid for 1 hour
52
- return { url: results.url };
53
- };
54
-
55
- export { saveFile, readFile, generateDownloadUrl, testWriteFileWithoutVolumeGrant };