stacks 0.58.55 → 0.58.57

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 (101) hide show
  1. package/core/actions/dist/src/upgrade.js +1 -1
  2. package/core/actions/package.json +1 -1
  3. package/core/ai/package.json +1 -1
  4. package/core/alias/package.json +1 -1
  5. package/core/analytics/package.json +1 -1
  6. package/core/api/package.json +1 -1
  7. package/core/arrays/package.json +1 -1
  8. package/core/auth/package.json +1 -1
  9. package/core/buddy/dist/{chunk-d52e40a990b45728.js → chunk-e9c0ec1a3b7be088.js} +120 -92
  10. package/core/buddy/dist/cli.js +1 -1
  11. package/core/buddy/dist/index.js +1 -1
  12. package/core/buddy/package.json +1 -1
  13. package/core/buddy/src/commands/configure.ts +38 -27
  14. package/core/buddy/src/commands/deploy.ts +81 -56
  15. package/core/buddy/src/commands/setup.ts +11 -9
  16. package/core/build/package.json +1 -1
  17. package/core/bun-create/bud/package.json +1 -1
  18. package/core/bun-create/buddy/package.json +1 -1
  19. package/core/bun-create/stack/package.json +1 -1
  20. package/core/bun-create/stacks/package.json +1 -1
  21. package/core/bun-create/stx/package.json +1 -1
  22. package/core/bun-plugin-yaml/package.json +1 -1
  23. package/core/cache/package.json +1 -1
  24. package/core/chat/package.json +1 -1
  25. package/core/cli/dist/index.js +7 -1
  26. package/core/cli/package.json +1 -1
  27. package/core/cli/src/exec.ts +8 -0
  28. package/core/cloud/deploy.ts +3 -2
  29. package/core/cloud/dist/index.js +131 -70
  30. package/core/cloud/package.json +1 -1
  31. package/core/cloud/src/cloud/aws-sdk-layer/nodejs/package.json +1 -1
  32. package/core/cloud/src/cloud/index.ts +76 -50
  33. package/core/cloud/src/cloud/queue.ts +86 -29
  34. package/core/cloud/src/cloud/router-layer/nodejs/package.json +2 -2
  35. package/core/collections/package.json +1 -1
  36. package/core/config/package.json +1 -1
  37. package/core/database/package.json +1 -1
  38. package/core/datetime/package.json +1 -1
  39. package/core/desktop/package.json +1 -1
  40. package/core/development/package.json +1 -1
  41. package/core/dns/package.json +1 -1
  42. package/core/docs/package.json +1 -1
  43. package/core/email/package.json +1 -1
  44. package/core/enums/package.json +1 -1
  45. package/core/env/package.json +1 -1
  46. package/core/env/src/types.ts +1 -1
  47. package/core/error-handling/package.json +1 -1
  48. package/core/eslint-config/package.json +1 -1
  49. package/core/events/package.json +1 -1
  50. package/core/faker/package.json +1 -1
  51. package/core/git/package.json +1 -1
  52. package/core/health/package.json +1 -1
  53. package/core/http/package.json +1 -1
  54. package/core/lint/package.json +1 -1
  55. package/core/logging/dist/index.js +161 -4
  56. package/core/logging/package.json +1 -1
  57. package/core/logging/src/index.ts +55 -12
  58. package/core/notifications/package.json +1 -1
  59. package/core/objects/package.json +1 -1
  60. package/core/orm/package.json +1 -1
  61. package/core/path/dist/index.js +1 -1
  62. package/core/path/package.json +1 -1
  63. package/core/path/src/index.ts +1 -1
  64. package/core/payments/package.json +1 -1
  65. package/core/push/package.json +1 -1
  66. package/core/query-builder/package.json +1 -1
  67. package/core/queue/dist/index.js +3 -1
  68. package/core/queue/package.json +1 -1
  69. package/core/queue/src/index.ts +3 -1
  70. package/core/raycast/package.json +1 -1
  71. package/core/realtime/package.json +1 -1
  72. package/core/repl/package.json +1 -1
  73. package/core/router/package.json +1 -1
  74. package/core/scheduler/package.json +1 -1
  75. package/core/search-engine/package.json +1 -1
  76. package/core/security/package.json +1 -1
  77. package/core/server/package.json +1 -1
  78. package/core/signals/package.json +1 -1
  79. package/core/slug/package.json +1 -1
  80. package/core/sms/package.json +1 -1
  81. package/core/storage/package.json +1 -1
  82. package/core/strings/package.json +1 -1
  83. package/core/tables/package.json +1 -1
  84. package/core/testing/package.json +1 -1
  85. package/core/tinker/package.json +1 -1
  86. package/core/tunnel/package.json +1 -1
  87. package/core/types/dist/index.js +8 -3
  88. package/core/types/package.json +1 -1
  89. package/core/types/src/configure.ts +7 -0
  90. package/core/types/src/cron-jobs.ts +8 -3
  91. package/core/ui/package.json +1 -1
  92. package/core/utils/dist/index.js +1 -1
  93. package/core/utils/package.json +1 -1
  94. package/core/validation/package.json +1 -1
  95. package/core/vite/dist/index.js +1 -1
  96. package/core/vite/package.json +1 -1
  97. package/core/whois/package.json +1 -1
  98. package/core/x-ray/package.json +1 -1
  99. package/core/zsh-buddy/package.json +1 -1
  100. package/ide/vscode/package.json +1 -1
  101. package/package.json +1 -1
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-new */
2
1
  import { Stack } from 'aws-cdk-lib'
3
2
  import type { Construct } from 'constructs'
4
3
  import { config } from '@stacksjs/config'
@@ -23,87 +22,114 @@ import { QueueStack } from './queue'
23
22
  // import { DashboardStack } from './dashboard'
24
23
 
25
24
  export class Cloud extends Stack {
25
+ dns: DnsStack
26
+ security: SecurityStack
27
+ storage: StorageStack
28
+ network: NetworkStack
29
+ fileSystem: FileSystemStack
30
+ jumpBox: JumpBoxStack
31
+ docs: DocsStack
32
+ email: EmailStack
33
+ redirects: RedirectsStack
34
+ permissions: PermissionsStack
35
+ ai: AiStack
36
+ cli: CliStack
37
+ api!: ComputeStack
38
+ cdn!: CdnStack
39
+ queue!: QueueStack
40
+ deployment!: DeploymentStack
41
+ scope: Construct
42
+ props: CloudOptions
43
+
26
44
  constructor(scope: Construct, id: string, props: CloudOptions) {
27
45
  super(scope, id, props)
28
- // please beware: be careful changing the order of the stack creations below
29
- const dns = new DnsStack(this, props)
46
+ this.scope = scope
47
+ this.props = props
30
48
 
31
- const security = new SecurityStack(this, {
49
+ // please beware: be careful changing the order of the stack creations below
50
+ this.dns = new DnsStack(this, props)
51
+ this.security = new SecurityStack(this, {
32
52
  ...props,
33
- zone: dns.zone,
53
+ zone: this.dns.zone,
34
54
  })
35
55
 
36
- const storage = new StorageStack(this, {
56
+ this.storage = new StorageStack(this, {
37
57
  ...props,
38
- kmsKey: security.kmsKey,
58
+ kmsKey: this.security.kmsKey,
39
59
  })
40
60
 
41
- const network = new NetworkStack(this, props)
61
+ this.network = new NetworkStack(this, props)
42
62
 
43
- const fileSystem = new FileSystemStack(this, {
63
+ this.fileSystem = new FileSystemStack(this, {
44
64
  ...props,
45
- vpc: network.vpc,
65
+ vpc: this.network.vpc,
46
66
  })
47
67
 
48
- new JumpBoxStack(this, {
68
+ this.jumpBox = new JumpBoxStack(this, {
49
69
  ...props,
50
- vpc: network.vpc,
51
- fileSystem: fileSystem.fileSystem,
70
+ vpc: this.network.vpc,
71
+ fileSystem: this.fileSystem.fileSystem,
52
72
  })
53
73
 
54
- const docs = new DocsStack(this, props)
74
+ this.docs = new DocsStack(this, props)
55
75
 
56
- new EmailStack(this, {
76
+ this.email = new EmailStack(this, {
57
77
  ...props,
58
- zone: dns.zone,
78
+ zone: this.dns.zone,
59
79
  })
60
80
 
61
- new RedirectsStack(this, props)
81
+ this.redirects = new RedirectsStack(this, props)
62
82
 
63
- new PermissionsStack(this)
83
+ this.permissions = new PermissionsStack(this)
64
84
 
65
85
  // new DashboardStack(this)
66
86
 
67
- let api
87
+ this.ai = new AiStack(this, props)
88
+
89
+ this.cli = new CliStack(this, props)
90
+ }
91
+
92
+ // we use an async init() method here because we need to wait for the
93
+
94
+ async init() {
68
95
  if (config.cloud.api?.deploy) {
69
- api = new ComputeStack(this, {
96
+ const props = this.props
97
+ this.api = new ComputeStack(this, {
70
98
  ...props,
71
- vpc: network.vpc,
72
- fileSystem: fileSystem.fileSystem,
73
- zone: dns.zone,
74
- certificate: security.certificate,
99
+ vpc: this.network.vpc,
100
+ fileSystem: this.fileSystem.fileSystem,
101
+ zone: this.dns.zone,
102
+ certificate: this.security.certificate,
75
103
  })
76
104
 
77
- new QueueStack(this, {
105
+ this.queue = new QueueStack(this, {
78
106
  ...props,
79
- cluster: api.cluster,
80
- taskDefinition: api.taskDefinition,
107
+ cluster: this.api.cluster,
108
+ taskDefinition: this.api.taskDefinition,
81
109
  })
82
- }
83
-
84
- const ai = new AiStack(this, props)
85
110
 
86
- const cli = new CliStack(this, props)
111
+ await this.queue.init()
87
112
 
88
- const cdn = new CdnStack(this, {
89
- ...props,
90
- publicBucket: storage.publicBucket,
91
- logBucket: storage.logBucket,
92
- certificate: security.certificate,
93
- firewall: security.firewall,
94
- originRequestFunction: docs.originRequestFunction,
95
- zone: dns.zone,
96
- cliSetupUrl: cli.cliSetupUrl,
97
- askAiUrl: ai.askAiUrl,
98
- summarizeAiUrl: ai.summarizeAiUrl,
99
- lb: api?.lb,
100
- })
113
+ this.cdn = new CdnStack(this, {
114
+ ...props,
115
+ publicBucket: this.storage.publicBucket,
116
+ logBucket: this.storage.logBucket,
117
+ certificate: this.security.certificate,
118
+ firewall: this.security.firewall,
119
+ originRequestFunction: this.docs.originRequestFunction,
120
+ zone: this.dns.zone,
121
+ cliSetupUrl: this.cli.cliSetupUrl,
122
+ askAiUrl: this.ai.askAiUrl,
123
+ summarizeAiUrl: this.ai.summarizeAiUrl,
124
+ lb: this.api?.lb,
125
+ })
101
126
 
102
- new DeploymentStack(this, {
103
- ...props,
104
- publicBucket: storage.publicBucket,
105
- privateBucket: storage.privateBucket,
106
- cdn: cdn.distribution,
107
- })
127
+ this.deployment = new DeploymentStack(this, {
128
+ ...props,
129
+ publicBucket: this.storage.publicBucket,
130
+ privateBucket: this.storage.privateBucket,
131
+ cdn: this.cdn.distribution,
132
+ })
133
+ }
108
134
  }
109
135
  }
@@ -1,6 +1,9 @@
1
- import type { Cluster, TaskDefinition } from 'aws-cdk-lib'
1
+ import type { Cluster, TaskDefinition } from 'aws-cdk-lib/aws-ecs'
2
2
  import { aws_ec2 as ec2 } from 'aws-cdk-lib'
3
3
  import type { Construct } from 'constructs'
4
+ import { pascalCase, slug } from '@stacksjs/strings'
5
+ import { fs } from '@stacksjs/storage'
6
+ import { path } from '@stacksjs/path'
4
7
  import { Rule, Schedule } from 'aws-cdk-lib/aws-events'
5
8
  import { EcsTask } from 'aws-cdk-lib/aws-events-targets'
6
9
  import type { NestedCloudProps } from '../types'
@@ -11,37 +14,91 @@ export interface QueueStackProps extends NestedCloudProps {
11
14
  }
12
15
 
13
16
  export class QueueStack {
17
+ scope: Construct
18
+ props: QueueStackProps
19
+
14
20
  constructor(scope: Construct, props: QueueStackProps) {
15
- const rule = new Rule(scope, 'QueueRule', {
16
- // schedule to run every second
17
- ruleName: `${props.appName}-${props.appEnv}-queue-rule`,
18
- schedule: Schedule.cron({ minute: '*', hour: '*', month: '*', weekDay: '*', year: '*' }),
19
- })
20
-
21
- rule.addTarget(new EcsTask({
22
- cluster: props.cluster,
23
- taskDefinition: props.taskDefinition,
24
- containerOverrides: [
25
- {
26
- containerName: `${props.appName}-${props.appEnv}-api`,
27
- environment: [
28
- {
29
- name: 'QUEUE_WORKER',
30
- value: 'true',
31
- },
32
- {
33
- name: 'JOB',
34
- value: 'DummyJob.ts',
21
+ this.scope = scope
22
+ this.props = props
23
+ }
24
+
25
+ async init() {
26
+ const jobsDir = path.jobsPath()
27
+
28
+ try {
29
+ const files = await fs.readdir(jobsDir)
30
+
31
+ for (const file of files) {
32
+ if (file.endsWith('.ts')) {
33
+ const filePath = path.jobsPath(file)
34
+
35
+ // Await the loading of the job module
36
+ const jobModule = await this.loadJobModule(filePath)
37
+
38
+ // Now you can safely access jobModule.default.rate
39
+ const rate = jobModule.default.rate || '* * * * *'
40
+
41
+ // Rest of your logic here...
42
+ // Convert the rate to a Schedule object
43
+ const schedule = Schedule.cron(this.cronScheduleFromRate(rate))
44
+
45
+ const id = `QueueRule${pascalCase(file.replace('.ts', ''))}`
46
+ // Perform operations with the jobModule.default as needed
47
+ const rule = new Rule(this.scope, id, {
48
+ // schedule to run every second
49
+ ruleName: `${this.props.appName}-${this.props.appEnv}-queue-rule-${slug(file.replace('.ts', ''))}`,
50
+ schedule,
51
+ })
52
+
53
+ rule.addTarget(new EcsTask({
54
+ cluster: this.props.cluster,
55
+ taskDefinition: this.props.taskDefinition,
56
+ containerOverrides: [
57
+ {
58
+ containerName: `${this.props.appName}-${this.props.appEnv}-api`,
59
+ environment: [
60
+ {
61
+ name: 'QUEUE_WORKER',
62
+ value: 'true',
63
+ },
64
+ {
65
+ name: 'JOB',
66
+ value: file,
67
+ },
68
+ ],
69
+ },
70
+ ],
71
+
72
+ retryAttempts: 3,
73
+
74
+ subnetSelection: {
75
+ subnetType: ec2.SubnetType.PUBLIC, // SubnetType.PRIVATE_WITH_EGRESS
35
76
  },
36
- ],
37
- },
38
- ],
77
+ }))
78
+ }
79
+ }
80
+ }
81
+ catch (err) {
82
+ console.error('Error reading the jobs directory:', err)
83
+ }
84
+ }
85
+
86
+ // Helper function to convert a rate string to a cron object for AWS Schedule
87
+ cronScheduleFromRate(rate: string): { minute?: string, hour?: string, month?: string, weekDay?: string, year?: string } {
88
+ // Assuming the rate is in standard cron format, split it to map to the AWS Schedule.cron() parameters
89
+ const parts = rate.split(' ')
90
+ return {
91
+ minute: parts[0],
92
+ hour: parts[1],
93
+ month: parts[2],
94
+ weekDay: parts[3],
95
+ year: parts[4],
96
+ }
97
+ }
39
98
 
40
- retryAttempts: 3,
99
+ async loadJobModule(filePath: string) {
100
+ const jobModule = await import(filePath)
41
101
 
42
- subnetSelection: {
43
- subnetType: ec2.SubnetType.PUBLIC, // SubnetType.PRIVATE_WITH_EGRESS
44
- },
45
- }))
102
+ return jobModule
46
103
  }
47
104
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stacks-router-layer",
3
- "version": "0.58.55",
3
+ "version": "0.58.57",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -10,6 +10,6 @@
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
12
12
  "dependencies": {
13
- "@stacksjs/router": "^0.58.53"
13
+ "@stacksjs/router": "^0.58.56"
14
14
  }
15
15
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/collections",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks collections.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/config",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks config helper methods.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/database",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks database integration.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/datetime",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks datetime helpers.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/desktop",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks Desktop engine.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/development",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks development dependencies.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/dns",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "Easily manage your DNS.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/docs",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks way to document.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/email",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks Email integration. Painlessly create & manage your inboxes, templates, and send emails.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/enums",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "Stacks enums.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/env",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "Stacks env helper methods.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  import type { Infer, VineBoolean, VineEnum, VineNumber, VineString } from '@stacksjs/validation'
2
2
  import { validator } from '@stacksjs/validation'
3
- import env from '../../../../../config/env'
3
+ import env from 'config/env'
4
4
  import type { EnvKey } from '../../../env'
5
5
 
6
6
  // import type { Validate } from '@stacksjs/validation'
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/error-handling",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "Type safe error handling.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/eslint-config",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks.js ESLint config preset, heavily inspired by Anthony's ESLint config.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/events",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "Functional event emitting.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/faker",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "Faker functions.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/git",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks git utilities & conventions.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/health",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks Health services.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/http",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "Stacks HTTP methods.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/lint",
3
3
  "type": "module",
4
- "version": "0.58.55",
4
+ "version": "0.58.57",
5
5
  "description": "The Stacks way to lint.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",