stacks 0.58.63 → 0.58.64

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 (138) hide show
  1. package/core/actions/dist/src/database/seed.js +0 -3
  2. package/core/actions/dist/src/deploy/index.js +1 -1
  3. package/core/actions/dist/src/index.js +3 -0
  4. package/core/actions/dist/src/release.js +5 -2
  5. package/core/actions/dist/src/upgrade.js +1 -1
  6. package/core/actions/package.json +1 -1
  7. package/core/actions/src/action.ts +4 -1
  8. package/core/actions/src/copy-types.ts +1 -1
  9. package/core/actions/src/database/seed.ts +3 -3
  10. package/core/actions/src/deploy/index.ts +1 -1
  11. package/core/actions/src/helpers/utils.ts +2 -2
  12. package/core/ai/package.json +1 -1
  13. package/core/alias/package.json +1 -1
  14. package/core/analytics/package.json +1 -1
  15. package/core/api/package.json +1 -1
  16. package/core/arrays/package.json +1 -1
  17. package/core/arrays/src/helpers.ts +3 -3
  18. package/core/auth/package.json +1 -1
  19. package/core/buddy/dist/cli.js +1 -1
  20. package/core/buddy/package.json +1 -1
  21. package/core/buddy/src/cli.ts +1 -1
  22. package/core/build/package.json +1 -1
  23. package/core/bun-create/bud/package.json +1 -1
  24. package/core/bun-create/buddy/package.json +1 -1
  25. package/core/bun-create/stack/package.json +1 -1
  26. package/core/bun-create/stacks/package.json +1 -1
  27. package/core/bun-create/stx/package.json +1 -1
  28. package/core/bun-plugin-yaml/package.json +1 -1
  29. package/core/cache/package.json +1 -1
  30. package/core/cache/tests/DynamoDB.test.ts +125 -125
  31. package/core/cache/tests/Memcached.test.ts +51 -51
  32. package/core/cache/tests/Redis.test.ts +84 -84
  33. package/core/chat/package.json +1 -1
  34. package/core/cli/dist/index.js +1 -1
  35. package/core/cli/package.json +1 -1
  36. package/core/cli/src/exec.ts +2 -2
  37. package/core/cloud/dist/index.js +7 -7
  38. package/core/cloud/package.json +1 -1
  39. package/core/cloud/src/cloud/ai.ts +3 -3
  40. package/core/cloud/src/cloud/aws-sdk-layer/nodejs/package.json +1 -1
  41. package/core/cloud/src/cloud/cli.ts +1 -1
  42. package/core/cloud/src/cloud/deployment.ts +3 -3
  43. package/core/cloud/src/cloud/router-layer/nodejs/package.json +2 -2
  44. package/core/collections/package.json +1 -1
  45. package/core/config/dist/index.js +4 -0
  46. package/core/config/package.json +1 -1
  47. package/core/database/package.json +1 -1
  48. package/core/database/src/kysely-bun-worker/driver.ts +1 -1
  49. package/core/datetime/package.json +1 -1
  50. package/core/desktop/package.json +1 -1
  51. package/core/development/package.json +1 -1
  52. package/core/dns/package.json +1 -1
  53. package/core/docs/package.json +1 -1
  54. package/core/email/package.json +2 -2
  55. package/core/enums/package.json +1 -1
  56. package/core/env/package.json +1 -1
  57. package/core/error-handling/package.json +1 -1
  58. package/core/error-handling/src/handler.ts +1 -1
  59. package/core/eslint-config/package.json +1 -1
  60. package/core/events/package.json +1 -1
  61. package/core/faker/package.json +1 -1
  62. package/core/git/package.json +1 -1
  63. package/core/health/package.json +1 -1
  64. package/core/http/package.json +1 -1
  65. package/core/lint/package.json +1 -1
  66. package/core/logging/package.json +1 -1
  67. package/core/notifications/package.json +1 -1
  68. package/core/objects/package.json +1 -1
  69. package/core/orm/package.json +1 -1
  70. package/core/path/dist/index.js +30 -0
  71. package/core/path/package.json +1 -1
  72. package/core/path/src/index.ts +30 -0
  73. package/core/payments/package.json +1 -1
  74. package/core/push/package.json +1 -1
  75. package/core/query-builder/package.json +1 -1
  76. package/core/queue/package.json +1 -1
  77. package/core/raycast/package.json +1 -1
  78. package/core/realtime/package.json +1 -1
  79. package/core/repl/package.json +1 -1
  80. package/core/router/dist/index.js +40 -2
  81. package/core/router/package.json +1 -1
  82. package/core/router/src/router.ts +21 -1
  83. package/core/router/src/server.ts +0 -2
  84. package/core/scheduler/dist/index.js +1 -2
  85. package/core/scheduler/package.json +2 -1
  86. package/core/scheduler/src/index.ts +1 -1
  87. package/core/scheduler/src/job.ts +2 -2
  88. package/core/scheduler/src/schedule.ts +2 -2
  89. package/core/scheduler/tests/cron.test.ts +1243 -1243
  90. package/core/scheduler/tests/crontime.test.ts +780 -778
  91. package/core/search-engine/dist/index.js +1 -3
  92. package/core/search-engine/package.json +1 -1
  93. package/core/search-engine/src/index.ts +5 -5
  94. package/core/security/package.json +1 -1
  95. package/core/server/package.json +1 -1
  96. package/core/signals/package.json +1 -1
  97. package/core/slug/package.json +1 -1
  98. package/core/sms/package.json +1 -1
  99. package/core/storage/dist/index.js +0 -1
  100. package/core/storage/package.json +1 -1
  101. package/core/storage/src/files.ts +2 -5
  102. package/core/storage/src/hash.ts +0 -2
  103. package/core/strings/package.json +1 -1
  104. package/core/tables/package.json +1 -1
  105. package/core/testing/dist/index.js +14978 -1
  106. package/core/testing/package.json +1 -1
  107. package/core/testing/src/index.ts +12 -2
  108. package/core/tinker/package.json +1 -1
  109. package/core/tunnel/package.json +1 -1
  110. package/core/types/package.json +1 -1
  111. package/core/types/src/cli.ts +1 -1
  112. package/core/types/src/cron-jobs.ts +0 -5
  113. package/core/types/src/errors.ts +1 -1
  114. package/core/types/src/router.ts +7 -5
  115. package/core/ui/package.json +1 -1
  116. package/core/utils/dist/index.js +4 -8
  117. package/core/utils/package.json +1 -1
  118. package/core/utils/scripts/export-size.ts +3 -3
  119. package/core/utils/src/base.ts +4 -4
  120. package/core/utils/src/helpers.ts +3 -3
  121. package/core/utils/src/retry.ts +2 -2
  122. package/core/validation/package.json +1 -1
  123. package/core/vite/dist/index.js +1 -1
  124. package/core/vite/package.json +1 -1
  125. package/core/vite/src/functions.ts +0 -1
  126. package/core/vite/src/index.ts +1 -1
  127. package/core/vite/src/plugin/docs.ts +2 -0
  128. package/core/vite/src/plugin/stacks.ts +3 -2
  129. package/core/vite/src/web-components.ts +2 -2
  130. package/core/whois/package.json +1 -1
  131. package/core/whois/src/index.ts +2 -2
  132. package/core/x-ray/package.json +1 -1
  133. package/core/zsh-buddy/package.json +1 -1
  134. package/ide/vscode/package.json +1 -1
  135. package/package.json +1 -1
  136. package/core/actions/src/database/mydb.sqlite +0 -0
  137. package/core/actions/src/database/stacks.sqlite +0 -0
  138. package/core/server/src/api.ts +0 -5
@@ -1,4 +1 @@
1
1
  // @bun
2
- // src/database/seed.ts
3
- import {seed} from "@stacksjs/database";
4
- await seed();
@@ -27,5 +27,5 @@ await runCommand("bun zip.ts", {
27
27
  log.info("Preparing Deployment...");
28
28
  var profile = process.env.AWS_PROFILE || "stacks";
29
29
  await runCommand(`bunx cdk deploy --require-approval never --profile="${profile}"`, {
30
- cwd: p.cloudPath()
30
+ cwd: p.frameworkCloudPath()
31
31
  });
@@ -515,6 +515,8 @@ export default <Model> {
515
515
  }
516
516
 
517
517
  // src/action.ts
518
+ import {log as log7} from "@stacksjs/logging";
519
+
518
520
  class Action3 {
519
521
  name;
520
522
  description;
@@ -524,6 +526,7 @@ class Action3 {
524
526
  enabled;
525
527
  handle;
526
528
  constructor({ name, description, handle, rate, tries, backoff, enabled }) {
529
+ log7.info(`Action ${name} created`);
527
530
  this.name = name;
528
531
  this.description = description;
529
532
  this.rate = rate;
@@ -517,6 +517,8 @@ export default <Model> {
517
517
  }
518
518
 
519
519
  // src/action.ts
520
+ import {log as log7} from "@stacksjs/logging";
521
+
520
522
  class Action3 {
521
523
  name;
522
524
  description;
@@ -526,6 +528,7 @@ class Action3 {
526
528
  enabled;
527
529
  handle;
528
530
  constructor({ name, description, handle, rate, tries, backoff, enabled }) {
531
+ log7.info(`Action ${name} created`);
529
532
  this.name = name;
530
533
  this.description = description;
531
534
  this.rate = rate;
@@ -538,7 +541,7 @@ class Action3 {
538
541
  // src/release.ts
539
542
  import {projectPath as projectPath4} from "@stacksjs/path";
540
543
  import {Action as Action4} from "@stacksjs/enums";
541
- import {log as log7} from "@stacksjs/logging";
544
+ import {log as log8} from "@stacksjs/logging";
542
545
  import {app} from "@stacksjs/config";
543
546
  await runActions([
544
547
  Action4.GenerateLibraryEntries,
@@ -548,4 +551,4 @@ await runActions([
548
551
  cwd: projectPath4(),
549
552
  stdin: "inherit"
550
553
  });
551
- log7.success(`Successfully released ${app.name}`);
554
+ log8.success(`Successfully released ${app.name}`);
@@ -7,7 +7,7 @@ import {projectPath} from "@stacksjs/path";
7
7
  import * as storage from "@stacksjs/storage";
8
8
  import {NpmScript} from "@stacksjs/enums";
9
9
  // package.json
10
- var version = "0.58.63";
10
+ var version = "0.58.64";
11
11
 
12
12
  // src/upgrade.ts
13
13
  function checkForUncommittedChanges(options) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/actions",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "The Stacks actions.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,4 +1,5 @@
1
1
  import type { JobOptions } from '@stacksjs/types'
2
+ import { log } from '@stacksjs/logging'
2
3
 
3
4
  interface ActionOptions {
4
5
  name?: string
@@ -16,10 +17,12 @@ export class Action {
16
17
  rate?: JobOptions['rate']
17
18
  tries?: JobOptions['tries']
18
19
  backoff?: JobOptions['backoff']
19
- enabled?: JobOptions['enabled']
20
+ enabled?: boolean
20
21
  handle: () => Promise<any>
21
22
 
22
23
  constructor({ name, description, handle, rate, tries, backoff, enabled }: ActionOptions) {
24
+ log.info(`Action ${name} created`)
25
+
23
26
  this.name = name
24
27
  this.description = description
25
28
  this.rate = rate
@@ -18,5 +18,5 @@ destinations.forEach(([src, dest]) => {
18
18
  // const srcPath = resolve(__filename, '..', src)
19
19
  // const destPath = resolve(__filename, '..', dest)
20
20
 
21
- copyFolder(src, dest)
21
+ copyFolder(src!, dest!)
22
22
  })
@@ -1,4 +1,4 @@
1
1
  // import { database } from '@stacksjs/config'
2
- import { seed } from '@stacksjs/database'
3
-
4
- await seed()
2
+ // import { seed } from '@stacksjs/database'
3
+ //
4
+ // await seed()
@@ -42,5 +42,5 @@ const profile = process.env.AWS_PROFILE || 'stacks'
42
42
 
43
43
  // TODO: ensure we check whether cdk bootstrap needs to be run
44
44
  await runCommand(`bunx cdk deploy --require-approval never --profile="${profile}"`, {
45
- cwd: p.cloudPath(),
45
+ cwd: p.frameworkCloudPath(),
46
46
  })
@@ -2,7 +2,7 @@ import * as storage from '@stacksjs/storage'
2
2
  import { buddyOptions, runCommand, runCommands } from '@stacksjs/cli'
3
3
  import { log } from '@stacksjs/logging'
4
4
  import * as p from '@stacksjs/path'
5
- import type { ActionOptions, StacksError, Subprocess } from '@stacksjs/types'
5
+ import type { ActionOptions, Subprocess } from '@stacksjs/types'
6
6
  import type { Result } from '@stacksjs/error-handling'
7
7
  import { err, handleError } from '@stacksjs/error-handling'
8
8
 
@@ -13,7 +13,7 @@ import { err, handleError } from '@stacksjs/error-handling'
13
13
  * @param options The options to pass to the command.
14
14
  * @returns The result of the command.
15
15
  */
16
- export async function runAction(action: string, options?: ActionOptions): Promise<Result<Subprocess, StacksError>> {
16
+ export async function runAction(action: string, options?: ActionOptions): Promise<Result<Subprocess, Error>> {
17
17
  const opts = buddyOptions()
18
18
  const path = p.relativeActionsPath(`${action}.ts`)
19
19
  const cmd = `bun --bun ${path} ${opts}`.trimEnd()
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/ai",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "Stacks Artificial Intelligence.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/alias",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "The Stacks aliases.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/analytics",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "Stacks Analytics. Privacy-friendly.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/api",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "The Stacks array utilities.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/arrays",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "The Stacks array utilities.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -74,12 +74,12 @@ export function partition<T>(array: readonly T[], ...filters: PartitionFilter<T>
74
74
  let i = 0
75
75
  for (const filter of filters) {
76
76
  if (filter(e, idx, arr)) {
77
- result[i].push(e)
77
+ result[i]!.push(e)
78
78
  return
79
79
  }
80
80
  i += 1
81
81
  }
82
- result[i].push(e)
82
+ result[i]!.push(e)
83
83
  })
84
84
  return result
85
85
  }
@@ -266,7 +266,7 @@ export function sample<T>(arr: T[], count: number) {
266
266
  export function shuffle<T>(array: T[]): T[] {
267
267
  for (let i = array.length - 1; i > 0; i--) {
268
268
  const j = Math.floor(Math.random() * (i + 1));
269
- [array[i], array[j]] = [array[j], array[i]]
269
+ [array[i]!, array[j]!] = [array[j]!, array[i]!]
270
270
  }
271
271
  return array
272
272
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/auth",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "A more simplistic way to authenticate.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -3945,7 +3945,7 @@ async function main() {
3945
3945
  ]);
3946
3946
  buddy.command("inspire", "Inspire yourself with a random quote").alias("insp").action(() => {
3947
3947
  log.info(quotes.random());
3948
- log.success("Have a great dayss!");
3948
+ log.success("Have a great days!");
3949
3949
  });
3950
3950
  buddy.on("inspire:*", () => {
3951
3951
  console.log("Invalid command:", buddy.args.join(" "));
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/buddy",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "Meet Buddy. The Stacks runtime.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -88,7 +88,7 @@ async function main() {
88
88
  .alias('insp')
89
89
  .action(() => {
90
90
  log.info(quotes.random())
91
- log.success('Have a great dayss!')
91
+ log.success('Have a great days!')
92
92
  })
93
93
 
94
94
  buddy.on('inspire:*', () => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/build",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "The Stacks framework build tools and configurations.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bun-examples/bud",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "Your project description.",
6
6
  "author": "your-name <your-email>",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bun-examples/buddy",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "Your project description.",
6
6
  "author": "your-name <your-email>",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bun-examples/stack",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "Your project description.",
6
6
  "author": "your-name <your-email>",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bun-examples/stacks",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "Your project description.",
6
6
  "author": "your-name <your-email>",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bun-examples/stx",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "Your project description.",
6
6
  "author": "your-name <your-email>",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-plugin-yaml",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "A Bun plugin to load yaml files",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/cache",
3
3
  "type": "module",
4
- "version": "0.58.63",
4
+ "version": "0.58.64",
5
5
  "description": "Caching the Stacks way.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,127 +1,113 @@
1
- import { DynamoDB, ListTablesCommand } from '@aws-sdk/client-dynamodb'
2
- import { expect, it } from '@stacksjs/testing'
3
-
4
- const dynamodb = new DynamoDB({ region: 'us-east-1' })
5
-
6
- describe('dynamoDB test', () => {
7
- it('it should create a table for dynamodb cache', async () => {
8
- await createTable()
9
- })
10
-
11
- it('it should set dynamodb cache', async () => {
12
- await set('foo', 'bar')
13
- const value = await get('foo')
14
- expect(value).toBe('bar')
15
- })
16
-
17
- it('it should get dynamodb cache', async () => {
18
- await set('foo', 'bar')
19
- const value = await get('foo')
20
- expect(value).toBe('bar')
21
- })
22
-
23
- it('it should delete dynamodb cache', async () => {
24
- await set('foo', 'bar')
25
- await remove('foo')
26
- const value = await get('foo')
27
- expect(value).toBe(null)
28
- })
29
- })
30
-
31
- async function createTable() {
32
- const tables = await dynamodb.send(new ListTablesCommand({}))
33
-
34
- const tableExists = tables.TableNames?.includes('cache')
35
-
36
- if (tableExists)
37
- return
38
-
39
- const params = {
40
- AttributeDefinitions: [
41
- {
42
- AttributeName: 'key',
43
- AttributeType: 'S',
44
- },
45
- ],
46
- KeySchema: [
47
- {
48
- AttributeName: 'key',
49
- KeyType: 'HASH',
50
- },
51
- ],
52
- ProvisionedThroughput: {
53
- ReadCapacityUnits: 5,
54
- WriteCapacityUnits: 5,
55
- },
56
- TableName: 'cache',
57
- }
58
-
59
- await dynamodb.createTable(params)
60
- }
61
-
62
- // TODO: needs to be imported to cache package
63
- async function set(key: string, value: string | number): Promise<void> {
64
- // eslint-disable-next-line no-console
65
- console.log('set', key, value)
66
- return Promise.resolve()
67
- // const valueAttribute = 'value'
68
- // const keyAttribute = 'key'
69
- //
70
- // const params: PutItemCommandInput = {
71
- // TableName: 'cache',
72
- // Item: {
73
- // [keyAttribute]: {
74
- // S: key,
75
- // },
76
- // [valueAttribute]: {
77
- // [getValueType(value)]: serialize(value),
78
- // },
79
- // },
80
- // }
81
- //
82
- // await dynamodb.putItem(params)
83
- }
84
-
85
- // TODO: needs to be imported to cache package
86
- async function get(key: string): Promise<string | undefined | null> {
87
- const valueAttribute = 'value'
88
- const keyAttribute = 'key'
89
-
90
- const params = {
91
- TableName: 'cache',
92
- Key: {
93
- [keyAttribute]: {
94
- S: key,
95
- },
96
- },
97
- }
98
-
99
- const response = await dynamodb.getItem(params)
100
-
101
- if (!response.Item)
102
- return null
103
-
104
- return response.Item[valueAttribute].S ?? response.Item[valueAttribute].N
105
- }
106
-
107
- // TODO: needs to be imported to cache package
108
- async function remove(key: string): Promise<void> {
109
- const keyAttribute = 'key'
110
-
111
- const params = {
112
- TableName: 'cache',
113
- Key: {
114
- [keyAttribute]: {
115
- S: key,
116
- },
117
- },
118
- }
119
-
120
- await dynamodb.deleteItem(params)
121
- }
122
-
123
- // TODO: needs to be imported to cache package
124
- // async function del(key: string): Promise<void> {
1
+ // import { DynamoDB, ListTablesCommand } from '@aws-sdk/client-dynamodb'
2
+ // import { expect, it } from '@stacksjs/testing'
3
+ //
4
+ // const dynamodb = new DynamoDB({ region: 'us-east-1' })
5
+ //
6
+ // describe('dynamoDB test', () => {
7
+ // it('it should create a table for dynamodb cache', async () => {
8
+ // await createTable()
9
+ // })
10
+ //
11
+ // it('it should set dynamodb cache', async () => {
12
+ // await set('foo', 'bar')
13
+ // const value = await get('foo')
14
+ // expect(value).toBe('bar')
15
+ // })
16
+ //
17
+ // it('it should get dynamodb cache', async () => {
18
+ // await set('foo', 'bar')
19
+ // const value = await get('foo')
20
+ // expect(value).toBe('bar')
21
+ // })
22
+ //
23
+ // it('it should delete dynamodb cache', async () => {
24
+ // await set('foo', 'bar')
25
+ // await remove('foo')
26
+ // const value = await get('foo')
27
+ // expect(value).toBe(null)
28
+ // })
29
+ // })
30
+ //
31
+ // async function createTable() {
32
+ // const tables = await dynamodb.send(new ListTablesCommand({}))
33
+ //
34
+ // const tableExists = tables.TableNames?.includes('cache')
35
+ //
36
+ // if (tableExists)
37
+ // return
38
+ //
39
+ // const params = {
40
+ // AttributeDefinitions: [
41
+ // {
42
+ // AttributeName: 'key',
43
+ // AttributeType: 'S',
44
+ // },
45
+ // ],
46
+ // KeySchema: [
47
+ // {
48
+ // AttributeName: 'key',
49
+ // KeyType: 'HASH',
50
+ // },
51
+ // ],
52
+ // ProvisionedThroughput: {
53
+ // ReadCapacityUnits: 5,
54
+ // WriteCapacityUnits: 5,
55
+ // },
56
+ // TableName: 'cache',
57
+ // }
58
+ //
59
+ // await dynamodb.createTable(params)
60
+ // }
61
+ //
62
+ // // TODO: needs to be imported to cache package
63
+ // async function set(key: string, value: string | number): Promise<void> {
64
+ // // eslint-disable-next-line no-console
65
+ // console.log('set', key, value)
66
+ // return Promise.resolve()
67
+ // // const valueAttribute = 'value'
68
+ // // const keyAttribute = 'key'
69
+ // //
70
+ // // const params: PutItemCommandInput = {
71
+ // // TableName: 'cache',
72
+ // // Item: {
73
+ // // [keyAttribute]: {
74
+ // // S: key,
75
+ // // },
76
+ // // [valueAttribute]: {
77
+ // // [getValueType(value)]: serialize(value),
78
+ // // },
79
+ // // },
80
+ // // }
81
+ // //
82
+ // // await dynamodb.putItem(params)
83
+ // }
84
+ //
85
+ // // TODO: needs to be imported to cache package
86
+ // async function get(key: string): Promise<string | undefined | null> {
87
+ // const valueAttribute = 'value'
88
+ // const keyAttribute = 'key'
89
+ //
90
+ // const params = {
91
+ // TableName: 'cache',
92
+ // Key: {
93
+ // [keyAttribute]: {
94
+ // S: key,
95
+ // },
96
+ // },
97
+ // }
98
+ //
99
+ // const response = await dynamodb.getItem(params)
100
+ //
101
+ // if (!response.Item)
102
+ // return null
103
+ //
104
+ // return response.Item[valueAttribute].S ?? response.Item[valueAttribute].N
105
+ // }
106
+ //
107
+ // // TODO: needs to be imported to cache package
108
+ // async function remove(key: string): Promise<void> {
109
+ // const keyAttribute = 'key'
110
+ //
125
111
  // const params = {
126
112
  // TableName: 'cache',
127
113
  // Key: {
@@ -130,6 +116,20 @@ async function remove(key: string): Promise<void> {
130
116
  // },
131
117
  // },
132
118
  // }
133
-
119
+ //
134
120
  // await dynamodb.deleteItem(params)
135
121
  // }
122
+ //
123
+ // // TODO: needs to be imported to cache package
124
+ // // async function del(key: string): Promise<void> {
125
+ // // const params = {
126
+ // // TableName: 'cache',
127
+ // // Key: {
128
+ // // [keyAttribute]: {
129
+ // // S: key,
130
+ // // },
131
+ // // },
132
+ // // }
133
+ //
134
+ // // await dynamodb.deleteItem(params)
135
+ // // }