@intelmesh/sdk 0.1.0
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/.github/scripts/compute-disttag.sh +47 -0
- package/.github/workflows/release.yml +206 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +2 -0
- package/.prettierrc +8 -0
- package/CLAUDE.md +37 -0
- package/LICENSE +21 -0
- package/commitlint.config.cjs +3 -0
- package/dist/index.d.ts +1293 -0
- package/dist/index.js +1651 -0
- package/docs/superpowers/plans/2026-04-10-release-pipeline.md +798 -0
- package/docs/superpowers/specs/2026-04-10-release-pipeline-design.md +309 -0
- package/eslint.config.mjs +38 -0
- package/package.json +72 -0
- package/src/builders/event.ts +72 -0
- package/src/builders/rule.ts +143 -0
- package/src/client/errors.ts +171 -0
- package/src/client/http.ts +209 -0
- package/src/client/intelmesh.ts +57 -0
- package/src/client/pagination.ts +50 -0
- package/src/generated/types.ts +11 -0
- package/src/index.ts +106 -0
- package/src/provision/index.ts +6 -0
- package/src/provision/provisioner.ts +326 -0
- package/src/provision/rule-builder.ts +193 -0
- package/src/resources/apikeys.ts +63 -0
- package/src/resources/audit.ts +29 -0
- package/src/resources/evaluations.ts +38 -0
- package/src/resources/events.ts +61 -0
- package/src/resources/lists.ts +91 -0
- package/src/resources/phases.ts +71 -0
- package/src/resources/rules.ts +98 -0
- package/src/resources/scopes.ts +71 -0
- package/src/resources/scores.ts +63 -0
- package/src/testkit/assertion.ts +76 -0
- package/src/testkit/harness.ts +252 -0
- package/src/testkit/index.ts +7 -0
- package/src/types.ts +330 -0
- package/tests/client/errors.test.ts +159 -0
- package/tests/provision/provisioner.test.ts +311 -0
- package/tests/scripts/compute-disttag.test.ts +178 -0
- package/tests/testkit/harness.test.ts +291 -0
- package/tsconfig.eslint.json +8 -0
- package/tsconfig.json +29 -0
- package/vitest.config.ts +14 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Compute npm dist-tag and prerelease flag from a git tag name.
|
|
3
|
+
#
|
|
4
|
+
# Reads (env):
|
|
5
|
+
# GITHUB_REF_NAME git tag name, e.g. "v1.2.3" or "v1.2.3-beta.1"
|
|
6
|
+
# GITHUB_OUTPUT path to GitHub Actions step output file
|
|
7
|
+
#
|
|
8
|
+
# Writes to $GITHUB_OUTPUT:
|
|
9
|
+
# version semver without leading "v"
|
|
10
|
+
# disttag npm dist-tag ("latest" for stable, lowercased suffix prefix otherwise)
|
|
11
|
+
# is_prerelease "true" for any tag with a "-" suffix, else "false"
|
|
12
|
+
#
|
|
13
|
+
# Exits:
|
|
14
|
+
# 0 on success
|
|
15
|
+
# 1 if GITHUB_REF_NAME or GITHUB_OUTPUT is unset or empty
|
|
16
|
+
# 1 if GITHUB_REF_NAME is not a valid semver tag
|
|
17
|
+
|
|
18
|
+
set -euo pipefail
|
|
19
|
+
|
|
20
|
+
tag="${GITHUB_REF_NAME:?GITHUB_REF_NAME is required}"
|
|
21
|
+
: "${GITHUB_OUTPUT:?GITHUB_OUTPUT is required}"
|
|
22
|
+
|
|
23
|
+
semver_re='^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'
|
|
24
|
+
if [[ ! "$tag" =~ $semver_re ]]; then
|
|
25
|
+
echo "::error::GITHUB_REF_NAME='$tag' is not a valid semver tag (expected vMAJOR.MINOR.PATCH[-PRERELEASE])" >&2
|
|
26
|
+
exit 1
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
version="${tag#v}"
|
|
30
|
+
|
|
31
|
+
if [[ "$version" == *-* ]]; then
|
|
32
|
+
suffix="${version#*-}"
|
|
33
|
+
disttag="${suffix%%.*}"
|
|
34
|
+
disttag="${disttag,,}"
|
|
35
|
+
is_prerelease=true
|
|
36
|
+
else
|
|
37
|
+
disttag="latest"
|
|
38
|
+
is_prerelease=false
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
{
|
|
42
|
+
echo "version=$version"
|
|
43
|
+
echo "disttag=$disttag"
|
|
44
|
+
echo "is_prerelease=$is_prerelease"
|
|
45
|
+
} >> "$GITHUB_OUTPUT"
|
|
46
|
+
|
|
47
|
+
echo "Resolved: tag=$tag version=$version disttag=$disttag prerelease=$is_prerelease" >&2
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v[0-9]+.[0-9]+.[0-9]+'
|
|
7
|
+
- 'v[0-9]+.[0-9]+.[0-9]+-*'
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: release-${{ github.ref }}
|
|
15
|
+
cancel-in-progress: false
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
verify-signature:
|
|
19
|
+
name: Verify commit and tag are signed
|
|
20
|
+
runs-on: ubuntu-24.04
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
steps:
|
|
24
|
+
# No checkout needed: this job only queries the GitHub API via `gh`.
|
|
25
|
+
- name: Verify commit signature
|
|
26
|
+
env:
|
|
27
|
+
GH_TOKEN: ${{ github.token }}
|
|
28
|
+
run: |
|
|
29
|
+
set -euo pipefail
|
|
30
|
+
commit_sha="${GITHUB_SHA}"
|
|
31
|
+
repo="${GITHUB_REPOSITORY}"
|
|
32
|
+
|
|
33
|
+
commit_json=$(gh api "repos/${repo}/commits/${commit_sha}")
|
|
34
|
+
verified=$(jq -r '.commit.verification.verified' <<<"${commit_json}")
|
|
35
|
+
reason=$(jq -r '.commit.verification.reason' <<<"${commit_json}")
|
|
36
|
+
|
|
37
|
+
echo "commit=${commit_sha} verified=${verified} reason=${reason}"
|
|
38
|
+
|
|
39
|
+
if [ "${verified}" != "true" ]; then
|
|
40
|
+
echo "::error title=Unsigned commit::Commit ${commit_sha} is NOT verified by GitHub. Reason: ${reason}. Refusing to release."
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
- name: Verify tag is a signed annotated tag
|
|
45
|
+
env:
|
|
46
|
+
GH_TOKEN: ${{ github.token }}
|
|
47
|
+
run: |
|
|
48
|
+
set -euo pipefail
|
|
49
|
+
tag="${GITHUB_REF_NAME}"
|
|
50
|
+
repo="${GITHUB_REPOSITORY}"
|
|
51
|
+
|
|
52
|
+
ref_json=$(gh api "repos/${repo}/git/refs/tags/${tag}")
|
|
53
|
+
obj_type=$(jq -r '.object.type' <<<"${ref_json}")
|
|
54
|
+
obj_sha=$(jq -r '.object.sha' <<<"${ref_json}")
|
|
55
|
+
|
|
56
|
+
if [ "${obj_type}" != "tag" ]; then
|
|
57
|
+
echo "::error title=Lightweight tag::Tag ${tag} is a lightweight tag (object.type=${obj_type}). Use 'git tag -s ${tag}' to create a signed annotated tag. Refusing to release."
|
|
58
|
+
exit 1
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
tag_json=$(gh api "repos/${repo}/git/tags/${obj_sha}")
|
|
62
|
+
verified=$(jq -r '.verification.verified' <<<"${tag_json}")
|
|
63
|
+
reason=$(jq -r '.verification.reason' <<<"${tag_json}")
|
|
64
|
+
|
|
65
|
+
echo "tag=${tag} object_sha=${obj_sha} verified=${verified} reason=${reason}"
|
|
66
|
+
|
|
67
|
+
if [ "${verified}" != "true" ]; then
|
|
68
|
+
echo "::error title=Unsigned tag::Tag ${tag} signature is NOT verified by GitHub. Reason: ${reason}. Refusing to release."
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
test:
|
|
73
|
+
name: Test on Node ${{ matrix.node-version }}
|
|
74
|
+
needs: verify-signature
|
|
75
|
+
runs-on: ubuntu-24.04
|
|
76
|
+
permissions:
|
|
77
|
+
contents: read
|
|
78
|
+
strategy:
|
|
79
|
+
fail-fast: true
|
|
80
|
+
matrix:
|
|
81
|
+
node-version: ['20', '22', '24']
|
|
82
|
+
steps:
|
|
83
|
+
- name: Checkout
|
|
84
|
+
uses: actions/checkout@v5
|
|
85
|
+
|
|
86
|
+
- name: Setup Node ${{ matrix.node-version }}
|
|
87
|
+
uses: actions/setup-node@v5
|
|
88
|
+
with:
|
|
89
|
+
node-version: ${{ matrix.node-version }}
|
|
90
|
+
cache: 'npm'
|
|
91
|
+
|
|
92
|
+
- name: Install dependencies
|
|
93
|
+
run: npm ci
|
|
94
|
+
|
|
95
|
+
- name: Lint
|
|
96
|
+
run: npm run lint
|
|
97
|
+
|
|
98
|
+
- name: Typecheck
|
|
99
|
+
run: npm run typecheck
|
|
100
|
+
|
|
101
|
+
- name: Test
|
|
102
|
+
run: npm test
|
|
103
|
+
|
|
104
|
+
- name: Build
|
|
105
|
+
run: npm run build
|
|
106
|
+
|
|
107
|
+
publish-npm:
|
|
108
|
+
name: Publish to npm
|
|
109
|
+
needs: test
|
|
110
|
+
runs-on: ubuntu-24.04
|
|
111
|
+
permissions:
|
|
112
|
+
contents: read
|
|
113
|
+
id-token: write
|
|
114
|
+
outputs:
|
|
115
|
+
version: ${{ steps.disttag.outputs.version }}
|
|
116
|
+
disttag: ${{ steps.disttag.outputs.disttag }}
|
|
117
|
+
is_prerelease: ${{ steps.disttag.outputs.is_prerelease }}
|
|
118
|
+
steps:
|
|
119
|
+
- name: Checkout
|
|
120
|
+
uses: actions/checkout@v5
|
|
121
|
+
|
|
122
|
+
- name: Setup Node
|
|
123
|
+
uses: actions/setup-node@v5
|
|
124
|
+
with:
|
|
125
|
+
node-version: '22'
|
|
126
|
+
registry-url: 'https://registry.npmjs.org'
|
|
127
|
+
cache: 'npm'
|
|
128
|
+
|
|
129
|
+
- name: Install dependencies
|
|
130
|
+
run: npm ci
|
|
131
|
+
|
|
132
|
+
- name: Build
|
|
133
|
+
run: npm run build
|
|
134
|
+
|
|
135
|
+
- name: Compute dist-tag from git tag
|
|
136
|
+
id: disttag
|
|
137
|
+
run: bash .github/scripts/compute-disttag.sh
|
|
138
|
+
|
|
139
|
+
- name: Verify package.json version matches git tag
|
|
140
|
+
run: |
|
|
141
|
+
set -euo pipefail
|
|
142
|
+
pkg_version=$(node -p "require('./package.json').version")
|
|
143
|
+
git_version="${{ steps.disttag.outputs.version }}"
|
|
144
|
+
if [ "${pkg_version}" != "${git_version}" ]; then
|
|
145
|
+
echo "::error title=Version mismatch::package.json version (${pkg_version}) does not match git tag (${git_version}). Bump package.json before tagging."
|
|
146
|
+
exit 1
|
|
147
|
+
fi
|
|
148
|
+
echo "package.json and git tag both at ${pkg_version}"
|
|
149
|
+
|
|
150
|
+
- name: Publish to npm
|
|
151
|
+
run: |
|
|
152
|
+
set -euo pipefail
|
|
153
|
+
npm publish \
|
|
154
|
+
--provenance \
|
|
155
|
+
--access public \
|
|
156
|
+
--tag "${{ steps.disttag.outputs.disttag }}"
|
|
157
|
+
|
|
158
|
+
github-release:
|
|
159
|
+
name: Create GitHub Release
|
|
160
|
+
needs: publish-npm
|
|
161
|
+
runs-on: ubuntu-24.04
|
|
162
|
+
permissions:
|
|
163
|
+
contents: write
|
|
164
|
+
steps:
|
|
165
|
+
- name: Checkout
|
|
166
|
+
uses: actions/checkout@v5
|
|
167
|
+
with:
|
|
168
|
+
fetch-depth: 0
|
|
169
|
+
|
|
170
|
+
- name: Setup Node
|
|
171
|
+
uses: actions/setup-node@v5
|
|
172
|
+
with:
|
|
173
|
+
node-version: '22'
|
|
174
|
+
cache: 'npm'
|
|
175
|
+
|
|
176
|
+
- name: Install dependencies
|
|
177
|
+
run: npm ci
|
|
178
|
+
|
|
179
|
+
- name: Build
|
|
180
|
+
run: npm run build
|
|
181
|
+
|
|
182
|
+
- name: Pack tarball
|
|
183
|
+
run: npm pack
|
|
184
|
+
|
|
185
|
+
- name: Create GitHub Release (stable)
|
|
186
|
+
if: needs.publish-npm.outputs.is_prerelease == 'false'
|
|
187
|
+
env:
|
|
188
|
+
GH_TOKEN: ${{ github.token }}
|
|
189
|
+
run: |
|
|
190
|
+
set -euo pipefail
|
|
191
|
+
gh release create "${GITHUB_REF_NAME}" \
|
|
192
|
+
./intelmesh-sdk-*.tgz \
|
|
193
|
+
--title "${GITHUB_REF_NAME}" \
|
|
194
|
+
--generate-notes
|
|
195
|
+
|
|
196
|
+
- name: Create GitHub Release (prerelease)
|
|
197
|
+
if: needs.publish-npm.outputs.is_prerelease == 'true'
|
|
198
|
+
env:
|
|
199
|
+
GH_TOKEN: ${{ github.token }}
|
|
200
|
+
run: |
|
|
201
|
+
set -euo pipefail
|
|
202
|
+
gh release create "${GITHUB_REF_NAME}" \
|
|
203
|
+
./intelmesh-sdk-*.tgz \
|
|
204
|
+
--title "${GITHUB_REF_NAME}" \
|
|
205
|
+
--generate-notes \
|
|
206
|
+
--prerelease
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx --no-install commitlint --edit "$1"
|
package/.prettierrc
ADDED
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @intelmesh/sdk — Development Guidelines
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Official Node.js client for the IntelMesh Risk Intelligence Engine API. Wraps REST endpoints with typed methods, cursor-based pagination, and structured errors. Zero runtime dependencies, uses native fetch (Node 20+).
|
|
5
|
+
|
|
6
|
+
## Code Conventions
|
|
7
|
+
- TypeScript strict mode, zero `any`
|
|
8
|
+
- JSDoc on ALL exported symbols
|
|
9
|
+
- Explicit return types on all functions
|
|
10
|
+
- `readonly` on interface properties where possible
|
|
11
|
+
- Max 50 lines per function, max complexity 10
|
|
12
|
+
- One responsibility per file
|
|
13
|
+
|
|
14
|
+
## Architecture
|
|
15
|
+
- `src/types.ts` — All API types (mirrors swagger definitions)
|
|
16
|
+
- `src/client/http.ts` — Base HTTP client (fetch wrapper, auth, JSON parsing)
|
|
17
|
+
- `src/client/errors.ts` — Typed error hierarchy with status code mapping
|
|
18
|
+
- `src/client/pagination.ts` — Async cursor iterator for paginated endpoints
|
|
19
|
+
- `src/client/intelmesh.ts` — Main IntelMesh class (facade)
|
|
20
|
+
- `src/resources/*.ts` — One file per API resource (events, rules, phases, etc.)
|
|
21
|
+
- `src/builders/*.ts` — Fluent builders for events and rules
|
|
22
|
+
- `src/generated/types.ts` — Auto-generated from swagger.json (do not edit)
|
|
23
|
+
|
|
24
|
+
## Testing
|
|
25
|
+
- Vitest, run with `npm test`
|
|
26
|
+
- Tests in `tests/` mirror `src/` structure
|
|
27
|
+
- No network calls in tests — mock fetch
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
- `npm run build` — Build with tsup
|
|
31
|
+
- `npm run lint` — ESLint check
|
|
32
|
+
- `npm run test` — Vitest run
|
|
33
|
+
- `npm run generate` — Regenerate types from swagger.json
|
|
34
|
+
- `npm run typecheck` — tsc --noEmit
|
|
35
|
+
|
|
36
|
+
## Key Principle
|
|
37
|
+
This SDK has ZERO runtime dependencies. It uses native fetch, native URL, and native AbortController. The only dependencies are devDependencies for build, lint, and test tooling.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Intelmesh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|