@incomy/platform-sdk 0.4.0-beta.1973 → 0.4.0-beta.2001
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/README.md +168 -0
- package/meta.json +4 -4
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# @incomy/platform-sdk
|
|
2
|
+
|
|
3
|
+
Auto-generated TypeScript client for the Incomy platform APIs (currently **Hub**),
|
|
4
|
+
produced from each service's OpenAPI spec and published to npm. Consumed by the
|
|
5
|
+
`web` frontend as `import { hub } from "@incomy/platform-sdk"`.
|
|
6
|
+
|
|
7
|
+
## TL;DR
|
|
8
|
+
|
|
9
|
+
- **Daily work:** just merge to `develop` — a beta is published automatically. You don't touch versions.
|
|
10
|
+
- **Release:** `npm version <patch|minor|major>` → commit → **merge to `main`**. No git tags.
|
|
11
|
+
- **Changed the API?** run `npm run snapshot` and commit `oas/hub.json` together with your backend change (otherwise CI fails).
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## What lives here
|
|
16
|
+
|
|
17
|
+
| Path | Tracked? | What it is |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `package.json` | ✅ committed | npm manifest; the `version` field is the **release base** (the single human knob) |
|
|
20
|
+
| `tsconfig.json` | ✅ committed | TypeScript build config |
|
|
21
|
+
| `package-lock.json` | ✅ committed | pinned build deps (`npm ci` in CI) |
|
|
22
|
+
| `scripts/*.mjs` | ✅ committed | generation / snapshot / contract-gate logic |
|
|
23
|
+
| `oas/hub.json` | ✅ committed | **OpenAPI contract snapshot** (reviewable in PRs, drives generation) |
|
|
24
|
+
| `generate.sh` | ✅ committed | local one-shot build (starts the API, then runs the generator) |
|
|
25
|
+
| `services/`, `dist/`, `index.ts`, `meta.json`, `*.tgz`, `node_modules/` | ❌ generated | build output (git-ignored) |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## How generation works
|
|
30
|
+
|
|
31
|
+
There is **one source of truth** for generation: [`scripts/build.mjs`](scripts/build.mjs). CI and
|
|
32
|
+
`generate.sh` both call it — there is no duplicated codegen logic.
|
|
33
|
+
|
|
34
|
+
It does, in order:
|
|
35
|
+
|
|
36
|
+
1. Resolve OpenAPI specs from `OAS_SOURCES` (pipe-delimited `name|url-or-path` lines; GitLab
|
|
37
|
+
package URLs get the `JOB-TOKEN` automatically). With no `OAS_SOURCES`, it reuses the committed
|
|
38
|
+
`oas/*.json` snapshot — so you can regenerate offline.
|
|
39
|
+
2. Run `openapi-typescript-codegen` per service into `services/<name>` (fetch client, union types).
|
|
40
|
+
3. Write `index.ts` — one namespace export per service: `export * as hub from "./services/hub"`.
|
|
41
|
+
**This is the public API surface** and it does not change across regenerations.
|
|
42
|
+
4. Stamp the version (when given), write `meta.json` provenance, compile with `tsc`, `npm pack`.
|
|
43
|
+
|
|
44
|
+
`meta.json` records where the build came from — `sdkVersion`, `apiCommit`, and a sha256 of each
|
|
45
|
+
source spec — so you can always tell which backend commit an SDK build was generated from.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Versioning
|
|
50
|
+
|
|
51
|
+
The **base** `major.minor.patch` is the `version` field in `package.json` (e.g. `0.4.0`). That is
|
|
52
|
+
the only thing a human sets. CI derives the actual published version from the branch
|
|
53
|
+
([`calculate_version`](.gitlab-ci.yml)):
|
|
54
|
+
|
|
55
|
+
| Context | Published version |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `main` | `BASE` — clean release, e.g. `0.4.0` |
|
|
58
|
+
| `develop` | `BASE-beta.<pipeline-iid>` — e.g. `0.4.0-beta.207` |
|
|
59
|
+
| `feature/*` (build only) | `BASE-alpha.<pipeline-iid>` |
|
|
60
|
+
|
|
61
|
+
`CI_PIPELINE_IID` is strictly increasing per project, so prerelease numbers are always unique and
|
|
62
|
+
monotonic — no duplicate-version publishes.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Releasing (version-file-driven, no tags)
|
|
67
|
+
|
|
68
|
+
A release happens when a **new base version lands on `main`**. There are no manual git tags.
|
|
69
|
+
|
|
70
|
+
| Context | Publishes? | dist-tag | Notes |
|
|
71
|
+
|---|:---:|---|---|
|
|
72
|
+
| `feature/*` | ❌ (build/validate only) | — | proves the SDK still compiles |
|
|
73
|
+
| `develop` | ✅ every push | `@beta` | continuous betas for testing |
|
|
74
|
+
| `main` | ✅ **only if the version is new** | `@latest` | the clean release |
|
|
75
|
+
|
|
76
|
+
The `main` job is **idempotent**: it checks `npm view "<name>@<version>"` and skips if that version
|
|
77
|
+
is already published. So a `main` merge that didn't bump the version is a no-op, and pipeline
|
|
78
|
+
retries never double-publish. `@latest` therefore only ever moves to a clean version from `main`.
|
|
79
|
+
|
|
80
|
+
### How to cut a release
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
cd sdk
|
|
84
|
+
npm version minor --no-git-tag-version # bump the base in package.json (see "which level" below)
|
|
85
|
+
git commit -am "chore(sdk): release 0.5.0"
|
|
86
|
+
# open an MR and merge to main → CI publishes 0.5.0 to @latest
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
(Or use the VS Code task **`sdk: bump version (release)`** for the bump step.)
|
|
90
|
+
|
|
91
|
+
### Which level to bump (semver)
|
|
92
|
+
|
|
93
|
+
| Level | When | Example |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| **patch** | bug fix, **API contract unchanged** | `0.4.0 → 0.4.1` |
|
|
96
|
+
| **minor** | new, backward-compatible API (new endpoint / optional field) | `0.4.0 → 0.5.0` |
|
|
97
|
+
| **major** | breaking change (removed/renamed/retyped field, removed endpoint) | `0.4.0 → 1.0.0` |
|
|
98
|
+
|
|
99
|
+
The `oas/hub.json` diff tells you the level: `path/schema added` or a new optional field → **minor**;
|
|
100
|
+
`path removed` or an incompatible `schema modified` → **major**; no `oas` change at all → **patch**.
|
|
101
|
+
|
|
102
|
+
> Pre-1.0 note: while on `0.x`, breaking changes conventionally go out as a **minor** bump; reserve
|
|
103
|
+
> `1.0.0` for the first explicitly-stable API.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## The OpenAPI contract snapshot + gate
|
|
108
|
+
|
|
109
|
+
`oas/hub.json` is a committed, normalized copy of the Hub OpenAPI spec — the **API contract** the
|
|
110
|
+
SDK is generated from. Committing it means any API change shows up as a reviewable diff in the PR.
|
|
111
|
+
|
|
112
|
+
A CI gate (`check_swagger_snapshot` in
|
|
113
|
+
[`services/hub/.gitlab-ci.yml`](../services/hub/.gitlab-ci.yml)) re-exports the spec from the
|
|
114
|
+
current backend and **fails if it differs from the committed snapshot** — so an API change can't
|
|
115
|
+
slip through without updating the contract. The `servers` block (derived from `INCOMY_ROOT_DOMAIN`)
|
|
116
|
+
is ignored, so deployment-environment differences don't cause false failures.
|
|
117
|
+
|
|
118
|
+
**When you change the API**, refresh and commit the snapshot alongside your backend change:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
cd sdk
|
|
122
|
+
npm run snapshot # re-export from the local API on :20001 → oas/hub.json
|
|
123
|
+
git add oas/hub.json # commit it together with the C# change
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
(VS Code task: **`sdk: snapshot OAS contract`**. Start the API first via **`run hub api with db`**.)
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Local development
|
|
131
|
+
|
|
132
|
+
| Command (in `sdk/`) | What it does | Needs API running? |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| `./generate.sh` | full local build: starts hub-api via Docker, then generates from the live spec | starts it for you |
|
|
135
|
+
| `npm run generate` | regenerate from the committed `oas/hub.json` snapshot | no |
|
|
136
|
+
| `npm run snapshot` | refresh `oas/hub.json` from the live API (`:20001`) | yes |
|
|
137
|
+
| `npm run build` | just `tsc` | no |
|
|
138
|
+
|
|
139
|
+
To test changes against `web`, build here and overwrite `web/node_modules/@incomy/platform-sdk`
|
|
140
|
+
with the resulting `dist/`.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Consuming the SDK
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
npm install @incomy/platform-sdk # @latest → newest clean release
|
|
148
|
+
npm install @incomy/platform-sdk@beta # newest beta (pre-release testing)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { hub } from "@incomy/platform-sdk";
|
|
153
|
+
// hub.<Service>.<operation>(...)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Pin an exact version (recommended for a generated client) and bump deliberately. Avoid caret ranges
|
|
157
|
+
on prereleases (e.g. `^0.4.0-189`) — npm prerelease range semantics make them surprising.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Gotchas
|
|
162
|
+
|
|
163
|
+
- **A `main` merge without a version bump publishes nothing** (idempotent skip). To release, bump first.
|
|
164
|
+
- **Keep `version` a clean `X.Y.Z`** — never hand-add `-beta`/`-alpha`; CI adds those.
|
|
165
|
+
- **npm versions are immutable** — you can't unpublish a mistake; fix forward with a higher version
|
|
166
|
+
(and `npm dist-tag` if you need to move `@latest` back).
|
|
167
|
+
- **`main` also deploys the backend.** A bump-and-merge releases the SDK *and* deploys the API
|
|
168
|
+
together; a no-bump merge just deploys the API.
|
package/meta.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"sdkVersion": "0.4.0-beta.
|
|
3
|
-
"generatedAt": "2026-06-
|
|
4
|
-
"apiCommit": "
|
|
5
|
-
"pipelineUrl": "https://gitlab.com/incomy/platform/-/pipelines/
|
|
2
|
+
"sdkVersion": "0.4.0-beta.2001",
|
|
3
|
+
"generatedAt": "2026-06-26T21:06:05.155Z",
|
|
4
|
+
"apiCommit": "4f2a29d7",
|
|
5
|
+
"pipelineUrl": "https://gitlab.com/incomy/platform/-/pipelines/2632900221",
|
|
6
6
|
"sources": {
|
|
7
7
|
"hub": {
|
|
8
8
|
"sha256": "db56e9ea7e70f27b4681ff0437208f90663024ce412985e3edf06463f46eea70"
|