@twinfinity/twin 6.1.0 → 6.1.2-ci.30738
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 +63 -2
- package/dist/BuildInfo.js +3 -3
- package/dist/TwinClient.d.ts +312 -9
- package/dist/TwinClient.d.ts.map +1 -1
- package/dist/TwinClient.js +321 -6
- package/dist/TwinClient.js.map +1 -1
- package/dist/errors.d.ts +120 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +116 -2
- package/dist/errors.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/generated.d.ts +93 -31
- package/dist/types/generated.d.ts.map +1 -1
- package/dist/types/twin-api.d.ts +54 -1
- package/dist/types/twin-api.d.ts.map +1 -1
- package/dist/types/twin-permissions-api.d.ts +226 -6
- package/dist/types/twin-permissions-api.d.ts.map +1 -1
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/AssetAttachmentConflictError.html +1 -1
- package/docs/classes/AssetAttachmentNotFoundError.html +1 -1
- package/docs/classes/AssetBatchError.html +1 -1
- package/docs/classes/AssetCatalogTooLargeError.html +1 -1
- package/docs/classes/AssetCategoryConflictError.html +1 -1
- package/docs/classes/AssetCategoryForbiddenError.html +1 -1
- package/docs/classes/AssetCategoryNotFoundError.html +1 -1
- package/docs/classes/AssetCategoryValidationError.html +1 -1
- package/docs/classes/AssetConflictError.html +1 -1
- package/docs/classes/AssetForbiddenError.html +1 -1
- package/docs/classes/AssetNotFoundError.html +1 -1
- package/docs/classes/AssetPermissionsConflictError.html +16 -0
- package/docs/classes/AssetTypeConflictError.html +1 -1
- package/docs/classes/AssetTypeForbiddenError.html +1 -1
- package/docs/classes/AssetTypeNotFoundError.html +1 -1
- package/docs/classes/AssetTypeValidationError.html +1 -1
- package/docs/classes/AssetValidationError.html +1 -1
- package/docs/classes/ProcessorNotFoundError.html +1 -1
- package/docs/classes/TwinClient.html +251 -73
- package/docs/classes/TwinConflictError.html +1 -1
- package/docs/classes/TwinFileConflictError.html +1 -1
- package/docs/classes/TwinFileNotFoundError.html +1 -1
- package/docs/classes/TwinFileValidationError.html +1 -1
- package/docs/classes/TwinNotFoundError.html +4 -2
- package/docs/classes/TwinPermissionsConflictError.html +19 -0
- package/docs/classes/TwinPermissionsForbiddenError.html +12 -0
- package/docs/classes/TwinPrincipalNotFoundError.html +5 -0
- package/docs/classes/TwinTemporarilyUnavailableError.html +10 -0
- package/docs/classes/TwinUnauthenticatedError.html +1 -1
- package/docs/classes/TwinValidationError.html +1 -1
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +56 -4
- package/docs/interfaces/AssetCatalogTooLargeErrorBody.html +2 -2
- package/docs/interfaces/AssetGroupGet.html +9 -0
- package/docs/interfaces/AssetGroupsGet.html +3 -0
- package/docs/interfaces/AssetPermissionsConflictErrorBody.html +12 -0
- package/docs/interfaces/AssetPermissionsPut.html +9 -0
- package/docs/interfaces/AssetPrincipalPermissionsGet.html +23 -0
- package/docs/interfaces/Coordinates.html +6 -0
- package/docs/interfaces/EntityCollection.html +7 -2
- package/docs/interfaces/EntityRepresentation.html +12 -0
- package/docs/interfaces/Facility.html +8 -3
- package/docs/interfaces/FacilityPart.html +5 -3
- package/docs/interfaces/ITwinClient.html +251 -73
- package/docs/interfaces/InheritedPermissions.html +8 -0
- package/docs/interfaces/ListTwinItem.html +18 -2
- package/docs/interfaces/Location.html +4 -1
- package/docs/interfaces/MyPermissions.html +2 -2
- package/docs/interfaces/MyTwinPermissions.html +5 -0
- package/docs/interfaces/Site.html +11 -4
- package/docs/interfaces/Space.html +6 -3
- package/docs/interfaces/TwinErrorBody.html +2 -2
- package/docs/interfaces/TwinGet.html +29 -11
- package/docs/interfaces/TwinGroupGet.html +10 -0
- package/docs/interfaces/TwinGroupsGet.html +3 -0
- package/docs/interfaces/TwinPermissionsConflictErrorBody.html +8 -0
- package/docs/interfaces/TwinPermissionsPut.html +11 -0
- package/docs/interfaces/TwinPrincipalPermissionsGet.html +34 -0
- package/docs/interfaces/TwinPut.html +8 -10
- package/docs/interfaces/TwinReference.html +4 -0
- package/docs/interfaces/TwinSpecification.html +7 -9
- package/docs/media/twin-management.md +197 -0
- package/docs/modules.html +1 -1
- package/docs/types/TwinBoundCapabilityName.html +8 -0
- package/docs/types/TwinCapability.html +11 -5
- package/docs/types/TwinCapabilityName.html +8 -0
- package/docs/types/TwinErrorCause.html +1 -1
- package/docs/types/TwinErrorItemKind.html +1 -1
- package/docs/types/TwinPermissionsConflictCause.html +6 -0
- package/docs/types/TwinScopedCapability.html +9 -0
- package/docs/types/TwinScopedCapabilityName.html +8 -0
- package/package.json +3 -3
- package/src/TwinClient.ts +776 -15
- package/src/errors.ts +191 -4
- package/src/types/generated.ts +93 -33
- package/src/types/twin-api.ts +55 -1
- package/src/types/twin-permissions-api.ts +243 -6
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Named, customer-scoped capability the caller can exercise against the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Named, customer-scoped capability the caller can exercise against the Twin service, granted on
|
|
3
|
+
* the asset domain — the one thing the service governs that is not bound to a single
|
|
4
|
+
* twin. Returned by `GET /twins/permissions/me`, listed by `GET /twins/permissions` and accepted by
|
|
5
|
+
* `PUT /twins/permissions/{principalId}`. Mirrors `Twinfinity.Twin.Model.TwinCapability`.
|
|
6
|
+
*
|
|
7
|
+
* Distinct from {@link TwinScopedCapability}, which is held on one twin. The two vocabularies never
|
|
8
|
+
* share a name, because `GET /twins/{twinId}/permissions/me` answers with one flat array mixing
|
|
9
|
+
* both and each name is resolved against the vocabulary it came from.
|
|
10
|
+
*
|
|
11
|
+
* This is the *write* vocabulary — the capabilities a grant may ask for. Values read back from the
|
|
12
|
+
* service are {@link TwinCapabilityName}, which also admits capabilities a newer server knows and
|
|
13
|
+
* this client does not; such a value is "not granted" as far as this client is concerned, and must
|
|
14
|
+
* be ignored rather than treated as an error.
|
|
7
15
|
*/
|
|
8
|
-
export type TwinCapability = '
|
|
16
|
+
export type TwinCapability = 'ViewAssets' | 'EditAssets' | 'DeleteAssets' | 'EditAssetTypes' | 'ManageAssetPermissions';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A capability as *read back* from the service: one of {@link TwinCapability}, or a name a newer
|
|
20
|
+
* server knows and this client does not.
|
|
21
|
+
*
|
|
22
|
+
* Deliberately wider than the write vocabulary. A grant may only ask for capabilities that exist,
|
|
23
|
+
* so {@link TwinCapability} stays closed and a typo is a compile error; a listing, though, is
|
|
24
|
+
* whatever the server says, and ADR-0008 §5 makes tolerating unknown names a rule for readers. The
|
|
25
|
+
* `(string & {})` tail keeps autocomplete on the five known values while forcing consumers who
|
|
26
|
+
* `switch` over a capability to write a default arm — which is where an unknown one must land.
|
|
27
|
+
*/
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
29
|
+
export type TwinCapabilityName = TwinCapability | (string & {});
|
|
9
30
|
|
|
10
31
|
/**
|
|
11
32
|
* Response body for `GET /twins/permissions/me`. The `permissions` array
|
|
@@ -16,5 +37,221 @@ export type TwinCapability = 'ViewAssetTypes' | 'EditAssetTypes';
|
|
|
16
37
|
* etag, an identity echo, expiry — can be added without a shape break.
|
|
17
38
|
*/
|
|
18
39
|
export interface MyPermissions {
|
|
40
|
+
permissions: TwinCapabilityName[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Named capability a principal can hold on one specific twin, granted through
|
|
45
|
+
* `/twins/{twinId}/permissions`. Mirrors `Twinfinity.Twin.Model.TwinScopedCapability`.
|
|
46
|
+
*
|
|
47
|
+
* Distinct from {@link TwinCapability}, which is customer-scoped and speaks about the
|
|
48
|
+
* asset domain rather than about one twin.
|
|
49
|
+
*
|
|
50
|
+
* This is the *write* vocabulary — the four capabilities a grant may ask for. Values read back
|
|
51
|
+
* from the service are {@link TwinScopedCapabilityName}, which also admits capabilities a newer
|
|
52
|
+
* server knows and this client does not; such a value is "not granted" as far as this client is
|
|
53
|
+
* concerned, and must be ignored rather than treated as an error.
|
|
54
|
+
*/
|
|
55
|
+
export type TwinScopedCapability = 'ReadTwin' | 'WriteTwin' | 'DeleteTwin' | 'ManageTwinPermissions';
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A capability as *read back* from the service: one of {@link TwinScopedCapability}, or a name a
|
|
59
|
+
* newer server knows and this client does not.
|
|
60
|
+
*
|
|
61
|
+
* Deliberately wider than the write vocabulary. A grant may only ask for capabilities that exist,
|
|
62
|
+
* so {@link TwinPermissionsPut} stays closed and a typo is a compile error; a listing, though, is
|
|
63
|
+
* whatever the server says, and ADR-0008 §5 makes tolerating unknown names a rule for readers. The
|
|
64
|
+
* `(string & {})` tail keeps autocomplete on the four known values while forcing consumers who
|
|
65
|
+
* `switch` over a capability to write a default arm — which is where an unknown one must land.
|
|
66
|
+
*/
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
68
|
+
export type TwinScopedCapabilityName = TwinScopedCapability | (string & {});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A capability as read back from `GET /twins/{twinId}/permissions/me`. That probe answers with one
|
|
72
|
+
* flat array mixing both vocabularies: the twin's own {@link TwinScopedCapability} values, plus the
|
|
73
|
+
* asset-instance capabilities `ViewAssets`, `EditAssets` and `DeleteAssets` from the customer-wide
|
|
74
|
+
* asset domain, which gate the assets hanging off the twin. `EditAssetTypes` and
|
|
75
|
+
* `ManageAssetPermissions` are not twin-bound and are absent — ask `GET /twins/permissions/me`.
|
|
76
|
+
*
|
|
77
|
+
* Names never collide across the two enums, so `includes('EditAssets')` is unambiguous. As with
|
|
78
|
+
* {@link TwinScopedCapabilityName}, the `(string & {})` tail admits names a newer server knows.
|
|
79
|
+
*/
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
81
|
+
export type TwinBoundCapabilityName = TwinScopedCapability | TwinCapability | (string & {});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Response body for `GET /twins/{twinId}/permissions/me`: the capabilities the caller
|
|
85
|
+
* holds on that twin. The endpoint is open to every authenticated caller — an empty
|
|
86
|
+
* list is an honest answer, not a refusal — so it is safe to call before rendering.
|
|
87
|
+
*/
|
|
88
|
+
export interface MyTwinPermissions {
|
|
89
|
+
permissions: TwinBoundCapabilityName[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* One entry of an access-control-list row's `inheritedPermissions`: capabilities the row's principal
|
|
94
|
+
* holds from a grant made somewhere other than this resource, and where that grant lives.
|
|
95
|
+
*
|
|
96
|
+
* `source` is an entity reference. A grant held customer-wide is spelled as the bare domain token
|
|
97
|
+
* with no trailing separator — `"twin"` for the asset capabilities a twin reports — which is where
|
|
98
|
+
* an administration UI has to go to change them.
|
|
99
|
+
*/
|
|
100
|
+
export interface InheritedPermissions {
|
|
101
|
+
source: string;
|
|
102
|
+
permissions: TwinBoundCapabilityName[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* One principal's permission entry on a twin, as listed by
|
|
107
|
+
* `GET /twins/{twinId}/permissions` and returned by the mutation endpoints.
|
|
108
|
+
*
|
|
109
|
+
* This is where the provenance split lives: {@link permissions} is what an administrator can edit
|
|
110
|
+
* here, {@link inheritedPermissions} is what confers ability on the twin from elsewhere, and
|
|
111
|
+
* {@link effectivePermissions} is what this principal can actually do. All three describe *this
|
|
112
|
+
* row's principal* — a twin's own representation is the one that describes the caller, and it
|
|
113
|
+
* carries the verdict alone.
|
|
114
|
+
*/
|
|
115
|
+
export interface TwinPrincipalPermissionsGet {
|
|
116
|
+
/** Global id of the principal (a group; users are not grantable per ADR-0008 §6). */
|
|
117
|
+
principalId: string;
|
|
118
|
+
/** The principal's display title. */
|
|
119
|
+
name: string;
|
|
120
|
+
/**
|
|
121
|
+
* What this principal holds from grants made on the twin *itself*, and the only part this
|
|
122
|
+
* surface writes: `setTwinPermissions` replaces exactly this set.
|
|
123
|
+
*/
|
|
124
|
+
permissions: TwinScopedCapabilityName[];
|
|
125
|
+
/**
|
|
126
|
+
* One entry per place outside this twin that confers ability on it. A twin has one possible
|
|
127
|
+
* source: the domain, `source: 'twin'`, carrying whichever of `ViewAssets`, `EditAssets` and
|
|
128
|
+
* `DeleteAssets` this principal holds customer-wide, because `twins/{twinId}/assets` gates on
|
|
129
|
+
* them. The asset catalog capability and `ManageAssetPermissions` never appear — they are
|
|
130
|
+
* domain-wide and confer nothing on one twin. Empty when the principal holds none of them.
|
|
131
|
+
*/
|
|
132
|
+
inheritedPermissions: InheritedPermissions[];
|
|
133
|
+
/**
|
|
134
|
+
* The union of {@link permissions} and every {@link inheritedPermissions} entry — what this
|
|
135
|
+
* principal can actually do on the twin. Calculated by the service on every read and never
|
|
136
|
+
* accepted on a write. Mixes both capability vocabularies, so it is typed the widened way.
|
|
137
|
+
*/
|
|
138
|
+
effectivePermissions: TwinBoundCapabilityName[];
|
|
139
|
+
/**
|
|
140
|
+
* True exactly when a `PUT` or `DELETE` naming this principal would be refused with
|
|
141
|
+
* `SystemPrincipalImmutable`: the twin's own default groups and the seeded Twinfinity
|
|
142
|
+
* system principals. Render the control as disabled rather than discovering the
|
|
143
|
+
* constraint by attempting a write.
|
|
144
|
+
*/
|
|
145
|
+
readOnly: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Optimistic concurrency token for this entry, to send back on the next mutation of this
|
|
148
|
+
* principal. Two entries in one listing may carry different values — edit each with the one its
|
|
149
|
+
* own row reported. Absent when the service had none to report.
|
|
150
|
+
*/
|
|
151
|
+
etag?: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Request body for `PUT /twins/{twinId}/permissions/{principalId}`. */
|
|
155
|
+
export interface TwinPermissionsPut {
|
|
156
|
+
/**
|
|
157
|
+
* The capability set replacing whatever this principal held of the four above; bits
|
|
158
|
+
* outside this vocabulary survive untouched. An empty list revokes all four, which
|
|
159
|
+
* leaves the principal with no listing entry at all unless it carries such bits.
|
|
160
|
+
*/
|
|
161
|
+
permissions: TwinScopedCapability[];
|
|
162
|
+
/**
|
|
163
|
+
* This principal's etag, from its entry in a prior listing or mutation response. May be omitted only to create
|
|
164
|
+
* the grants of a principal that holds nothing on the twin yet — the one case with no
|
|
165
|
+
* entry to read one from. Omitting it on what turns out to be a replacement is refused
|
|
166
|
+
* with `EtagRequired`, and a stale value with `EtagMismatch`.
|
|
167
|
+
*/
|
|
168
|
+
etag?: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* One of the default groups a twin owns — `TwinReaders`, `TwinContributors`,
|
|
173
|
+
* `TwinAdministrators` — provisioned for it when it is created.
|
|
174
|
+
*
|
|
175
|
+
* Address a group by {@link id}: {@link name} is informational and not unique across
|
|
176
|
+
* twins, since every twin's groups carry the same three names. The groups' own grants
|
|
177
|
+
* are immutable; confer a preset by changing a group's membership through the
|
|
178
|
+
* Permission service instead.
|
|
179
|
+
*/
|
|
180
|
+
export interface TwinGroupGet {
|
|
181
|
+
name: string;
|
|
182
|
+
id: string;
|
|
183
|
+
title: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Response body for `GET /twins/{twinId}/groups`. */
|
|
187
|
+
export interface TwinGroupsGet {
|
|
188
|
+
groups: TwinGroupGet[];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* One principal's permission entry on the asset domain, as listed by `GET /twins/permissions` and
|
|
193
|
+
* returned by the mutation endpoints.
|
|
194
|
+
*
|
|
195
|
+
* The etag is customer-wide rather than per principal, so every entry in a listing carries the same
|
|
196
|
+
* value and a write by any administrator invalidates the one every other administrator is holding.
|
|
197
|
+
*/
|
|
198
|
+
export interface AssetPrincipalPermissionsGet {
|
|
199
|
+
/** Global id of the principal (a group; users are not grantable). */
|
|
200
|
+
id: string;
|
|
201
|
+
/** The principal's display name. */
|
|
202
|
+
name: string;
|
|
203
|
+
/** The capabilities this principal holds on the domain. Empty after a full revoke. */
|
|
204
|
+
permissions: TwinCapabilityName[];
|
|
205
|
+
/**
|
|
206
|
+
* True exactly when a `PUT` or `DELETE` naming this principal would be refused with
|
|
207
|
+
* `SystemPrincipalImmutable`: the seeded default groups. Render the control as disabled rather
|
|
208
|
+
* than discovering the constraint by attempting a write. False for everything else, the
|
|
209
|
+
* all-authenticated principal included, whose capabilities are mutable.
|
|
210
|
+
*/
|
|
211
|
+
readOnly: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Optimistic concurrency token, to send back on the next mutation. It is customer-wide rather
|
|
214
|
+
* than per principal, so any administrator's write invalidates the value every other one holds.
|
|
215
|
+
*
|
|
216
|
+
* Because it belongs to the domain rather than to the principal, a revocation answers with one
|
|
217
|
+
* too, even though the revoked principal no longer has a listing entry — so a caller may chain
|
|
218
|
+
* another write straight after a `deleteAssetPermissions` without re-reading the listing.
|
|
219
|
+
*
|
|
220
|
+
* Absent only before the domain has been provisioned for the customer.
|
|
221
|
+
*/
|
|
222
|
+
etag?: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Request body for `PUT /twins/permissions/{principalId}`. */
|
|
226
|
+
export interface AssetPermissionsPut {
|
|
227
|
+
/**
|
|
228
|
+
* The capability set replacing whatever this principal held; an empty list revokes everything
|
|
229
|
+
* and leaves the principal with no listing entry at all.
|
|
230
|
+
*/
|
|
19
231
|
permissions: TwinCapability[];
|
|
232
|
+
/**
|
|
233
|
+
* The domain's etag. May be omitted only to create the grants of a principal that holds nothing
|
|
234
|
+
* yet — the one case with no entry to read one from. Omitting it on what turns out to be a
|
|
235
|
+
* replacement is refused with `EtagRequired`, and a stale value with `EtagMismatch`.
|
|
236
|
+
*/
|
|
237
|
+
etag?: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* One of the asset domain's default groups — `AssetsReaders`, `AssetsContributors`,
|
|
242
|
+
* `AssetsAdministrators` — seeded once per customer.
|
|
243
|
+
*
|
|
244
|
+
* Unlike a twin's groups, {@link name} is unique across the customer and is what
|
|
245
|
+
* {@link ITwinClient.getAssetGroup} addresses. The groups' own grants are immutable; confer a
|
|
246
|
+
* preset by changing a group's membership through the permission API instead.
|
|
247
|
+
*/
|
|
248
|
+
export interface AssetGroupGet {
|
|
249
|
+
name: string;
|
|
250
|
+
id: string;
|
|
251
|
+
title: string;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Response body for `GET /twins/groups`. */
|
|
255
|
+
export interface AssetGroupsGet {
|
|
256
|
+
groups: AssetGroupGet[];
|
|
20
257
|
}
|