@stonyx/orm 0.2.1-alpha.2 → 0.2.1-alpha.21

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 (46) hide show
  1. package/.claude/code-style-rules.md +44 -0
  2. package/.claude/hooks.md +250 -0
  3. package/.claude/index.md +292 -0
  4. package/.claude/usage-patterns.md +300 -0
  5. package/.claude/views.md +292 -0
  6. package/.github/workflows/ci.yml +5 -25
  7. package/.github/workflows/publish.yml +24 -116
  8. package/README.md +461 -15
  9. package/config/environment.js +29 -6
  10. package/improvements.md +139 -0
  11. package/package.json +24 -8
  12. package/project-structure.md +343 -0
  13. package/scripts/setup-test-db.sh +21 -0
  14. package/src/aggregates.js +93 -0
  15. package/src/belongs-to.js +4 -1
  16. package/src/commands.js +170 -0
  17. package/src/db.js +132 -6
  18. package/src/has-many.js +4 -1
  19. package/src/hooks.js +124 -0
  20. package/src/index.js +12 -2
  21. package/src/main.js +77 -4
  22. package/src/manage-record.js +30 -4
  23. package/src/migrate.js +72 -0
  24. package/src/model-property.js +2 -2
  25. package/src/model.js +11 -0
  26. package/src/mysql/connection.js +28 -0
  27. package/src/mysql/migration-generator.js +286 -0
  28. package/src/mysql/migration-runner.js +110 -0
  29. package/src/mysql/mysql-db.js +473 -0
  30. package/src/mysql/query-builder.js +64 -0
  31. package/src/mysql/schema-introspector.js +325 -0
  32. package/src/mysql/type-map.js +37 -0
  33. package/src/orm-request.js +313 -53
  34. package/src/plural-registry.js +12 -0
  35. package/src/record.js +35 -8
  36. package/src/serializer.js +9 -2
  37. package/src/setup-rest-server.js +5 -2
  38. package/src/store.js +130 -1
  39. package/src/utils.js +1 -1
  40. package/src/view-resolver.js +183 -0
  41. package/src/view.js +21 -0
  42. package/test-events-setup.js +41 -0
  43. package/test-hooks-manual.js +54 -0
  44. package/test-hooks-with-logging.js +52 -0
  45. package/.claude/project-structure.md +0 -578
  46. package/stonyx-bootstrap.cjs +0 -30
@@ -1,7 +1,8 @@
1
1
  name: Publish to NPM
2
2
 
3
3
  on:
4
- # Manual trigger (kept for flexibility)
4
+ repository_dispatch:
5
+ types: [cascade-publish]
5
6
  workflow_dispatch:
6
7
  inputs:
7
8
  version-type:
@@ -9,7 +10,6 @@ on:
9
10
  required: true
10
11
  type: choice
11
12
  options:
12
- - alpha
13
13
  - patch
14
14
  - minor
15
15
  - major
@@ -17,127 +17,35 @@ on:
17
17
  description: 'Custom version (optional, overrides version-type)'
18
18
  required: false
19
19
  type: string
20
-
21
- # Auto-publish alpha on PR
22
20
  pull_request:
23
21
  types: [opened, synchronize, reopened]
24
- branches: [main, dev]
25
-
26
- # Auto-publish stable on merge to main
22
+ branches: [main]
27
23
  push:
28
24
  branches: [main]
29
25
 
26
+ concurrency:
27
+ group: ${{ github.event_name == 'repository_dispatch' && 'cascade-update' || format('publish-{0}', github.ref) }}
28
+ cancel-in-progress: false
29
+
30
30
  permissions:
31
31
  contents: write
32
- id-token: write # Required for npm provenance
33
- pull-requests: write # For PR comments
32
+ id-token: write
33
+ pull-requests: write
34
34
 
35
35
  jobs:
36
36
  publish:
37
- runs-on: ubuntu-latest
38
-
39
- steps:
40
- - name: Checkout code
41
- uses: actions/checkout@v3
42
- with:
43
- fetch-depth: 0
44
- # For PR events, check out the PR branch
45
- ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
46
-
47
- - name: Setup pnpm
48
- uses: pnpm/action-setup@v4
49
- with:
50
- version: 9
51
-
52
- - name: Set up Node.js
53
- uses: actions/setup-node@v3
54
- with:
55
- node-version: 24.13.0
56
- cache: 'pnpm'
57
- registry-url: 'https://registry.npmjs.org'
58
-
59
- - name: Install dependencies
60
- run: pnpm install --frozen-lockfile
61
-
62
- - name: Run tests
63
- run: pnpm test
64
-
65
- - name: Configure git
66
- run: |
67
- git config user.name "github-actions[bot]"
68
- git config user.email "github-actions[bot]@users.noreply.github.com"
69
-
70
- # Determine version type based on trigger
71
- - name: Determine version bump type
72
- id: version-type
73
- run: |
74
- if [ "${{ github.event_name }}" = "pull_request" ]; then
75
- echo "type=alpha" >> $GITHUB_OUTPUT
76
- elif [ "${{ github.event_name }}" = "push" ]; then
77
- echo "type=patch" >> $GITHUB_OUTPUT
78
- elif [ "${{ github.event.inputs.custom-version }}" != "" ]; then
79
- echo "type=custom" >> $GITHUB_OUTPUT
80
- else
81
- echo "type=${{ github.event.inputs.version-type }}" >> $GITHUB_OUTPUT
82
- fi
83
-
84
- # Version bumping
85
- - name: Bump version (custom)
86
- if: steps.version-type.outputs.type == 'custom'
87
- run: pnpm version ${{ github.event.inputs.custom-version }} --no-git-tag-version
88
-
89
- - name: Bump version (alpha)
90
- if: steps.version-type.outputs.type == 'alpha'
91
- run: pnpm version prerelease --preid=alpha --no-git-tag-version
92
-
93
- - name: Bump version (patch/minor/major)
94
- if: steps.version-type.outputs.type == 'patch' || steps.version-type.outputs.type == 'minor' || steps.version-type.outputs.type == 'major'
95
- run: pnpm version ${{ steps.version-type.outputs.type }} --no-git-tag-version
96
-
97
- - name: Get package version
98
- id: package-version
99
- run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
100
-
101
- # Publishing
102
- - name: Publish to NPM (alpha)
103
- if: contains(steps.package-version.outputs.version, 'alpha')
104
- run: pnpm publish --tag alpha --access public --no-git-checks
105
-
106
- - name: Publish to NPM (stable)
107
- if: "!contains(steps.package-version.outputs.version, 'alpha')"
108
- run: pnpm publish --access public
109
-
110
- # Only commit and tag for stable releases (push to main or manual stable)
111
- - name: Commit version bump and create tag
112
- if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !contains(steps.package-version.outputs.version, 'alpha'))
113
- run: |
114
- git add package.json
115
- git commit -m "chore: release v${{ steps.package-version.outputs.version }}"
116
- git tag v${{ steps.package-version.outputs.version }}
117
- git push origin main --tags
118
-
119
- - name: Create GitHub Release
120
- if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !contains(steps.package-version.outputs.version, 'alpha'))
121
- uses: actions/create-release@v1
122
- env:
123
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124
- with:
125
- tag_name: v${{ steps.package-version.outputs.version }}
126
- release_name: v${{ steps.package-version.outputs.version }}
127
- draft: false
128
- prerelease: false
129
-
130
- # Add PR comment with alpha version info
131
- - name: Comment on PR with alpha version
132
- if: github.event_name == 'pull_request'
133
- uses: actions/github-script@v6
134
- with:
135
- script: |
136
- const version = '${{ steps.package-version.outputs.version }}';
137
- const packageName = require('./package.json').name;
138
- github.rest.issues.createComment({
139
- issue_number: context.issue.number,
140
- owner: context.repo.owner,
141
- repo: context.repo.repo,
142
- body: `## 🚀 Alpha Version Published\n\n**Version:** \`${version}\`\n\n**Install:**\n\`\`\`bash\npnpm add ${packageName}@${version}\n# or\npnpm add ${packageName}@alpha # latest alpha\n\`\`\`\n\nThis alpha version is now available for testing!`
143
- });
37
+ if: "!contains(github.event.head_commit.message, '[skip ci]')"
38
+ uses: abofs/stonyx-workflows/.github/workflows/npm-publish.yml@main
39
+ with:
40
+ version-type: ${{ github.event.inputs.version-type }}
41
+ custom-version: ${{ github.event.inputs.custom-version }}
42
+ cascade-source: ${{ github.event.client_payload.source_package || '' }}
43
+ secrets: inherit
44
+
45
+ cascade:
46
+ needs: publish
47
+ uses: abofs/stonyx-workflows/.github/workflows/cascade.yml@main
48
+ with:
49
+ package-name: ${{ needs.publish.outputs.package-name }}
50
+ published-version: ${{ needs.publish.outputs.published-version }}
51
+ secrets: inherit