@stacksjs/cloud 0.58.57 → 0.58.59
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/dist/index.js
CHANGED
|
@@ -1810,46 +1810,25 @@ class QueueStack {
|
|
|
1810
1810
|
}
|
|
1811
1811
|
async init() {
|
|
1812
1812
|
const jobsDir = path6.jobsPath();
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
environment: [
|
|
1833
|
-
{
|
|
1834
|
-
name: "QUEUE_WORKER",
|
|
1835
|
-
value: "true"
|
|
1836
|
-
},
|
|
1837
|
-
{
|
|
1838
|
-
name: "JOB",
|
|
1839
|
-
value: file
|
|
1840
|
-
}
|
|
1841
|
-
]
|
|
1842
|
-
}
|
|
1843
|
-
],
|
|
1844
|
-
retryAttempts: 3,
|
|
1845
|
-
subnetSelection: {
|
|
1846
|
-
subnetType: ec24.SubnetType.PUBLIC
|
|
1847
|
-
}
|
|
1848
|
-
}));
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
} catch (err2) {
|
|
1852
|
-
console.error("Error reading the jobs directory:", err2);
|
|
1813
|
+
const actionsDir = path6.appPath("Actions");
|
|
1814
|
+
const jobFiles = await fs.readdir(jobsDir);
|
|
1815
|
+
const actionFiles = await fs.readdir(actionsDir);
|
|
1816
|
+
const jobs = [];
|
|
1817
|
+
for (const file of jobFiles) {
|
|
1818
|
+
if (!file.endsWith(".ts"))
|
|
1819
|
+
continue;
|
|
1820
|
+
const jobPath = path6.jobsPath(file);
|
|
1821
|
+
const job = await this.loadModule(jobPath);
|
|
1822
|
+
this.createQueueRule(job, file);
|
|
1823
|
+
jobs.push(job);
|
|
1824
|
+
}
|
|
1825
|
+
for (const file of actionFiles) {
|
|
1826
|
+
if (!file.endsWith(".ts"))
|
|
1827
|
+
continue;
|
|
1828
|
+
const actionPath = path6.appPath(`Actions/${file}`);
|
|
1829
|
+
const action = await this.loadModule(actionPath);
|
|
1830
|
+
this.createQueueRule(action, file);
|
|
1831
|
+
jobs.push(action);
|
|
1853
1832
|
}
|
|
1854
1833
|
}
|
|
1855
1834
|
cronScheduleFromRate(rate) {
|
|
@@ -1862,10 +1841,60 @@ class QueueStack {
|
|
|
1862
1841
|
year: parts[4]
|
|
1863
1842
|
};
|
|
1864
1843
|
}
|
|
1865
|
-
async
|
|
1844
|
+
async loadModule(filePath) {
|
|
1866
1845
|
const jobModule = await import(filePath);
|
|
1867
1846
|
return jobModule;
|
|
1868
1847
|
}
|
|
1848
|
+
createQueueRule(module, file) {
|
|
1849
|
+
const rate = module.default?.rate;
|
|
1850
|
+
if (!rate || module.default?.enabled === false)
|
|
1851
|
+
return;
|
|
1852
|
+
const schedule = Schedule.cron(this.cronScheduleFromRate(rate));
|
|
1853
|
+
const id = `QueueRule${pascalCase(file.replace(".ts", ""))}`;
|
|
1854
|
+
const rule = new Rule(this.scope, id, {
|
|
1855
|
+
ruleName: `${this.props.appName}-${this.props.appEnv}-queue-rule-${slug2(file.replace(".ts", ""))}`,
|
|
1856
|
+
schedule
|
|
1857
|
+
});
|
|
1858
|
+
rule.addTarget(new EcsTask({
|
|
1859
|
+
cluster: this.props.cluster,
|
|
1860
|
+
taskDefinition: this.props.taskDefinition,
|
|
1861
|
+
containerOverrides: [
|
|
1862
|
+
{
|
|
1863
|
+
containerName: `${this.props.appName}-${this.props.appEnv}-api`,
|
|
1864
|
+
environment: [
|
|
1865
|
+
{
|
|
1866
|
+
name: "QUEUE_WORKER",
|
|
1867
|
+
value: "true"
|
|
1868
|
+
},
|
|
1869
|
+
{
|
|
1870
|
+
name: "JOB",
|
|
1871
|
+
value: file
|
|
1872
|
+
},
|
|
1873
|
+
{
|
|
1874
|
+
name: "JOB_BACKOFF_FACTOR",
|
|
1875
|
+
value: module.default?.backoffFactor
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
name: "JOB_RETRIES",
|
|
1879
|
+
value: module.default?.tries
|
|
1880
|
+
},
|
|
1881
|
+
{
|
|
1882
|
+
name: "JOB_INITIAL_DELAY",
|
|
1883
|
+
value: module.default?.initialDelay
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
name: "JOB_JITTER",
|
|
1887
|
+
value: module.default?.jitter
|
|
1888
|
+
}
|
|
1889
|
+
]
|
|
1890
|
+
}
|
|
1891
|
+
],
|
|
1892
|
+
retryAttempts: 1,
|
|
1893
|
+
subnetSelection: {
|
|
1894
|
+
subnetType: ec24.SubnetType.PUBLIC
|
|
1895
|
+
}
|
|
1896
|
+
}));
|
|
1897
|
+
}
|
|
1869
1898
|
}
|
|
1870
1899
|
|
|
1871
1900
|
// src/cloud/index.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/cloud",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.58.
|
|
4
|
+
"version": "0.58.59",
|
|
5
5
|
"description": "The Stacks cloud/serverless integration & implementation.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -55,19 +55,19 @@
|
|
|
55
55
|
"prepublishOnly": "bun run build"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@aws-sdk/client-bedrock": "^3.
|
|
59
|
-
"@aws-sdk/client-cloudformation": "^3.
|
|
60
|
-
"@aws-sdk/client-cloudfront": "^3.
|
|
61
|
-
"@aws-sdk/client-cloudwatch-logs": "^3.
|
|
62
|
-
"@aws-sdk/client-ec2": "^3.
|
|
63
|
-
"@aws-sdk/client-efs": "^3.
|
|
64
|
-
"@aws-sdk/client-iam": "^3.
|
|
65
|
-
"@aws-sdk/client-lambda": "^3.
|
|
66
|
-
"@aws-sdk/client-route-53-domains": "^3.
|
|
67
|
-
"@aws-sdk/client-s3": "^3.
|
|
68
|
-
"@aws-sdk/client-ses": "^3.
|
|
69
|
-
"@aws-sdk/client-sesv2": "^3.
|
|
70
|
-
"@aws-sdk/client-ssm": "^3.
|
|
58
|
+
"@aws-sdk/client-bedrock": "^3.511.0",
|
|
59
|
+
"@aws-sdk/client-cloudformation": "^3.511.0",
|
|
60
|
+
"@aws-sdk/client-cloudfront": "^3.511.0",
|
|
61
|
+
"@aws-sdk/client-cloudwatch-logs": "^3.511.0",
|
|
62
|
+
"@aws-sdk/client-ec2": "^3.511.0",
|
|
63
|
+
"@aws-sdk/client-efs": "^3.511.0",
|
|
64
|
+
"@aws-sdk/client-iam": "^3.511.0",
|
|
65
|
+
"@aws-sdk/client-lambda": "^3.511.0",
|
|
66
|
+
"@aws-sdk/client-route-53-domains": "^3.511.0",
|
|
67
|
+
"@aws-sdk/client-s3": "^3.511.0",
|
|
68
|
+
"@aws-sdk/client-ses": "^3.511.0",
|
|
69
|
+
"@aws-sdk/client-sesv2": "^3.511.0",
|
|
70
|
+
"@aws-sdk/client-ssm": "^3.511.0",
|
|
71
71
|
"@stacksjs/config": "latest",
|
|
72
72
|
"@stacksjs/env": "latest",
|
|
73
73
|
"@stacksjs/logging": "latest",
|
|
@@ -79,20 +79,20 @@
|
|
|
79
79
|
"@stacksjs/validation": "latest"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@aws-sdk/client-bedrock": "^3.
|
|
83
|
-
"@aws-sdk/client-cloudformation": "^3.
|
|
84
|
-
"@aws-sdk/client-cloudfront": "^3.
|
|
85
|
-
"@aws-sdk/client-cloudwatch-logs": "^3.
|
|
86
|
-
"@aws-sdk/client-dynamodb": "3.
|
|
87
|
-
"@aws-sdk/client-ec2": "^3.
|
|
88
|
-
"@aws-sdk/client-efs": "^3.
|
|
89
|
-
"@aws-sdk/client-iam": "^3.
|
|
90
|
-
"@aws-sdk/client-lambda": "^3.
|
|
91
|
-
"@aws-sdk/client-route-53-domains": "^3.
|
|
92
|
-
"@aws-sdk/client-s3": "^3.
|
|
93
|
-
"@aws-sdk/client-ses": "^3.
|
|
94
|
-
"@aws-sdk/client-sesv2": "^3.
|
|
95
|
-
"@aws-sdk/client-ssm": "^3.
|
|
82
|
+
"@aws-sdk/client-bedrock": "^3.511.0",
|
|
83
|
+
"@aws-sdk/client-cloudformation": "^3.511.0",
|
|
84
|
+
"@aws-sdk/client-cloudfront": "^3.511.0",
|
|
85
|
+
"@aws-sdk/client-cloudwatch-logs": "^3.511.0",
|
|
86
|
+
"@aws-sdk/client-dynamodb": "3.511.0",
|
|
87
|
+
"@aws-sdk/client-ec2": "^3.511.0",
|
|
88
|
+
"@aws-sdk/client-efs": "^3.511.0",
|
|
89
|
+
"@aws-sdk/client-iam": "^3.511.0",
|
|
90
|
+
"@aws-sdk/client-lambda": "^3.511.0",
|
|
91
|
+
"@aws-sdk/client-route-53-domains": "^3.511.0",
|
|
92
|
+
"@aws-sdk/client-s3": "^3.511.0",
|
|
93
|
+
"@aws-sdk/client-ses": "^3.511.0",
|
|
94
|
+
"@aws-sdk/client-sesv2": "^3.511.0",
|
|
95
|
+
"@aws-sdk/client-ssm": "^3.511.0",
|
|
96
96
|
"@stacksjs/config": "latest",
|
|
97
97
|
"@stacksjs/dns": "latest",
|
|
98
98
|
"@stacksjs/env": "latest",
|
|
@@ -102,18 +102,18 @@
|
|
|
102
102
|
"@stacksjs/storage": "latest",
|
|
103
103
|
"@stacksjs/utils": "latest",
|
|
104
104
|
"@stacksjs/validation": "latest",
|
|
105
|
-
"aws-cdk": "^2.
|
|
106
|
-
"aws-cdk-lib": "^2.
|
|
105
|
+
"aws-cdk": "^2.127.0",
|
|
106
|
+
"aws-cdk-lib": "^2.127.0",
|
|
107
107
|
"aws4fetch": "^1.0.17",
|
|
108
108
|
"constructs": "^10.3.0"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@oclif/plugin-plugins": "^4.2.
|
|
111
|
+
"@oclif/plugin-plugins": "^4.2.2",
|
|
112
112
|
"@stacksjs/cli": "latest",
|
|
113
113
|
"@stacksjs/development": "latest",
|
|
114
114
|
"@stacksjs/env": "latest",
|
|
115
115
|
"jszip": "^3.10.1",
|
|
116
|
-
"oclif": "^4.4.
|
|
116
|
+
"oclif": "^4.4.10",
|
|
117
117
|
"source-map-support": "^0.5.21"
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aws-sdk-layer",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.58",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "aws-sdk-layer",
|
|
9
|
-
"version": "0.58.
|
|
9
|
+
"version": "0.58.58",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"aws-sdk": "^2.
|
|
12
|
+
"aws-sdk": "^2.1555.0"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"node_modules/available-typed-arrays": {
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"node_modules/aws-sdk": {
|
|
27
|
-
"version": "2.
|
|
28
|
-
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.
|
|
29
|
-
"integrity": "sha512-
|
|
27
|
+
"version": "2.1555.0",
|
|
28
|
+
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1555.0.tgz",
|
|
29
|
+
"integrity": "sha512-hjYs1MQkJxdHnoZm8hypqGy4PQKWVUs19McdXRXWNXr97V0il4xcUpIfvjHQ9x9EjP0p/jyIx9/BtyrR68jnUQ==",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"buffer": "4.9.2",
|
|
32
32
|
"events": "1.1.1",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aws-sdk-layer",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.59",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"aws-sdk": "^2.
|
|
13
|
+
"aws-sdk": "^2.1555.0"
|
|
14
14
|
}
|
|
15
15
|
}
|
package/src/cloud/queue.ts
CHANGED
|
@@ -24,63 +24,39 @@ export class QueueStack {
|
|
|
24
24
|
|
|
25
25
|
async init() {
|
|
26
26
|
const jobsDir = path.jobsPath()
|
|
27
|
+
const actionsDir = path.appPath('Actions')
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
76
|
-
},
|
|
77
|
-
}))
|
|
78
|
-
}
|
|
79
|
-
}
|
|
29
|
+
const jobFiles = await fs.readdir(jobsDir)
|
|
30
|
+
const actionFiles = await fs.readdir(actionsDir)
|
|
31
|
+
const jobs = []
|
|
32
|
+
|
|
33
|
+
// then, need to loop through all app/Jobs/*.ts and create a rule for each, potentially overwriting the Schedule.ts jobs
|
|
34
|
+
for (const file of jobFiles) {
|
|
35
|
+
if (!file.endsWith('.ts'))
|
|
36
|
+
continue
|
|
37
|
+
|
|
38
|
+
const jobPath = path.jobsPath(file)
|
|
39
|
+
|
|
40
|
+
// Await the loading of the job module
|
|
41
|
+
const job = await this.loadModule(jobPath)
|
|
42
|
+
this.createQueueRule(job, file)
|
|
43
|
+
jobs.push(job)
|
|
80
44
|
}
|
|
81
|
-
|
|
82
|
-
|
|
45
|
+
|
|
46
|
+
for (const file of actionFiles) {
|
|
47
|
+
if (!file.endsWith('.ts'))
|
|
48
|
+
continue
|
|
49
|
+
|
|
50
|
+
const actionPath = path.appPath(`Actions/${file}`)
|
|
51
|
+
|
|
52
|
+
// Await the loading of the job module
|
|
53
|
+
const action = await this.loadModule(actionPath)
|
|
54
|
+
this.createQueueRule(action, file)
|
|
55
|
+
jobs.push(action)
|
|
83
56
|
}
|
|
57
|
+
|
|
58
|
+
// for (const job of jobs)
|
|
59
|
+
// await this.createQueueRule(job, file)
|
|
84
60
|
}
|
|
85
61
|
|
|
86
62
|
// Helper function to convert a rate string to a cron object for AWS Schedule
|
|
@@ -96,9 +72,74 @@ export class QueueStack {
|
|
|
96
72
|
}
|
|
97
73
|
}
|
|
98
74
|
|
|
99
|
-
async
|
|
75
|
+
async loadModule(filePath: string) {
|
|
100
76
|
const jobModule = await import(filePath)
|
|
101
77
|
|
|
102
78
|
return jobModule
|
|
103
79
|
}
|
|
80
|
+
|
|
81
|
+
// TODO: narrow any type -> jobs & actions are allowed
|
|
82
|
+
createQueueRule(module: { default: any }, file: string) {
|
|
83
|
+
// Now you can safely access module.default.rate
|
|
84
|
+
const rate = module.default?.rate
|
|
85
|
+
|
|
86
|
+
// if no rate or job is disabled, no need to schedule, skip
|
|
87
|
+
if (!rate || module.default?.enabled === false)
|
|
88
|
+
return
|
|
89
|
+
|
|
90
|
+
// Convert the rate to a Schedule object
|
|
91
|
+
const schedule = Schedule.cron(this.cronScheduleFromRate(rate))
|
|
92
|
+
|
|
93
|
+
const id = `QueueRule${pascalCase(file.replace('.ts', ''))}`
|
|
94
|
+
|
|
95
|
+
// Perform operations with the jobModule.default as needed
|
|
96
|
+
const rule = new Rule(this.scope, id, {
|
|
97
|
+
// schedule to run every second
|
|
98
|
+
ruleName: `${this.props.appName}-${this.props.appEnv}-queue-rule-${slug(file.replace('.ts', ''))}`,
|
|
99
|
+
schedule,
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
rule.addTarget(new EcsTask({
|
|
103
|
+
cluster: this.props.cluster,
|
|
104
|
+
taskDefinition: this.props.taskDefinition,
|
|
105
|
+
containerOverrides: [
|
|
106
|
+
{
|
|
107
|
+
containerName: `${this.props.appName}-${this.props.appEnv}-api`,
|
|
108
|
+
environment: [
|
|
109
|
+
{
|
|
110
|
+
name: 'QUEUE_WORKER',
|
|
111
|
+
value: 'true',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'JOB',
|
|
115
|
+
value: file,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'JOB_BACKOFF_FACTOR',
|
|
119
|
+
value: module.default?.backoffFactor,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'JOB_RETRIES',
|
|
123
|
+
value: module.default?.tries,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: 'JOB_INITIAL_DELAY',
|
|
127
|
+
value: module.default?.initialDelay,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'JOB_JITTER',
|
|
131
|
+
value: module.default?.jitter,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
|
|
137
|
+
retryAttempts: 1, // we utilize a custom retry mechanism in the job itself
|
|
138
|
+
// retryAttempts: module.default.tries || 3,
|
|
139
|
+
|
|
140
|
+
subnetSelection: {
|
|
141
|
+
subnetType: ec2.SubnetType.PUBLIC, // SubnetType.PRIVATE_WITH_EGRESS
|
|
142
|
+
},
|
|
143
|
+
}))
|
|
144
|
+
}
|
|
104
145
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stacks-router-layer",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.59",
|
|
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.58"
|
|
14
14
|
}
|
|
15
15
|
}
|