@spotto/contract 1.0.70-alpha.15 → 1.0.70-alpha.17

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 CHANGED
@@ -1,33 +1,33 @@
1
- # README
2
-
3
- This repository is a source of truth / documentation for the spotto-api.
4
-
5
- The repository consists of a series of typescript classes that document the API contract
6
- between the spotto API and its clients
7
-
8
- ### How do I get set up?
9
-
10
- 1. Clone this repository
11
- 1. yarn install
12
- 1. run 'yarn start' to start a documentation server
13
-
14
- ### Contribution guidelines
15
-
16
- When adding endpoints create a new folder / file for your endpoint.
17
- Fill out file using others as a guide.
18
-
19
- Any response and request shapes should be specified in the /types folder. The documentation server
20
- is sometimes unable to understand more complicated interfaces. In these scenarios please create two
21
- types files, one with a logical working type that can be used by other repositories. The other will
22
- be simply for filling the response server.
23
-
24
- Any documentation specific types files should have the suffix 'Docs' within the same folder. e.g.
25
-
26
- - types
27
- - objects
28
- - objectTypes.ts
29
- - objectTypesDocs.ts
30
-
31
- ### Who do I talk to?
32
-
33
- - Repo owner or admin
1
+ # README
2
+
3
+ This repository is a source of truth / documentation for the spotto-api.
4
+
5
+ The repository consists of a series of typescript classes that document the API contract
6
+ between the spotto API and its clients
7
+
8
+ ### How do I get set up?
9
+
10
+ 1. Clone this repository
11
+ 1. yarn install
12
+ 1. run 'yarn start' to start a documentation server
13
+
14
+ ### Contribution guidelines
15
+
16
+ When adding endpoints create a new folder / file for your endpoint.
17
+ Fill out file using others as a guide.
18
+
19
+ Any response and request shapes should be specified in the /types folder. The documentation server
20
+ is sometimes unable to understand more complicated interfaces. In these scenarios please create two
21
+ types files, one with a logical working type that can be used by other repositories. The other will
22
+ be simply for filling the response server.
23
+
24
+ Any documentation specific types files should have the suffix 'Docs' within the same folder. e.g.
25
+
26
+ - types
27
+ - objects
28
+ - objectTypes.ts
29
+ - objectTypesDocs.ts
30
+
31
+ ### Who do I talk to?
32
+
33
+ - Repo owner or admin
@@ -24,6 +24,21 @@ export declare type UnknownRoleActionType = (typeof UNKNOWN_ROLE_ACTION_TYPES)[n
24
24
  * can be onboarded against it. This is a manual one-off via the AWS console.
25
25
  */
26
26
  export declare const DEFAULT_ROLE_CLAIM_ATTRIBUTE = "custom:g2g_role";
27
+ /**
28
+ * Cognito user attribute that carries the IdP-emitted group memberships.
29
+ * Fixed across all SSO orgs, exactly like `DEFAULT_ROLE_CLAIM_ATTRIBUTE` —
30
+ * per-customer IdP attribute mappings wire the customer's group claim
31
+ * (`idpGroupClaim`, opt-in) into this attribute, and the snapshot trigger +
32
+ * usergroup sync read from it.
33
+ *
34
+ * Operational note: each User Pool (dev / staging / prod) needs the
35
+ * `g2g_groups` custom attribute (String, mutable, max length 2048 — the
36
+ * Cognito maximum) defined once before any org can adopt group mapping.
37
+ * Manual one-off via the AWS console, same as `g2g_role`. The 2048-char
38
+ * ceiling fits ~48 Entra GUIDs — IdP setup guidance must scope the emitted
39
+ * claim to app-assigned groups.
40
+ */
41
+ export declare const DEFAULT_GROUP_CLAIM_ATTRIBUTE = "custom:g2g_groups";
27
42
  /**
28
43
  * The IdP-side claim name customers MUST emit. Mandated rather than
29
44
  * configurable per-customer — every onboarded IdP gets the same Cognito
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildSsoProviderName = exports.DEFAULT_IDP_ROLE_CLAIM = exports.DEFAULT_ROLE_CLAIM_ATTRIBUTE = exports.UNKNOWN_ROLE_ACTION_TYPES = exports.SSO_MODES = void 0;
3
+ exports.buildSsoProviderName = exports.DEFAULT_IDP_ROLE_CLAIM = exports.DEFAULT_GROUP_CLAIM_ATTRIBUTE = exports.DEFAULT_ROLE_CLAIM_ATTRIBUTE = exports.UNKNOWN_ROLE_ACTION_TYPES = exports.SSO_MODES = void 0;
4
4
  /**
5
5
  * Supported SSO protocol modes for an organisation's per-customer Cognito IdP.
6
6
  */
@@ -25,6 +25,21 @@ exports.UNKNOWN_ROLE_ACTION_TYPES = ['deny', 'defaultRole'];
25
25
  * can be onboarded against it. This is a manual one-off via the AWS console.
26
26
  */
27
27
  exports.DEFAULT_ROLE_CLAIM_ATTRIBUTE = 'custom:g2g_role';
28
+ /**
29
+ * Cognito user attribute that carries the IdP-emitted group memberships.
30
+ * Fixed across all SSO orgs, exactly like `DEFAULT_ROLE_CLAIM_ATTRIBUTE` —
31
+ * per-customer IdP attribute mappings wire the customer's group claim
32
+ * (`idpGroupClaim`, opt-in) into this attribute, and the snapshot trigger +
33
+ * usergroup sync read from it.
34
+ *
35
+ * Operational note: each User Pool (dev / staging / prod) needs the
36
+ * `g2g_groups` custom attribute (String, mutable, max length 2048 — the
37
+ * Cognito maximum) defined once before any org can adopt group mapping.
38
+ * Manual one-off via the AWS console, same as `g2g_role`. The 2048-char
39
+ * ceiling fits ~48 Entra GUIDs — IdP setup guidance must scope the emitted
40
+ * claim to app-assigned groups.
41
+ */
42
+ exports.DEFAULT_GROUP_CLAIM_ATTRIBUTE = 'custom:g2g_groups';
28
43
  /**
29
44
  * The IdP-side claim name customers MUST emit. Mandated rather than
30
45
  * configurable per-customer — every onboarded IdP gets the same Cognito
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/organisations/sso/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAA;AAIlD;;;;GAIG;AACU,QAAA,yBAAyB,GAAG,CAAC,MAAM,EAAE,aAAa,CAAU,CAAA;AAIzE;;;;;;;;;;;;GAYG;AACU,QAAA,4BAA4B,GAAG,iBAAiB,CAAA;AAE7D;;;;;;;;;;GAUG;AACU,QAAA,sBAAsB,GAAG,UAAU,CAAA;AAEhD;;;;;;;;GAQG;AACI,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAU,EAAE,CAC/D,OAAO,QAAQ,EAAE,CAAA;AADN,QAAA,oBAAoB,wBACd"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/organisations/sso/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAA;AAIlD;;;;GAIG;AACU,QAAA,yBAAyB,GAAG,CAAC,MAAM,EAAE,aAAa,CAAU,CAAA;AAIzE;;;;;;;;;;;;GAYG;AACU,QAAA,4BAA4B,GAAG,iBAAiB,CAAA;AAE7D;;;;;;;;;;;;;GAaG;AACU,QAAA,6BAA6B,GAAG,mBAAmB,CAAA;AAEhE;;;;;;;;;;GAUG;AACU,QAAA,sBAAsB,GAAG,UAAU,CAAA;AAEhD;;;;;;;;GAQG;AACI,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAU,EAAE,CAC/D,OAAO,QAAQ,EAAE,CAAA;AADN,QAAA,oBAAoB,wBACd"}
@@ -42,6 +42,40 @@ export interface RoleMappingInput {
42
42
  propertyValue: string;
43
43
  roleId: string;
44
44
  }
45
+ /**
46
+ * One row in the org's usergroup-mapping list. At sign-in the IdP-emitted
47
+ * group claim (captured into `custom:g2g_groups` via the per-org Cognito IdP
48
+ * `AttributeMapping`) is normalised to `string[]` and matched against this
49
+ * list; unlike `RoleMapping` (first match wins, order significant) the
50
+ * semantics are **union** — the user joins every group whose `propertyValue`
51
+ * appears in the normalised values, and order is irrelevant.
52
+ *
53
+ * A group referenced here is *SSO-managed* for federated users: membership
54
+ * within the mapped set is reconciled (added AND removed) on every sync, and
55
+ * manual membership edits for `authProvider: 'sso'` users are refused at both
56
+ * write doors. Groups NOT referenced here are untouched by sync.
57
+ *
58
+ * Generic over the identifier type so the same shape covers both the wire
59
+ * layer (string IDs) and the Mongo storage layer (ObjectId).
60
+ */
61
+ export interface UsergroupMapping<TId = string> {
62
+ _id: TId;
63
+ /**
64
+ * Value to look for in the IdP-emitted claim. Compared with `===` against
65
+ * each entry of the normalised `string[]` — case-sensitive, exact match.
66
+ */
67
+ propertyValue: string;
68
+ /** Spotto user group the matching user joins. */
69
+ usergroupId: TId;
70
+ }
71
+ /**
72
+ * Wire shape for creating / replacing usergroup mappings. `_id` is
73
+ * server-assigned on each write, so it's not part of the input.
74
+ */
75
+ export interface UsergroupMappingInput {
76
+ propertyValue: string;
77
+ usergroupId: string;
78
+ }
45
79
  export interface SsoEnabledBase<TRoleId = string> {
46
80
  enabled: true;
47
81
  /** Email domains owned by this org. One domain → one org (enforced at write time). */
@@ -66,6 +100,20 @@ export interface SsoEnabledBase<TRoleId = string> {
66
100
  * through to `unknownRoleAction`. See `RoleMapping`.
67
101
  */
68
102
  roleMappings: RoleMapping<TRoleId>[];
103
+ /**
104
+ * IdP-side claim name that feeds the Cognito `custom:g2g_groups` attribute.
105
+ * Absent ⇒ group sync is off for this org (the pre-feature state; also the
106
+ * default — group mapping is opt-in per org). May name the same IdP claim
107
+ * as `idpRoleClaim`: two `AttributeMapping` entries can read one claim.
108
+ */
109
+ idpGroupClaim?: string;
110
+ /**
111
+ * Org-scoped usergroup-mapping list, union semantics. Absent/empty ⇒ no
112
+ * groups are SSO-managed and sync is a no-op. Unlike the role claim there
113
+ * is no unknown-value fallback — zero matches is a legitimate outcome
114
+ * (`unknownRoleAction` remains the only login gate). See `UsergroupMapping`.
115
+ */
116
+ usergroupMappings?: UsergroupMapping<TRoleId>[];
69
117
  /**
70
118
  * Mixed-mode opt-in: when `true`, the org accepts both SSO-managed users
71
119
  * (via federation) AND password-auth users created through `POST /users`.
@@ -1,4 +1,4 @@
1
- import { RoleMappingInput } from '../../organisations/sso';
1
+ import { RoleMappingInput, UsergroupMappingInput } from '../../organisations/sso';
2
2
  /**
3
3
  * Wire shape for `POST /sso/orgs/:id/onboard`. Operator-supplied fields only.
4
4
  *
@@ -31,6 +31,17 @@ interface OnboardSsoOrgWireBase {
31
31
  * mappings via `PUT /sso/orgs/:id/sso-mappings`.
32
32
  */
33
33
  roleMappings?: RoleMappingInput[];
34
+ /**
35
+ * IdP claim to wire into `custom:g2g_groups`. Optional — group mapping is
36
+ * opt-in; absent means no group sync for the org until configured via
37
+ * `PUT /sso/orgs/:id/sso-mappings`.
38
+ */
39
+ idpGroupClaim?: string;
40
+ /**
41
+ * Initial usergroup mappings (union semantics — see `UsergroupMapping`).
42
+ * Only meaningful alongside `idpGroupClaim`.
43
+ */
44
+ usergroupMappings?: UsergroupMappingInput[];
34
45
  /**
35
46
  * Opt-in to mixed-mode: allow password-auth users alongside SSO-managed
36
47
  * users in the same org. Password-user emails must be OUTSIDE
@@ -1,14 +1,19 @@
1
- import { RoleMappingInput } from '../../organisations/sso';
1
+ import { RoleMappingInput, UsergroupMappingInput } from '../../organisations/sso';
2
2
  /**
3
3
  * Wire shape for `PUT /sso/orgs/:id/sso-mappings`.
4
4
  *
5
- * Atomic full-replace of the org's role-mapping configuration. Sends both
6
- * `idpRoleClaim` (which IdP claim feeds `custom:g2g_role`) and the whole
7
- * `roleMappings` array. The orchestrator validates roleIds, pushes any
8
- * `idpRoleClaim` change to Cognito via `UpdateIdentityProvider`, then
5
+ * Atomic full-replace of the org's mapping configuration — role AND group.
6
+ * Sends `idpRoleClaim` (which IdP claim feeds `custom:g2g_role`) and the
7
+ * whole `roleMappings` array, plus optionally `idpGroupClaim` (feeds
8
+ * `custom:g2g_groups`) and `usergroupMappings`. Because the PUT carries
9
+ * complete state, omitting the group fields CLEARS group mapping for the
10
+ * org. The orchestrator validates role/usergroup ids, pushes any claim-name
11
+ * change (either attribute) to Cognito via `UpdateIdentityProvider`, then
9
12
  * persists. Mapping `_id` values are server-assigned on each write.
10
13
  */
11
14
  export interface UpdateSsoMappingsRequest {
12
15
  idpRoleClaim: string;
13
16
  roleMappings: RoleMappingInput[];
17
+ idpGroupClaim?: string;
18
+ usergroupMappings?: UsergroupMappingInput[];
14
19
  }
@@ -17,6 +17,15 @@ export interface GetUsergroupResponse {
17
17
  * only when true.
18
18
  */
19
19
  allLocations?: boolean;
20
+ /**
21
+ * True when the group is referenced by the org's SSO `usergroupMappings` —
22
+ * i.e. membership is SSO-managed for federated users (manual membership
23
+ * edits for `authProvider: 'sso'` users are refused; sync adds AND removes
24
+ * within the mapped set). Emitted only when true. Lets group/user admin
25
+ * surfaces mark managed groups without needing `sso:admin` to read the
26
+ * org's SSO config.
27
+ */
28
+ ssoManaged?: boolean;
20
29
  meta?: IEntityMeta;
21
30
  }
22
31
  export interface GetUsergroupsResponse {
@@ -7,9 +7,11 @@
7
7
  * A layout is a flat, ordered list of widgets, each pinned to a rect on a
8
8
  * 4-column grid (`gridPos`). The widget `type` is a closed union (below): adding
9
9
  * a new kind is a contract change + republish + client bump. Per-widget `config`
10
- * is left opaque and carries widget *behaviour* only (a saved-view id, an action
11
- * id, a heading's text) — never geometry — so a widget can evolve without a
12
- * contract change while the API still validates the structural parts.
10
+ * carries widget *behaviour* only (a saved-view id, an action id, a heading's
11
+ * text) — never geometry. Since 2026-07-30 the API validates each kind's KNOWN
12
+ * config keys on write (the per-kind `*WidgetConfig` shapes below) while
13
+ * tolerating unknown keys, so the client can still add config keys without an
14
+ * API deploy ordering — only changing a known key's meaning needs one.
13
15
  *
14
16
  * `version` discriminates stored layouts so the client can detect and
15
17
  * reset/migrate an older one on read.
@@ -30,6 +32,38 @@
30
32
  * expressed through `gridPos.w`, not enforced by the API.
31
33
  */
32
34
  export declare type HomeWidgetType = 'tile-link' | 'summary-list' | 'recent-activity' | 'recent-assets' | 'recent-locations' | 'needs-attention' | 'kit-spotlight' | 'hero' | 'heading';
35
+ /**
36
+ * Per-kind `config` shapes — the authoritative form of each configurable
37
+ * kind's KNOWN keys, which the API enforces on write (unknown keys pass, so
38
+ * these can grow client-first). The feed kinds define no config keys. `config`
39
+ * itself stays loosely typed on `HomeWidget`; the client parses defensively at
40
+ * the render boundary regardless (stored data may predate validation).
41
+ */
42
+ /** A `tile-link`'s target: a registered app action or a saved view — never a
43
+ * free URL (the client resolves targets to internal routes by design). */
44
+ export declare type TileLinkWidgetConfig = {
45
+ source: 'action';
46
+ actionId: string;
47
+ } | {
48
+ source: 'view';
49
+ viewId: string;
50
+ };
51
+ /** A `summary-list` renders the top matches of one saved view. */
52
+ export interface SummaryListWidgetConfig {
53
+ viewId: string;
54
+ }
55
+ /** A `heading`'s user-editable label — empty while freshly added. */
56
+ export interface HeadingWidgetConfig {
57
+ text: string;
58
+ }
59
+ /** The `hero`'s data source: the whole account's assets, or one saved view's
60
+ * matches. Always present on a stored hero (the kind shipped with it). */
61
+ export declare type HeroWidgetConfig = {
62
+ source: 'account';
63
+ } | {
64
+ source: 'view';
65
+ viewId: string;
66
+ };
33
67
  /**
34
68
  * A widget's cell on the Home grid: top-left position (`x`/`y`) and size
35
69
  * (`w`/`h`), in grid units. The grid is 4 columns wide, so `x + w <= 4`, and
@@ -53,7 +87,7 @@ export interface HomeWidget {
53
87
  type: HomeWidgetType;
54
88
  /** Position + size on the 4-column grid. */
55
89
  gridPos: HomeWidgetGridPos;
56
- /** Widget-specific *behaviour* config (e.g. a saved-view id, a heading's text). Opaque to the API; never geometry. */
90
+ /** Widget-specific *behaviour* config (e.g. a saved-view id, a heading's text) — never geometry. Known keys are validated per kind (see the `*WidgetConfig` shapes); unknown keys pass through. */
57
91
  config?: Record<string, unknown>;
58
92
  }
59
93
  export interface HomeLayout {
@@ -8,9 +8,11 @@
8
8
  * A layout is a flat, ordered list of widgets, each pinned to a rect on a
9
9
  * 4-column grid (`gridPos`). The widget `type` is a closed union (below): adding
10
10
  * a new kind is a contract change + republish + client bump. Per-widget `config`
11
- * is left opaque and carries widget *behaviour* only (a saved-view id, an action
12
- * id, a heading's text) — never geometry — so a widget can evolve without a
13
- * contract change while the API still validates the structural parts.
11
+ * carries widget *behaviour* only (a saved-view id, an action id, a heading's
12
+ * text) — never geometry. Since 2026-07-30 the API validates each kind's KNOWN
13
+ * config keys on write (the per-kind `*WidgetConfig` shapes below) while
14
+ * tolerating unknown keys, so the client can still add config keys without an
15
+ * API deploy ordering — only changing a known key's meaning needs one.
14
16
  *
15
17
  * `version` discriminates stored layouts so the client can detect and
16
18
  * reset/migrate an older one on read.
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/users/home-layout/shared.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG"}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/users/home-layout/shared.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spotto/contract",
3
3
  "license": "ISC",
4
- "version": "1.0.70-alpha.15",
4
+ "version": "1.0.70-alpha.17",
5
5
  "description": "Spotto's API Contract type definitions",
6
6
  "main": "./dist/index.js",
7
7
  "files": [
@@ -18,5 +18,5 @@
18
18
  "@types/geojson": "^7946.0.11",
19
19
  "shx": "^0.3.4"
20
20
  },
21
- "gitHead": "1639adf5cd5b9bbac1c3f6aa3c6127bf1e3ee882"
21
+ "gitHead": "9b6226de3170566e74ebaaa51a55c0a8e646b5a8"
22
22
  }