@rytass/bpm-core-client 0.1.4 → 0.1.5

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 (3) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +69 -3
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -8,6 +8,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  Releases are managed by [`nx release`](https://nx.dev/recipes/nx-release) with
9
9
  Conventional Commits — see `nx.json` for the release config.
10
10
 
11
+ ## 0.1.5 — 2026-05-28
12
+
13
+ ### Documentation
14
+
15
+ - **README "Organization mirror pattern" section.** Condensed pointer to
16
+ the full pattern in `@rytass/bpm-core-nestjs-module`'s README plus a
17
+ client-side worked example using `createOrgUnit`, `updateOrgUnit`,
18
+ `deleteOrgUnit`, `commitOrgUnitTreeDraft`, `createPosition`,
19
+ `createMembership`, `createManagerResolution`. Clarifies that BPM owns
20
+ the org graph and host applications mirror their existing org data in
21
+ rather than expose a resolver (in contrast to the member-resolver
22
+ pattern).
23
+
24
+ ### Why a patch
25
+
26
+ No type or runtime change. README only.
27
+
28
+ ## 0.1.4 — 2026-05-27
29
+
30
+ No source changes. Bumped in lockstep with
31
+ `@rytass/bpm-core-nestjs-module@0.1.4` (re-publish after the 0.1.3
32
+ backend tarball shipped only `.ts` source — see that package's CHANGELOG).
33
+
34
+ ## 0.1.3 — 2026-05-27 (deprecated on npm)
35
+
36
+ Lockstep bump alongside the broken 0.1.3 backend release. Avoid;
37
+ upgrade directly to 0.1.4 or newer.
38
+
11
39
  ## 0.1.2 — 2026-05-27
12
40
 
13
41
  No source changes. Bumped in lockstep with
package/README.md CHANGED
@@ -151,9 +151,9 @@ default endpoint, no cookie jar. Treat them the same as Server Components.
151
151
 
152
152
  ## Endpoint Resolution
153
153
 
154
- By default the client targets the same origin (no `/api` prefix) — see
155
- [`docs/10-bpm-embedding-auth.md`](../../docs/10-bpm-embedding-auth.md) for the
156
- host contract. Endpoint resolution rules:
154
+ By default the client targets the same origin (no `/api` prefix) — see the
155
+ "Embedding & auth" section of `@rytass/bpm-core-nestjs-module`'s README for
156
+ the host-side contract. Endpoint resolution rules:
157
157
 
158
158
  | Source | Behavior |
159
159
  | ----------------------------------------------- | -------------------------------------------------------------------------- |
@@ -206,6 +206,72 @@ Every subpath uses the same `requestGraphQl` transport from the root. Hosts
206
206
  can mix and match — for example a read-only dashboard might only import
207
207
  `workflow` queries, never reaching for `/organization` mutations.
208
208
 
209
+ ## Organization Mirror Pattern (Important)
210
+
211
+ > **TL;DR:** BPM owns the org graph (`org_units`, `positions`,
212
+ > `memberships`, `manager_resolutions`). Hosts with their own org model
213
+ > mirror data **into** BPM via the `/organization` mutations rather than
214
+ > exposing a host-side resolver. See the
215
+ > "Organization Data Ownership" section of
216
+ > `@rytass/bpm-core-nestjs-module`'s README for the rationale.
217
+
218
+ The integration shape is **asymmetric** with `BPMMemberResolver`:
219
+ member identity stays in the host's user table and BPM reaches in via
220
+ the resolver token; the org structure lives in BPM and the host pushes
221
+ data in. Three rules keep the mirror idempotent:
222
+
223
+ 1. **Use `code` as the natural key.** Both `OrgUnit` and `Position`
224
+ carry a unique `code` you control. On every sync, look up by `code`
225
+ before deciding INSERT vs UPDATE.
226
+ 2. **Stash the host-FK in `metadata`.** Both entities carry an opaque
227
+ `metadata` JSON BPM never introspects — store your host's primary
228
+ key there to chase pointers back during reconciliation.
229
+ 3. **Soft-delete via the `delete*` mutations.** They set `deletedAt`;
230
+ live queries (`orgUnits`, `orgUnitCount`, etc.) filter soft-deleted
231
+ rows automatically.
232
+
233
+ Quick wire-up using only this package's exports:
234
+
235
+ ```ts
236
+ import {
237
+ createOrgUnit,
238
+ updateOrgUnit,
239
+ orgUnits,
240
+ } from '@rytass/bpm-core-client/organization';
241
+
242
+ async function upsertOrgUnit(hostUnit: {
243
+ code: string;
244
+ name: string;
245
+ type: 'COMPANY' | 'DIVISION' | 'DEPARTMENT' | 'TEAM';
246
+ parentCode: string | null;
247
+ hostId: string;
248
+ }): Promise<string> {
249
+ const existing = (await orgUnits({ searchText: hostUnit.code })).find(
250
+ (u) => u.code === hostUnit.code,
251
+ );
252
+ const parentId = hostUnit.parentCode
253
+ ? (await orgUnits({ searchText: hostUnit.parentCode })).find(
254
+ (u) => u.code === hostUnit.parentCode,
255
+ )?.id ?? null
256
+ : null;
257
+ const metadataJson = JSON.stringify({ hostId: hostUnit.hostId });
258
+
259
+ if (existing) {
260
+ return (
261
+ await updateOrgUnit({
262
+ id: existing.id,
263
+ input: { ...hostUnit, parentId, metadataJson },
264
+ })
265
+ ).id;
266
+ }
267
+ return (await createOrgUnit({ ...hostUnit, parentId, metadataJson })).id;
268
+ }
269
+ ```
270
+
271
+ `createPosition`, `createMembership`, `updateMembership`, and
272
+ `createManagerResolution` follow the same pattern. For bulk tree moves
273
+ in one transaction, see `commitOrgUnitTreeDraft`.
274
+
209
275
  ## Auth REST Endpoints
210
276
 
211
277
  The BPM wrapper-host exposes the following endpoints under the host root (no
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/bpm-core-client",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Framework-agnostic TypeScript client for the Rytass BPM approval workflow GraphQL surface: fetch-based GraphQL transport, REST auth client, pre-baked typed operations for organization, member, form, template, and workflow.",
5
5
  "keywords": [
6
6
  "bpm",
@@ -73,7 +73,7 @@
73
73
  }
74
74
  },
75
75
  "peerDependencies": {
76
- "@rytass/bpm-core-shared": "^0.1.4"
76
+ "@rytass/bpm-core-shared": "^0.1.5"
77
77
  },
78
78
  "dependencies": {
79
79
  "tslib": "^2.3.0"