@spotto/contract 1.0.70-alpha.35 → 1.0.70-alpha.37

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.
@@ -1,5 +1,4 @@
1
1
  import { ActionEffect, ActionEvent, ActionPresentation, ActionTargetEntity } from '../../shared';
2
- import { PermissionGrant } from '../../../usergroups/shared';
3
2
  /** `name` is immutable. `event: null` clears the custom history label. */
4
3
  export interface UpdateActionRequest {
5
4
  label?: string;
@@ -10,7 +9,4 @@ export interface UpdateActionRequest {
10
9
  event?: ActionEvent | null;
11
10
  /** Replaced wholesale; an empty array clears every effect. */
12
11
  effects?: ActionEffect[];
13
- /** UI-only visibility grants — replaced wholesale; [] clears them (usable
14
- * by everyone). Every group id must exist in the org; `level` ignored. */
15
- permissions?: PermissionGrant[];
16
12
  }
@@ -1,5 +1,4 @@
1
1
  import { IEntityMeta } from '../../shared';
2
- import { PermissionGrant } from '../../usergroups/shared';
3
2
  import { ActionEffect, ActionEvent, ActionPresentation, ActionTargetEntity } from '../shared';
4
3
  import { GetActionsQuery } from './query';
5
4
  export interface GetActionResponse {
@@ -17,9 +16,6 @@ export interface GetActionResponse {
17
16
  event?: ActionEvent;
18
17
  /** Run on submit in author order (§4.2); absent = none. */
19
18
  effects?: ActionEffect[];
20
- /** UI-only visibility grants — binary for actions (`level` ignored; any
21
- * grant ⇒ members-only). Absent/empty = usable by everyone. */
22
- permissions?: PermissionGrant[];
23
19
  meta?: IEntityMeta;
24
20
  }
25
21
  export interface GetActionsResponse {
@@ -22,7 +22,11 @@ export interface ActionEvent {
22
22
  /** Severity of a raiseAlert effect — drives the client toast/result panel. */
23
23
  export declare const ACTION_ALERT_LEVELS: readonly ["success", "info", "warning", "error"];
24
24
  export declare type ActionAlertLevel = (typeof ACTION_ALERT_LEVELS)[number];
25
- /** One SES call carries all of a sendMessage effect's recipients (§4.2). */
25
+ /**
26
+ * The most recipients an action's sendMessage effects may name in total, so
27
+ * one submit emails at most this many addresses (§4.2). It also keeps each
28
+ * effect within one SES call.
29
+ */
26
30
  export declare const ACTION_EFFECT_MAX_RECIPIENTS = 50;
27
31
  /**
28
32
  * Raise a resolved message into the submit response and the stored
@@ -37,14 +41,22 @@ export interface ActionAlertEffect {
37
41
  }
38
42
  /**
39
43
  * Email via SES, sent post-commit best-effort (§4.2) — at most once per
40
- * capture; interpolated values are HTML-escaped into the body at send time.
44
+ * capture. The message is plain text: at send time the whole rendered message
45
+ * is HTML-escaped into the body and its line breaks become <br>.
41
46
  */
42
47
  export interface ActionMessageEffect {
43
48
  type: 'sendMessage';
44
- /** Static recipient addresses (v1), capped at ACTION_EFFECT_MAX_RECIPIENTS. */
49
+ /**
50
+ * Static recipient addresses (v1). All of an action's sendMessage effects
51
+ * together are capped at ACTION_EFFECT_MAX_RECIPIENTS.
52
+ */
45
53
  to: string[];
46
- /** Template, interpolated like message (an SES field — structurally header-safe). */
54
+ /**
55
+ * Template, interpolated like message (an SES field — structurally
56
+ * header-safe), sent on one line: line breaks become spaces.
57
+ */
47
58
  subject: string;
59
+ /** Plain-text template. */
48
60
  message: string;
49
61
  }
50
62
  export declare type ActionEffect = ActionAlertEffect | ActionMessageEffect;
@@ -8,6 +8,10 @@ exports.ACTION_ALERT_LEVELS = [
8
8
  'warning',
9
9
  'error',
10
10
  ];
11
- /** One SES call carries all of a sendMessage effect's recipients (§4.2). */
11
+ /**
12
+ * The most recipients an action's sendMessage effects may name in total, so
13
+ * one submit emails at most this many addresses (§4.2). It also keeps each
14
+ * effect within one SES call.
15
+ */
12
16
  exports.ACTION_EFFECT_MAX_RECIPIENTS = 50;
13
17
  //# sourceMappingURL=shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/actions/shared.ts"],"names":[],"mappings":";;;AA4BA,8EAA8E;AACjE,QAAA,mBAAmB,GAAG;IACjC,SAAS;IACT,MAAM;IACN,SAAS;IACT,OAAO;CACC,CAAA;AAIV,4EAA4E;AAC/D,QAAA,4BAA4B,GAAG,EAAE,CAAA"}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/actions/shared.ts"],"names":[],"mappings":";;;AA4BA,8EAA8E;AACjE,QAAA,mBAAmB,GAAG;IACjC,SAAS;IACT,MAAM;IACN,SAAS;IACT,OAAO;CACC,CAAA;AAIV;;;;GAIG;AACU,QAAA,4BAA4B,GAAG,EAAE,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { DateCondition, ReadinessState, SearchableSortFields, SortOrders } from '../../shared';
2
2
  import { LocationStatus } from '../../locations/constants';
3
+ import { ListScope } from '../../usergroups/access';
3
4
  export declare type AssetSearchField = 'name' | 'tagIds';
4
5
  export declare type AssetEmbedField = 'meta' | 'tagIds' | 'candidateLocations' | 'telemetry' | 'readers' | 'readiness';
5
6
  export declare type AssetSortField = SearchableSortFields | 'battery' | 'ready';
@@ -95,5 +96,12 @@ export interface GetAssetsQuery extends AssetFilters {
95
96
  * distinct "gone" error, never an empty page.
96
97
  */
97
98
  semanticQueryId?: string;
99
+ /**
100
+ * `caller`, the default, applies the caller's user groups. `organisation`
101
+ * ignores them and lists the whole organisation, for a client that filters
102
+ * locally. Any signed-in user may pass it. Not a filter: it combines with a
103
+ * stored query.
104
+ */
105
+ scope?: ListScope;
98
106
  }
99
107
  export {};
@@ -1,3 +1,4 @@
1
+ import { ListScope } from '../../usergroups/access';
1
2
  export interface GetAssetPartitionsQuery {
2
3
  /**
3
4
  * How many near-equal slices to split the caller's assets into, in id
@@ -6,4 +7,10 @@ export interface GetAssetPartitionsQuery {
6
7
  * side. Default 4, at most 16.
7
8
  */
8
9
  parts?: number;
10
+ /**
11
+ * `caller`, the default, slices the assets the caller's groups grant.
12
+ * `organisation` slices the whole organisation, which a client that
13
+ * downloads everything and filters locally passes on its first download.
14
+ */
15
+ scope?: ListScope;
9
16
  }
@@ -1,5 +1,4 @@
1
1
  import { FieldDataType, FieldInputType } from '../constants';
2
- import { PermissionGrant } from '../../usergroups/shared';
3
2
  export interface GetFieldResponse {
4
3
  id: string;
5
4
  name: string;
@@ -22,8 +21,6 @@ export interface GetFieldResponse {
22
21
  decimalMin?: number;
23
22
  decimalMax?: number;
24
23
  decimalPlaces?: number;
25
- /** UI-only visibility grants (usergroups); absent/empty = open. */
26
- permissions?: PermissionGrant[];
27
24
  meta?: {
28
25
  created: number;
29
26
  updated?: number;
@@ -1,5 +1,4 @@
1
1
  import { FieldInputType } from '../../constants';
2
- import { PermissionGrant } from '../../../usergroups/shared';
3
2
  export interface UpdateFieldRequestOption {
4
3
  value: string;
5
4
  /**
@@ -30,7 +29,4 @@ export interface UpdateFieldRequest {
30
29
  decimalMin?: number | null;
31
30
  decimalMax?: number | null;
32
31
  decimalPlaces?: number | null;
33
- /** UI-only visibility grants — replaced wholesale; [] clears them (open).
34
- * Every group id must exist in the org. */
35
- permissions?: PermissionGrant[];
36
32
  }
@@ -1,5 +1,6 @@
1
1
  import { SearchableSortFields, SortOrders } from '../../shared';
2
2
  import { LocationType } from '../constants';
3
+ import { ListScope } from '../../usergroups/access';
3
4
  export declare type LocationSearchField = 'name';
4
5
  export declare type LocationEmbedField = 'meta' | 'tagIds' | 'readers' | 'telemetry' | 'status';
5
6
  export declare type LocationSortField = SearchableSortFields | 'path';
@@ -43,4 +44,11 @@ export interface GetLocationsQuery extends LocationFilters {
43
44
  * saved query resolves "today" differently depending on who runs it.
44
45
  */
45
46
  timezone?: string;
47
+ /**
48
+ * `caller`, the default, applies the caller's location union. `organisation`
49
+ * ignores it and lists every location, for a client that filters locally.
50
+ * Any signed-in user may pass it. Not a filter: it combines with a stored
51
+ * query.
52
+ */
53
+ scope?: ListScope;
46
54
  }
@@ -5,6 +5,13 @@ export interface GetOrganisationResponse {
5
5
  id: string;
6
6
  name: string;
7
7
  tenant?: Tenant;
8
+ /**
9
+ * The organisation's IANA timezone (one of `timezoneOptions`), the calendar
10
+ * its readiness rules evaluate `TODAY()` against and the overnight readiness
11
+ * refresh follows. Absent when never set: read it as
12
+ * `DEFAULT_ORGANISATION_TIMEZONE`.
13
+ */
14
+ timezone?: string;
8
15
  ancestors?: IEmbeddedEntity[];
9
16
  preferences?: Preferences;
10
17
  integrations?: Integrations;
@@ -6,6 +6,8 @@ export interface NetworkWithDeletionFlag extends INetworkRequest {
6
6
  export interface UpdateOrganisationRequest {
7
7
  name?: string;
8
8
  tenant?: Tenant;
9
+ /** IANA timezone, one of `timezoneOptions` — see `GetOrganisationResponse.timezone`. */
10
+ timezone?: string;
9
11
  networks?: NetworkWithDeletionFlag[];
10
12
  preferences?: Preferences;
11
13
  }
@@ -44,3 +44,12 @@ export interface Preferences {
44
44
  }>;
45
45
  }
46
46
  export declare type Tenant = 'g2g' | 'spotto';
47
+ /**
48
+ * The timezone an organisation is read as when it has never set one
49
+ * (`GetOrganisationResponse.timezone` absent). Readiness rules that call
50
+ * `TODAY()` evaluate against the organisation's local date, so this is also
51
+ * the calendar the overnight readiness refresh follows for such organisations.
52
+ * Sydney is the company's home zone and where most customers are; an
53
+ * organisation elsewhere should set its own.
54
+ */
55
+ export declare const DEFAULT_ORGANISATION_TIMEZONE = "Australia/Sydney";
@@ -1,3 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_ORGANISATION_TIMEZONE = void 0;
4
+ /**
5
+ * The timezone an organisation is read as when it has never set one
6
+ * (`GetOrganisationResponse.timezone` absent). Readiness rules that call
7
+ * `TODAY()` evaluate against the organisation's local date, so this is also
8
+ * the calendar the overnight readiness refresh follows for such organisations.
9
+ * Sydney is the company's home zone and where most customers are; an
10
+ * organisation elsewhere should set its own.
11
+ */
12
+ exports.DEFAULT_ORGANISATION_TIMEZONE = 'Australia/Sydney';
3
13
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/organisations/constants.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/organisations/constants.ts"],"names":[],"mappings":";;;AAwDA;;;;;;;GAOG;AACU,QAAA,6BAA6B,GAAG,kBAAkB,CAAA"}
@@ -1,20 +1,23 @@
1
1
  import { GroupHomeLayout } from '../../../users/home-layout';
2
+ import { ActionAccess, AssetAccessRuleRequest } from '../../access';
2
3
  /**
3
- * Membership and scope are replaced wholesale; an empty array clears either
4
- * (a scope-less group abstains from location scope). `allLocations: false`
5
- * clears the sentinel. Changes that alter the actor's own membership are
4
+ * Membership, the rule and the action access are replaced wholesale; an
5
+ * empty member list empties the group and an empty rule array leaves it
6
+ * granting no assets. Changes that alter the actor's own membership are
6
7
  * rejected (the own-role-guard rule).
7
8
  */
8
9
  export interface UpdateUsergroupRequest {
9
10
  name?: string;
10
11
  members?: string[];
11
- locationScope?: string[];
12
- allLocations?: boolean;
12
+ /** Replaced wholesale. `[]` leaves the group granting no assets. */
13
+ assetAccessRules?: AssetAccessRuleRequest[];
14
+ /** Replaced wholesale. */
15
+ actionAccess?: ActionAccess;
13
16
  /**
14
- * Replaced wholesale, like membership and scope. `null` CLEARS it — the
15
- * group stops provisioning a layout, and members lose the row from their
16
- * switcher. An empty widget list is a different thing: a layout that exists
17
- * and happens to be empty.
17
+ * Replaced wholesale, like membership. `null` CLEARS it — the group stops
18
+ * provisioning a layout, and members lose the row from their switcher. An
19
+ * empty widget list is a different thing: a layout that exists and happens
20
+ * to be empty.
18
21
  */
19
22
  homeLayout?: GroupHomeLayout | null;
20
23
  }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The group permission model: one asset rule per group, with the field access
3
+ * inside the rule and the action access beside it. A group only ever grants.
4
+ *
5
+ * Specification: business_unit_access/group_permission_spec_v31.md, section 3.
6
+ * The evaluation that both the API and the client run over these shapes lives
7
+ * in `@spotto/semantic-query` (its rules module), not here.
8
+ */
9
+ /** The level a rule or a field grant confers. Edit implies view. */
10
+ export declare const ASSET_ACCESS_LEVELS: readonly ["VIEW", "EDIT"];
11
+ export declare type AssetAccessLevel = (typeof ASSET_ACCESS_LEVELS)[number];
12
+ /** `ALL`: the whole dimension. `SELECTED`: the listed entries, which OR together. */
13
+ export declare const ACCESS_SELECTION_MODES: readonly ["ALL", "SELECTED"];
14
+ export declare type AccessSelectionMode = (typeof ACCESS_SELECTION_MODES)[number];
15
+ /** The one operator a custom-field filter takes in this release. */
16
+ export declare const RULE_FILTER_OPERATORS: readonly ["IN"];
17
+ export declare type RuleFilterOperator = (typeof RULE_FILTER_OPERATORS)[number];
18
+ /** One dimension of a rule: the whole organisation, or a set of subtrees. */
19
+ export interface AccessPathSelection {
20
+ mode: AccessSelectionMode;
21
+ /**
22
+ * Required and non-empty under `SELECTED`, absent under `ALL`. Stored in the
23
+ * canonical form with the trailing pipe (`Eastern|Sydney|`), so a prefix
24
+ * never reaches a sibling (`Eastern|Sydneyside|`). The organisation root,
25
+ * whose path is empty, is never a valid entry: `ALL` is the way to say the
26
+ * whole organisation.
27
+ */
28
+ paths?: string[];
29
+ }
30
+ /** A custom-field filter: the asset's value for the field is one of these. */
31
+ export interface AccessFieldFilter {
32
+ /** A single-select field: `DROPDOWN` or `RADIO` with an option list. */
33
+ fieldId: string;
34
+ operator: RuleFilterOperator;
35
+ /** Option values, non-empty. A discontinued option may still be named. */
36
+ values: string[];
37
+ }
38
+ /**
39
+ * The conditions of a rule. Within a dimension the entries OR together;
40
+ * across dimensions they AND. A dimension at `ALL` always matches.
41
+ */
42
+ export interface AssetRuleConditions {
43
+ /** Matches when the asset's home path OR its current location path sits inside a selected subtree. */
44
+ locations: AccessPathSelection;
45
+ /** Matches by type-path prefix, so a selected type covers its subtypes. */
46
+ assetTypes: AccessPathSelection;
47
+ /** Filters AND together, each one's values OR together. Empty or absent means no filter. */
48
+ customFields?: AccessFieldFilter[];
49
+ }
50
+ export interface FieldAccessGrant {
51
+ fieldId: string;
52
+ level: AssetAccessLevel;
53
+ }
54
+ /**
55
+ * The custom fields a group grants. `ALL` grants every field, the ones created
56
+ * later included, at one level. `SELECTED` grants the listed fields each at a
57
+ * level; hidden fields are omitted, never stored, and an empty list grants no
58
+ * custom field at all, which is the only way to say standard fields only.
59
+ */
60
+ export declare type FieldAccess = {
61
+ mode: 'ALL';
62
+ level: AssetAccessLevel;
63
+ } | {
64
+ mode: 'SELECTED';
65
+ fields: FieldAccessGrant[];
66
+ };
67
+ export interface AssetAccessRule {
68
+ /** Assigned by the server when a request omits it. */
69
+ id: string;
70
+ /** Required with `conditions`; without them it is ignored and may be omitted. */
71
+ level?: AssetAccessLevel;
72
+ /**
73
+ * Absent on a rule-less group, whose field access applies to every asset
74
+ * the member can open, capped by what the member can do to that asset.
75
+ */
76
+ conditions?: AssetRuleConditions;
77
+ fieldAccess: FieldAccess;
78
+ }
79
+ /** A rule as a request carries it: the id is optional. */
80
+ export declare type AssetAccessRuleRequest = Omit<AssetAccessRule, 'id'> & {
81
+ id?: string;
82
+ };
83
+ /**
84
+ * The actions a group grants, binary and unpaired with the asset rule. A group
85
+ * document without the key grants no action, and the read emits it as
86
+ * `SELECTED` with an empty list.
87
+ */
88
+ export declare type ActionAccess = {
89
+ mode: 'ALL';
90
+ } | {
91
+ mode: 'SELECTED';
92
+ actions: string[];
93
+ };
94
+ /**
95
+ * The scope a list read applies: the caller's groups, the default, or the
96
+ * whole organisation. Any signed-in user may ask for the organisation; the
97
+ * parameter exists for clients that filter locally.
98
+ */
99
+ export declare const LIST_SCOPES: readonly ["caller", "organisation"];
100
+ export declare type ListScope = (typeof LIST_SCOPES)[number];
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * The group permission model: one asset rule per group, with the field access
4
+ * inside the rule and the action access beside it. A group only ever grants.
5
+ *
6
+ * Specification: business_unit_access/group_permission_spec_v31.md, section 3.
7
+ * The evaluation that both the API and the client run over these shapes lives
8
+ * in `@spotto/semantic-query` (its rules module), not here.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.LIST_SCOPES = exports.RULE_FILTER_OPERATORS = exports.ACCESS_SELECTION_MODES = exports.ASSET_ACCESS_LEVELS = void 0;
12
+ /** The level a rule or a field grant confers. Edit implies view. */
13
+ exports.ASSET_ACCESS_LEVELS = ['VIEW', 'EDIT'];
14
+ /** `ALL`: the whole dimension. `SELECTED`: the listed entries, which OR together. */
15
+ exports.ACCESS_SELECTION_MODES = ['ALL', 'SELECTED'];
16
+ /** The one operator a custom-field filter takes in this release. */
17
+ exports.RULE_FILTER_OPERATORS = ['IN'];
18
+ /**
19
+ * The scope a list read applies: the caller's groups, the default, or the
20
+ * whole organisation. Any signed-in user may ask for the organisation; the
21
+ * parameter exists for clients that filter locally.
22
+ */
23
+ exports.LIST_SCOPES = ['caller', 'organisation'];
24
+ //# sourceMappingURL=access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.js","sourceRoot":"","sources":["../../src/usergroups/access.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,oEAAoE;AACvD,QAAA,mBAAmB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAA;AAG5D,qFAAqF;AACxE,QAAA,sBAAsB,GAAG,CAAC,KAAK,EAAE,UAAU,CAAU,CAAA;AAGlE,oEAAoE;AACvD,QAAA,qBAAqB,GAAG,CAAC,IAAI,CAAU,CAAA;AA8EpD;;;;GAIG;AACU,QAAA,WAAW,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAU,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { IEntityMeta } from '../../shared';
2
2
  import { GroupHomeLayout } from '../../users/home-layout';
3
+ import { ActionAccess, AssetAccessRule } from '../access';
3
4
  import { GetUsergroupsQuery } from './query';
4
5
  export interface GetUsergroupResponse {
5
6
  id: string;
@@ -7,17 +8,16 @@ export interface GetUsergroupResponse {
7
8
  /** User ids. Membership's source of truth lives here, never on the user. */
8
9
  members: string[];
9
10
  /**
10
- * Location-name path prefixes this group confines its members to. Absent
11
- * or empty = the group abstains from location scope (it may exist purely
12
- * for field/action grants).
11
+ * The group's asset rule, at most one in this release, carried as an array
12
+ * for later expansion. An empty array grants no assets, which stays valid
13
+ * for a group that exists for its home layout or an SSO mapping.
13
14
  */
14
- locationScope?: string[];
15
+ assetAccessRules: AssetAccessRule[];
15
16
  /**
16
- * The explicit "entire organisation" sentinel — never expressed as the
17
- * root location's path (the root's name is the empty string). Emitted
18
- * only when true.
17
+ * The actions the group grants. A document without the key reads as
18
+ * `SELECTED` with an empty list.
19
19
  */
20
- allLocations?: boolean;
20
+ actionAccess: ActionAccess;
21
21
  /**
22
22
  * True when the group is referenced by the org's SSO `usergroupMappings` —
23
23
  * i.e. membership is SSO-managed for federated users (manual membership
@@ -2,3 +2,4 @@ export * from './shared';
2
2
  export * from './get';
3
3
  export * from './post';
4
4
  export * from './[id]';
5
+ export * from './access';
@@ -18,4 +18,5 @@ __exportStar(require("./shared"), exports);
18
18
  __exportStar(require("./get"), exports);
19
19
  __exportStar(require("./post"), exports);
20
20
  __exportStar(require("./[id]"), exports);
21
+ __exportStar(require("./access"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/usergroups/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,wCAAqB;AACrB,yCAAsB;AACtB,yCAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/usergroups/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,wCAAqB;AACrB,yCAAsB;AACtB,yCAAsB;AACtB,2CAAwB"}
@@ -1,14 +1,17 @@
1
1
  import { GroupHomeLayout } from '../../users/home-layout';
2
+ import { ActionAccess, AssetAccessRuleRequest } from '../access';
2
3
  export interface PostUsergroupRequest {
3
4
  name: string;
4
5
  /** User ids. The actor's own id is rejected — nobody edits their own
5
6
  * memberships (the own-role-guard rule). */
6
7
  members?: string[];
7
- /** Non-empty location-name path prefixes; omitted/empty = the group
8
- * abstains from location scope. Never the root path — "entire
9
- * organisation" is `allLocations: true`. */
10
- locationScope?: string[];
11
- allLocations?: boolean;
8
+ /**
9
+ * The group's asset rule, at most one. Omit, or send `[]`, for a group that
10
+ * grants no assets. The server assigns a rule id when the request omits it.
11
+ */
12
+ assetAccessRules?: AssetAccessRuleRequest[];
13
+ /** The actions the group grants. Omitted, the group grants no action. */
14
+ actionAccess?: ActionAccess;
12
15
  /** A Home layout to provision to this group's members. */
13
16
  homeLayout?: GroupHomeLayout;
14
17
  }
@@ -1,25 +1,8 @@
1
1
  /**
2
- * Effective access level a field grant confers. Most-permissive wins across
3
- * a user's groups; a field with no grants at all is open (EDIT) to everyone.
4
- * Actions reuse the grant shape with `level` ignored (binary: any grant ⇒
5
- * members-only).
2
+ * The three-valued level the evaluation reports for a custom field on one
3
+ * asset: `NONE` (hidden), `VIEW` or `EDIT`. Rules and grants are authored at
4
+ * `VIEW` or `EDIT` only (`ASSET_ACCESS_LEVELS` in `access.ts`); `NONE` is an
5
+ * outcome, never stored.
6
6
  */
7
7
  export declare const PERMISSION_GRANT_LEVELS: readonly ["NONE", "VIEW", "EDIT"];
8
8
  export declare type PermissionGrantLevel = (typeof PERMISSION_GRANT_LEVELS)[number];
9
- /** One usergroup's grant on a field or action. */
10
- export interface PermissionGrant {
11
- /** Usergroup id — must exist in the organisation at write time. */
12
- group: string;
13
- level: PermissionGrantLevel;
14
- }
15
- /**
16
- * A user's resolved location scope, derived from their usergroups: any
17
- * `allLocations` group — or no location-defining group at all — resolves to
18
- * unconfined; otherwise the union of the groups' `locationScope` prefixes.
19
- * Emitted on GET /users/current so the client can detect scope changes.
20
- */
21
- export declare type UsergroupsScope = {
22
- unconfined: true;
23
- } | {
24
- paths: string[];
25
- };
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PERMISSION_GRANT_LEVELS = void 0;
4
4
  /**
5
- * Effective access level a field grant confers. Most-permissive wins across
6
- * a user's groups; a field with no grants at all is open (EDIT) to everyone.
7
- * Actions reuse the grant shape with `level` ignored (binary: any grant ⇒
8
- * members-only).
5
+ * The three-valued level the evaluation reports for a custom field on one
6
+ * asset: `NONE` (hidden), `VIEW` or `EDIT`. Rules and grants are authored at
7
+ * `VIEW` or `EDIT` only (`ASSET_ACCESS_LEVELS` in `access.ts`); `NONE` is an
8
+ * outcome, never stored.
9
9
  */
10
10
  exports.PERMISSION_GRANT_LEVELS = ['NONE', 'VIEW', 'EDIT'];
11
11
  //# sourceMappingURL=shared.js.map
@@ -3,11 +3,24 @@ import { Preferences } from '../organisations/constants';
3
3
  import { Integrations } from '../integrations/constants';
4
4
  import { System } from '../system';
5
5
  import { ProvisionedHomeLayout, StoredHomeLayout } from './home-layout';
6
- import { PermissionGrantLevel, UsergroupsScope } from '../usergroups/shared';
7
- /** One entry of the §1.7 field access list — every org field appears. */
8
- export interface FieldAccessEntry {
6
+ import { ActionAccess, AssetAccessRule } from '../usergroups/access';
7
+ /**
8
+ * One of the caller's groups as the app needs it: the rule, its field access
9
+ * and the action access, so the shared rules module can run on the device.
10
+ * Membership and layouts are not repeated here.
11
+ */
12
+ export interface CurrentUserUsergroup {
9
13
  id: string;
10
- level: PermissionGrantLevel;
14
+ name: string;
15
+ assetAccessRules: AssetAccessRule[];
16
+ actionAccess: ActionAccess;
17
+ }
18
+ /** What the caller's role exempts them from. */
19
+ export interface UsergroupsExempt {
20
+ /** The role carries the exemption literal: asset rules do not apply. */
21
+ assets: boolean;
22
+ /** The role carries `fields:admin`: every custom field, at the asset's level. */
23
+ fields: boolean;
11
24
  }
12
25
  export interface EmbeddedRole extends IEmbeddedEntity {
13
26
  permissions: string[];
@@ -15,6 +28,14 @@ export interface EmbeddedRole extends IEmbeddedEntity {
15
28
  export interface EmbeddedOrganisation extends IEmbeddedEntity {
16
29
  preferences: Preferences;
17
30
  integrations?: Integrations;
31
+ /**
32
+ * The organisation's IANA timezone, as `GetOrganisationResponse.timezone`,
33
+ * carried here so every signed-in device evaluates readiness rules, form
34
+ * conditions and option rules in the organisation's calendar without
35
+ * reading the organisation itself, which needs `organisations:view`.
36
+ * Absent when never set: read it as `DEFAULT_ORGANISATION_TIMEZONE`.
37
+ */
38
+ timezone?: string;
18
39
  }
19
40
  export interface CurrentUserResponse {
20
41
  id: string;
@@ -60,21 +81,21 @@ export interface CurrentUserResponse {
60
81
  */
61
82
  groupHomeLayouts?: ProvisionedHomeLayout[];
62
83
  /**
63
- * UI-only visibility lists (usergroups feature) — COMPLETE: every org
64
- * field appears with the caller's effective level (grant-less ⇒ EDIT;
65
- * admin bypass ⇒ all EDIT), every usable action id appears. All three
66
- * keys are omitted entirely when the org toggle is OFF — client rule:
67
- * absent list (or absent id) ⇒ open.
84
+ * The complete list of usable action ids, computed from the caller's
85
+ * groups: every id for an open or admin caller or a member of an All
86
+ * actions group, the union of the Selected lists otherwise. Omitted when
87
+ * the toggle is off, which the app reads as open. A user in no group gets
88
+ * an empty list.
68
89
  */
69
- fieldAccess?: FieldAccessEntry[];
70
90
  actionAccess?: string[];
71
91
  /**
72
- * The caller's resolved location scope, verbatim from the user-doc cache.
73
- * The offline client treats a CHANGE in this value (including appearing/
74
- * disappearing) as its delta-cursor + cache reset trigger — delta reads
75
- * never re-deliver docs whose lastChanged predates the cursor.
92
+ * The caller's groups with their rules, field access and action access,
93
+ * for the app's local evaluation. Omitted when the toggle is off, which the
94
+ * app reads as open. Emitted as `[]` for a user in no group.
76
95
  */
77
- usergroupsScope?: UsergroupsScope;
96
+ usergroups?: CurrentUserUsergroup[];
97
+ /** Omitted when the toggle is off. */
98
+ usergroupsExempt?: UsergroupsExempt;
78
99
  }
79
100
  export interface CurrentUserPublicResponse {
80
101
  id: string;
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.35",
4
+ "version": "1.0.70-alpha.37",
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": "7534d6b7699136610bfd65f75b50407e80d404f5"
21
+ "gitHead": "55a29affe0ebc09495a381fd90a9eb92ba0155b0"
22
22
  }