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.
- package/core/actions/dist/src/upgrade.js +1 -1
- package/core/actions/package.json +1 -1
- package/core/ai/package.json +1 -1
- package/core/alias/package.json +1 -1
- package/core/analytics/package.json +1 -1
- package/core/api/package.json +1 -1
- package/core/arrays/package.json +1 -1
- package/core/auth/package.json +1 -1
- package/core/buddy/dist/{chunk-d52e40a990b45728.js → chunk-e9c0ec1a3b7be088.js} +120 -92
- package/core/buddy/dist/cli.js +1 -1
- package/core/buddy/dist/index.js +1 -1
- package/core/buddy/package.json +1 -1
- package/core/buddy/src/commands/configure.ts +38 -27
- package/core/buddy/src/commands/deploy.ts +81 -56
- package/core/buddy/src/commands/setup.ts +11 -9
- package/core/build/package.json +1 -1
- package/core/bun-create/bud/package.json +1 -1
- package/core/bun-create/buddy/package.json +1 -1
- package/core/bun-create/stack/package.json +1 -1
- package/core/bun-create/stacks/package.json +1 -1
- package/core/bun-create/stx/package.json +1 -1
- package/core/bun-plugin-yaml/package.json +1 -1
- package/core/cache/package.json +1 -1
- package/core/chat/package.json +1 -1
- package/core/cli/dist/index.js +7 -1
- package/core/cli/package.json +1 -1
- package/core/cli/src/exec.ts +8 -0
- package/core/cloud/deploy.ts +3 -2
- package/core/cloud/dist/index.js +131 -70
- package/core/cloud/package.json +1 -1
- package/core/cloud/src/cloud/aws-sdk-layer/nodejs/package.json +1 -1
- package/core/cloud/src/cloud/index.ts +76 -50
- package/core/cloud/src/cloud/queue.ts +86 -29
- package/core/cloud/src/cloud/router-layer/nodejs/package.json +2 -2
- package/core/collections/package.json +1 -1
- package/core/config/package.json +1 -1
- package/core/database/package.json +1 -1
- package/core/datetime/package.json +1 -1
- package/core/desktop/package.json +1 -1
- package/core/development/package.json +1 -1
- package/core/dns/package.json +1 -1
- package/core/docs/package.json +1 -1
- package/core/email/package.json +1 -1
- package/core/enums/package.json +1 -1
- package/core/env/package.json +1 -1
- package/core/env/src/types.ts +1 -1
- package/core/error-handling/package.json +1 -1
- package/core/eslint-config/package.json +1 -1
- package/core/events/package.json +1 -1
- package/core/faker/package.json +1 -1
- package/core/git/package.json +1 -1
- package/core/health/package.json +1 -1
- package/core/http/package.json +1 -1
- package/core/lint/package.json +1 -1
- package/core/logging/dist/index.js +161 -4
- package/core/logging/package.json +1 -1
- package/core/logging/src/index.ts +55 -12
- package/core/notifications/package.json +1 -1
- package/core/objects/package.json +1 -1
- package/core/orm/package.json +1 -1
- package/core/path/dist/index.js +1 -1
- package/core/path/package.json +1 -1
- package/core/path/src/index.ts +1 -1
- package/core/payments/package.json +1 -1
- package/core/push/package.json +1 -1
- package/core/query-builder/package.json +1 -1
- package/core/queue/dist/index.js +3 -1
- package/core/queue/package.json +1 -1
- package/core/queue/src/index.ts +3 -1
- package/core/raycast/package.json +1 -1
- package/core/realtime/package.json +1 -1
- package/core/repl/package.json +1 -1
- package/core/router/package.json +1 -1
- package/core/scheduler/package.json +1 -1
- package/core/search-engine/package.json +1 -1
- package/core/security/package.json +1 -1
- package/core/server/package.json +1 -1
- package/core/signals/package.json +1 -1
- package/core/slug/package.json +1 -1
- package/core/sms/package.json +1 -1
- package/core/storage/package.json +1 -1
- package/core/strings/package.json +1 -1
- package/core/tables/package.json +1 -1
- package/core/testing/package.json +1 -1
- package/core/tinker/package.json +1 -1
- package/core/tunnel/package.json +1 -1
- package/core/types/dist/index.js +8 -3
- package/core/types/package.json +1 -1
- package/core/types/src/configure.ts +7 -0
- package/core/types/src/cron-jobs.ts +8 -3
- package/core/ui/package.json +1 -1
- package/core/utils/dist/index.js +1 -1
- package/core/utils/package.json +1 -1
- package/core/validation/package.json +1 -1
- package/core/vite/dist/index.js +1 -1
- package/core/vite/package.json +1 -1
- package/core/whois/package.json +1 -1
- package/core/x-ray/package.json +1 -1
- package/core/zsh-buddy/package.json +1 -1
- package/ide/vscode/package.json +1 -1
- 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
|
-
|
|
29
|
-
|
|
46
|
+
this.scope = scope
|
|
47
|
+
this.props = props
|
|
30
48
|
|
|
31
|
-
|
|
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
|
-
|
|
56
|
+
this.storage = new StorageStack(this, {
|
|
37
57
|
...props,
|
|
38
|
-
kmsKey: security.kmsKey,
|
|
58
|
+
kmsKey: this.security.kmsKey,
|
|
39
59
|
})
|
|
40
60
|
|
|
41
|
-
|
|
61
|
+
this.network = new NetworkStack(this, props)
|
|
42
62
|
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
111
|
+
await this.queue.init()
|
|
87
112
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
99
|
+
async loadJobModule(filePath: string) {
|
|
100
|
+
const jobModule = await import(filePath)
|
|
41
101
|
|
|
42
|
-
|
|
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.
|
|
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.
|
|
13
|
+
"@stacksjs/router": "^0.58.56"
|
|
14
14
|
}
|
|
15
15
|
}
|
package/core/config/package.json
CHANGED
package/core/dns/package.json
CHANGED
package/core/docs/package.json
CHANGED
package/core/email/package.json
CHANGED
package/core/enums/package.json
CHANGED
package/core/env/package.json
CHANGED
package/core/env/src/types.ts
CHANGED
|
@@ -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 '
|
|
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/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.58.
|
|
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",
|
package/core/events/package.json
CHANGED
package/core/faker/package.json
CHANGED
package/core/git/package.json
CHANGED
package/core/health/package.json
CHANGED
package/core/http/package.json
CHANGED