@crossdelta/platform-sdk 0.13.2 → 0.13.4
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/bin/cli.js +312 -0
- package/bin/docs/generators/README.md +56 -0
- package/bin/docs/generators/code-style.md +96 -0
- package/bin/docs/generators/hono-bun.md +181 -0
- package/bin/docs/generators/hono-node.md +194 -0
- package/bin/docs/generators/nest.md +358 -0
- package/bin/docs/generators/service.md +564 -0
- package/bin/docs/generators/testing.md +97 -0
- package/bin/integration.collection.json +18 -0
- package/bin/templates/hono-microservice/Dockerfile.hbs +16 -0
- package/bin/templates/hono-microservice/biome.json.hbs +3 -0
- package/bin/templates/hono-microservice/src/index.ts.hbs +18 -0
- package/bin/templates/hono-microservice/tsconfig.json.hbs +14 -0
- package/bin/templates/nest-microservice/Dockerfile.hbs +37 -0
- package/bin/templates/nest-microservice/biome.json.hbs +3 -0
- package/bin/templates/nest-microservice/src/app.context.ts.hbs +17 -0
- package/bin/templates/nest-microservice/src/events/events.module.ts.hbs +8 -0
- package/bin/templates/nest-microservice/src/events/events.service.ts.hbs +22 -0
- package/bin/templates/nest-microservice/src/main.ts.hbs +34 -0
- package/bin/templates/workspace/biome.json.hbs +62 -0
- package/bin/templates/workspace/bunfig.toml.hbs +5 -0
- package/bin/templates/workspace/editorconfig.hbs +9 -0
- package/bin/templates/workspace/gitignore.hbs +15 -0
- package/bin/templates/workspace/infra/Pulumi.dev.yaml.hbs +5 -0
- package/bin/templates/workspace/infra/Pulumi.yaml.hbs +6 -0
- package/bin/templates/workspace/infra/index.ts.hbs +56 -0
- package/bin/templates/workspace/infra/package.json.hbs +23 -0
- package/bin/templates/workspace/infra/tsconfig.json.hbs +15 -0
- package/bin/templates/workspace/npmrc.hbs +2 -0
- package/bin/templates/workspace/package.json.hbs +51 -0
- package/bin/templates/workspace/packages/contracts/README.md.hbs +166 -0
- package/bin/templates/workspace/packages/contracts/package.json.hbs +22 -0
- package/bin/templates/workspace/packages/contracts/src/events/index.ts +16 -0
- package/bin/templates/workspace/packages/contracts/src/index.ts +10 -0
- package/bin/templates/workspace/packages/contracts/src/stream-policies.ts.hbs +40 -0
- package/bin/templates/workspace/packages/contracts/tsconfig.json.hbs +7 -0
- package/bin/templates/workspace/pnpm-workspace.yaml.hbs +5 -0
- package/bin/templates/workspace/turbo.json +38 -0
- package/bin/templates/workspace/turbo.json.hbs +29 -0
- package/install.sh +46 -8
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {{workspaceName}} Stream Policies
|
|
3
|
+
*
|
|
4
|
+
* Business rules for NATS JetStream stream configuration.
|
|
5
|
+
* Defines retention, replication, and storage policies per stream.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* - This file: Business rules (data)
|
|
9
|
+
* - @crossdelta/infrastructure: Deployment logic
|
|
10
|
+
* - infra/streams: Connects business rules + deployment logic
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { StreamPolicy } from '@crossdelta/infrastructure'
|
|
14
|
+
|
|
15
|
+
// Time constants for readability
|
|
16
|
+
const DAYS = 24 * 60 * 60 * 1000
|
|
17
|
+
const MB = 1024 * 1024
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Stream-specific policies
|
|
21
|
+
* Add entries here as you create new streams via event contracts
|
|
22
|
+
*/
|
|
23
|
+
export const STREAM_POLICIES: Record<string, Partial<StreamPolicy>> = {
|
|
24
|
+
// Example:
|
|
25
|
+
// ORDERS: {
|
|
26
|
+
// maxAge: 14 * DAYS,
|
|
27
|
+
// replicas: 3,
|
|
28
|
+
// },
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Default stream policy
|
|
33
|
+
* Applied to all streams without specific overrides
|
|
34
|
+
*/
|
|
35
|
+
export const DEFAULT_POLICY: Partial<StreamPolicy> = {
|
|
36
|
+
maxAge: 7 * DAYS, // 7 days default retention
|
|
37
|
+
storage: 'file', // Persistent storage
|
|
38
|
+
replicas: 1, // Single replica for non-critical streams
|
|
39
|
+
maxMsgSize: 1 * MB, // 1MB max message size
|
|
40
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://turborepo.org/schema.json",
|
|
3
|
+
"tasks": {
|
|
4
|
+
"start:dev": {
|
|
5
|
+
"cache": false,
|
|
6
|
+
"persistent": true
|
|
7
|
+
},
|
|
8
|
+
"sync-templates": {
|
|
9
|
+
"cache": false
|
|
10
|
+
},
|
|
11
|
+
"sync-templates:check": {
|
|
12
|
+
"cache": false
|
|
13
|
+
},
|
|
14
|
+
"pulumi": {},
|
|
15
|
+
"build": {
|
|
16
|
+
"cache": false,
|
|
17
|
+
"dependsOn": ["^build"]
|
|
18
|
+
},
|
|
19
|
+
"test": {
|
|
20
|
+
"cache": false
|
|
21
|
+
},
|
|
22
|
+
"format": {
|
|
23
|
+
"cache": false
|
|
24
|
+
},
|
|
25
|
+
"lint": {
|
|
26
|
+
"cache": false
|
|
27
|
+
},
|
|
28
|
+
"preview": {
|
|
29
|
+
"cache": false,
|
|
30
|
+
"persistent": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"ui": "tui",
|
|
34
|
+
"concurrency": "50",
|
|
35
|
+
"globalPassThroughEnv": [
|
|
36
|
+
"*"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://turborepo.org/schema.json",
|
|
3
|
+
"tasks": {
|
|
4
|
+
"start:dev": {
|
|
5
|
+
"cache": false,
|
|
6
|
+
"persistent": true
|
|
7
|
+
},
|
|
8
|
+
"pulumi": {},
|
|
9
|
+
"build": {
|
|
10
|
+
"cache": false
|
|
11
|
+
},
|
|
12
|
+
"test": {
|
|
13
|
+
"cache": false
|
|
14
|
+
},
|
|
15
|
+
"format": {
|
|
16
|
+
"cache": false
|
|
17
|
+
},
|
|
18
|
+
"lint": {
|
|
19
|
+
"cache": false
|
|
20
|
+
},
|
|
21
|
+
"preview": {
|
|
22
|
+
"cache": false,
|
|
23
|
+
"persistent": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"ui": "tui",
|
|
27
|
+
"concurrency": "50",
|
|
28
|
+
"globalPassThroughEnv": ["*"]
|
|
29
|
+
}
|
package/install.sh
CHANGED
|
@@ -49,22 +49,38 @@ detect_or_install_package_manager() {
|
|
|
49
49
|
printf "${YELLOW}No package manager found (bun, pnpm, yarn, npm).${NC}\n"
|
|
50
50
|
printf "${YELLOW}To use @crossdelta/platform-sdk, we recommend installing Bun (fast JavaScript runtime).${NC}\n"
|
|
51
51
|
printf "\n"
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
|
|
53
|
+
# Check if stdin is a terminal (interactive mode)
|
|
54
|
+
if [ -t 0 ]; then
|
|
55
|
+
# Interactive: ask user
|
|
56
|
+
read -p "Do you want to install Bun now? (y/n) " -n 1 -r
|
|
57
|
+
printf "\n"
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
60
|
+
printf "${RED}Installation cancelled. Please install Bun or another package manager manually.${NC}\n"
|
|
61
|
+
printf "${BLUE}Visit: https://bun.sh${NC}\n"
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
|
64
|
+
else
|
|
65
|
+
# Non-interactive (e.g., piped from curl): auto-install
|
|
66
|
+
printf "${BLUE}Auto-installing Bun (non-interactive mode)...${NC}\n"
|
|
59
67
|
fi
|
|
60
68
|
|
|
61
69
|
# Install Bun
|
|
62
70
|
printf "${BLUE}Installing Bun...${NC}\n"
|
|
63
71
|
curl -fsSL https://bun.sh/install | bash
|
|
64
72
|
|
|
65
|
-
#
|
|
66
|
-
|
|
73
|
+
# Reload Bun environment (Bun's installer writes to ~/.bashrc/~/.zshrc)
|
|
74
|
+
# But we need it in the current shell session
|
|
75
|
+
export BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
|
|
67
76
|
export PATH="$BUN_INSTALL/bin:$PATH"
|
|
77
|
+
|
|
78
|
+
# Verify Bun is now available
|
|
79
|
+
if ! command_exists bun; then
|
|
80
|
+
printf "${RED}✗ Bun installation failed or not in PATH${NC}\n"
|
|
81
|
+
printf "${YELLOW}Please restart your shell and try again${NC}\n"
|
|
82
|
+
exit 1
|
|
83
|
+
fi
|
|
68
84
|
|
|
69
85
|
printf "${GREEN}✓${NC} Bun installed successfully\n"
|
|
70
86
|
echo "bun"
|
|
@@ -102,6 +118,28 @@ if [ $# -eq 0 ]; then
|
|
|
102
118
|
printf "\n"
|
|
103
119
|
printf "${GREEN}✨ Installation successful!${NC}\n"
|
|
104
120
|
printf "\n"
|
|
121
|
+
|
|
122
|
+
# Check if pf is available in current session
|
|
123
|
+
if ! command_exists pf; then
|
|
124
|
+
# Detect shell config file
|
|
125
|
+
SHELL_CONFIG=""
|
|
126
|
+
if [ -n "$ZSH_VERSION" ] || [[ "$SHELL" == */zsh ]]; then
|
|
127
|
+
SHELL_CONFIG="~/.zshrc"
|
|
128
|
+
elif [[ "$SHELL" == */bash ]]; then
|
|
129
|
+
SHELL_CONFIG="~/.bashrc"
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
printf "${YELLOW}⚠️ To use pf in this terminal session, run:${NC}\n"
|
|
133
|
+
if [ -n "$SHELL_CONFIG" ]; then
|
|
134
|
+
printf " ${BLUE}source $SHELL_CONFIG${NC}\n"
|
|
135
|
+
else
|
|
136
|
+
printf " ${BLUE}export PATH=\"\$HOME/.bun/bin:\$PATH\"${NC}\n"
|
|
137
|
+
fi
|
|
138
|
+
printf "\n"
|
|
139
|
+
printf "${CYAN}Or simply open a new terminal.${NC}\n"
|
|
140
|
+
printf "\n"
|
|
141
|
+
fi
|
|
142
|
+
|
|
105
143
|
printf "${CYAN}Next steps:${NC}\n"
|
|
106
144
|
printf " # Create a new workspace\n"
|
|
107
145
|
printf " ${BLUE}pf new workspace my-platform${NC}\n"
|