@twinfinity/twin 0.0.0-feature.31596

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 (245) hide show
  1. package/README.md +277 -0
  2. package/dist/BuildInfo.d.ts +25 -0
  3. package/dist/BuildInfo.d.ts.map +1 -0
  4. package/dist/BuildInfo.js +15 -0
  5. package/dist/BuildInfo.js.map +1 -0
  6. package/dist/TwinClient.d.ts +823 -0
  7. package/dist/TwinClient.d.ts.map +1 -0
  8. package/dist/TwinClient.js +1487 -0
  9. package/dist/TwinClient.js.map +1 -0
  10. package/dist/errors.d.ts +289 -0
  11. package/dist/errors.d.ts.map +1 -0
  12. package/dist/errors.js +357 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/index.d.ts +4 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +4 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/tsconfig.tsbuildinfo +1 -0
  19. package/dist/types/Twin.d.ts +7 -0
  20. package/dist/types/Twin.d.ts.map +1 -0
  21. package/dist/types/Twin.js +6 -0
  22. package/dist/types/Twin.js.map +1 -0
  23. package/dist/types/TwinGeometryInfo.d.ts +7 -0
  24. package/dist/types/TwinGeometryInfo.d.ts.map +1 -0
  25. package/dist/types/TwinGeometryInfo.js +2 -0
  26. package/dist/types/TwinGeometryInfo.js.map +1 -0
  27. package/dist/types/asset-api.d.ts +66 -0
  28. package/dist/types/asset-api.d.ts.map +1 -0
  29. package/dist/types/asset-api.js +2 -0
  30. package/dist/types/asset-api.js.map +1 -0
  31. package/dist/types/asset-attachment-api.d.ts +51 -0
  32. package/dist/types/asset-attachment-api.d.ts.map +1 -0
  33. package/dist/types/asset-attachment-api.js +8 -0
  34. package/dist/types/asset-attachment-api.js.map +1 -0
  35. package/dist/types/asset-batch-api.d.ts +73 -0
  36. package/dist/types/asset-batch-api.d.ts.map +1 -0
  37. package/dist/types/asset-batch-api.js +2 -0
  38. package/dist/types/asset-batch-api.js.map +1 -0
  39. package/dist/types/asset-types-api.d.ts +76 -0
  40. package/dist/types/asset-types-api.d.ts.map +1 -0
  41. package/dist/types/asset-types-api.js +5 -0
  42. package/dist/types/asset-types-api.js.map +1 -0
  43. package/dist/types/common.d.ts +10 -0
  44. package/dist/types/common.d.ts.map +1 -0
  45. package/dist/types/common.js +2 -0
  46. package/dist/types/common.js.map +1 -0
  47. package/dist/types/generated.d.ts +458 -0
  48. package/dist/types/generated.d.ts.map +1 -0
  49. package/dist/types/generated.js +2 -0
  50. package/dist/types/generated.js.map +1 -0
  51. package/dist/types/index.d.ts +10 -0
  52. package/dist/types/index.d.ts.map +1 -0
  53. package/dist/types/index.js +10 -0
  54. package/dist/types/index.js.map +1 -0
  55. package/dist/types/twin-api.d.ts +141 -0
  56. package/dist/types/twin-api.d.ts.map +1 -0
  57. package/dist/types/twin-api.js +2 -0
  58. package/dist/types/twin-api.js.map +1 -0
  59. package/dist/types/twin-file-api.d.ts +61 -0
  60. package/dist/types/twin-file-api.d.ts.map +1 -0
  61. package/dist/types/twin-file-api.js +2 -0
  62. package/dist/types/twin-file-api.js.map +1 -0
  63. package/dist/types/twin-permissions-api.d.ts +240 -0
  64. package/dist/types/twin-permissions-api.d.ts.map +1 -0
  65. package/dist/types/twin-permissions-api.js +2 -0
  66. package/dist/types/twin-permissions-api.js.map +1 -0
  67. package/docs/.nojekyll +1 -0
  68. package/docs/assets/hierarchy.js +1 -0
  69. package/docs/assets/highlight.css +99 -0
  70. package/docs/assets/icons.js +18 -0
  71. package/docs/assets/icons.svg +1 -0
  72. package/docs/assets/main.js +60 -0
  73. package/docs/assets/navigation.js +1 -0
  74. package/docs/assets/search.js +1 -0
  75. package/docs/assets/style.css +1633 -0
  76. package/docs/classes/AssetAttachmentConflictError.html +3 -0
  77. package/docs/classes/AssetAttachmentNotFoundError.html +2 -0
  78. package/docs/classes/AssetBatchError.html +3 -0
  79. package/docs/classes/AssetCatalogTooLargeError.html +16 -0
  80. package/docs/classes/AssetCategoryConflictError.html +3 -0
  81. package/docs/classes/AssetCategoryForbiddenError.html +2 -0
  82. package/docs/classes/AssetCategoryNotFoundError.html +2 -0
  83. package/docs/classes/AssetCategoryValidationError.html +3 -0
  84. package/docs/classes/AssetConflictError.html +3 -0
  85. package/docs/classes/AssetForbiddenError.html +2 -0
  86. package/docs/classes/AssetNotFoundError.html +2 -0
  87. package/docs/classes/AssetPermissionsConflictError.html +16 -0
  88. package/docs/classes/AssetTypeConflictError.html +3 -0
  89. package/docs/classes/AssetTypeForbiddenError.html +2 -0
  90. package/docs/classes/AssetTypeNotFoundError.html +2 -0
  91. package/docs/classes/AssetTypeValidationError.html +3 -0
  92. package/docs/classes/AssetValidationError.html +3 -0
  93. package/docs/classes/ProcessorNotFoundError.html +2 -0
  94. package/docs/classes/TwinClient.html +409 -0
  95. package/docs/classes/TwinConflictError.html +3 -0
  96. package/docs/classes/TwinFileConflictError.html +3 -0
  97. package/docs/classes/TwinFileNotFoundError.html +2 -0
  98. package/docs/classes/TwinFileValidationError.html +3 -0
  99. package/docs/classes/TwinNotFoundError.html +4 -0
  100. package/docs/classes/TwinPermissionsConflictError.html +19 -0
  101. package/docs/classes/TwinPermissionsForbiddenError.html +12 -0
  102. package/docs/classes/TwinPrincipalNotFoundError.html +5 -0
  103. package/docs/classes/TwinTemporarilyUnavailableError.html +10 -0
  104. package/docs/classes/TwinUnauthenticatedError.html +6 -0
  105. package/docs/classes/TwinValidationError.html +3 -0
  106. package/docs/functions/isAssetCatalogTooLargeErrorBody.html +6 -0
  107. package/docs/functions/readErrorBody.html +10 -0
  108. package/docs/hierarchy.html +1 -0
  109. package/docs/index.html +168 -0
  110. package/docs/interfaces/ApiCreateUploadSessionResponse.html +7 -0
  111. package/docs/interfaces/AssetAttachmentPut.html +6 -0
  112. package/docs/interfaces/AssetBatchDeleteOperation.html +4 -0
  113. package/docs/interfaces/AssetBatchGetRequest.html +2 -0
  114. package/docs/interfaces/AssetBatchGetResponse.html +3 -0
  115. package/docs/interfaces/AssetBatchRequest.html +2 -0
  116. package/docs/interfaces/AssetBatchResponse.html +3 -0
  117. package/docs/interfaces/AssetBatchRestoreOperation.html +4 -0
  118. package/docs/interfaces/AssetBatchUpsertItem.html +12 -0
  119. package/docs/interfaces/AssetBatchUpsertOperation.html +4 -0
  120. package/docs/interfaces/AssetCatalogCategory.html +7 -0
  121. package/docs/interfaces/AssetCatalogResponse.html +6 -0
  122. package/docs/interfaces/AssetCatalogTooLargeErrorBody.html +15 -0
  123. package/docs/interfaces/AssetCategoryDelete.html +2 -0
  124. package/docs/interfaces/AssetCategoryGet.html +14 -0
  125. package/docs/interfaces/AssetCategoryPut.html +7 -0
  126. package/docs/interfaces/AssetGet.html +18 -0
  127. package/docs/interfaces/AssetGroupGet.html +9 -0
  128. package/docs/interfaces/AssetGroupsGet.html +3 -0
  129. package/docs/interfaces/AssetListItem.html +14 -0
  130. package/docs/interfaces/AssetPermissionsConflictErrorBody.html +12 -0
  131. package/docs/interfaces/AssetPermissionsPut.html +9 -0
  132. package/docs/interfaces/AssetPosition.html +4 -0
  133. package/docs/interfaces/AssetPost.html +12 -0
  134. package/docs/interfaces/AssetPrincipalPermissionsGet.html +23 -0
  135. package/docs/interfaces/AssetPut.html +12 -0
  136. package/docs/interfaces/AssetTypeDelete.html +2 -0
  137. package/docs/interfaces/AssetTypeGet.html +16 -0
  138. package/docs/interfaces/AssetTypePut.html +9 -0
  139. package/docs/interfaces/AttachmentGet.html +20 -0
  140. package/docs/interfaces/AttachmentPost.html +4 -0
  141. package/docs/interfaces/BatchItemError.html +4 -0
  142. package/docs/interfaces/BatchItemResult.html +6 -0
  143. package/docs/interfaces/BatchSummary.html +4 -0
  144. package/docs/interfaces/Coordinates.html +6 -0
  145. package/docs/interfaces/Diagnostics.html +4 -0
  146. package/docs/interfaces/DiagnosticsSummary.html +4 -0
  147. package/docs/interfaces/ElementQuantities.html +3 -0
  148. package/docs/interfaces/EntityCollection.html +15 -0
  149. package/docs/interfaces/EntityRepresentation.html +12 -0
  150. package/docs/interfaces/Facility.html +22 -0
  151. package/docs/interfaces/FacilityPart.html +18 -0
  152. package/docs/interfaces/FilePatch.html +7 -0
  153. package/docs/interfaces/FilePatchSet.html +5 -0
  154. package/docs/interfaces/GenericDiagnosticEntry.html +4 -0
  155. package/docs/interfaces/ITwinClient.html +404 -0
  156. package/docs/interfaces/IfcDiagnosticEntry.html +5 -0
  157. package/docs/interfaces/IfcDiagnosticNode.html +6 -0
  158. package/docs/interfaces/IfcDiagnosticNodeData.html +6 -0
  159. package/docs/interfaces/InheritedPermissions.html +8 -0
  160. package/docs/interfaces/ListTwinItem.html +30 -0
  161. package/docs/interfaces/Location.html +13 -0
  162. package/docs/interfaces/MyPermissions.html +7 -0
  163. package/docs/interfaces/MyTwinPermissions.html +5 -0
  164. package/docs/interfaces/PaginatedResponse.html +3 -0
  165. package/docs/interfaces/Pagination.html +4 -0
  166. package/docs/interfaces/Property.html +4 -0
  167. package/docs/interfaces/PropertySet.html +6 -0
  168. package/docs/interfaces/SimpleQuantity.html +6 -0
  169. package/docs/interfaces/SinglePropertyValue.html +5 -0
  170. package/docs/interfaces/Site.html +27 -0
  171. package/docs/interfaces/Space.html +16 -0
  172. package/docs/interfaces/TwinComputedPropertySetsResponse.html +4 -0
  173. package/docs/interfaces/TwinContentResponse.html +6 -0
  174. package/docs/interfaces/TwinDelete.html +2 -0
  175. package/docs/interfaces/TwinDiagnosticEntry.html +5 -0
  176. package/docs/interfaces/TwinDiagnosticNode.html +4 -0
  177. package/docs/interfaces/TwinDiagnosticNodeData.html +9 -0
  178. package/docs/interfaces/TwinDiagnosticsResponse.html +5 -0
  179. package/docs/interfaces/TwinErrorBody.html +4 -0
  180. package/docs/interfaces/TwinFileDelete.html +2 -0
  181. package/docs/interfaces/TwinFileGet.html +15 -0
  182. package/docs/interfaces/TwinFileListOptions.html +6 -0
  183. package/docs/interfaces/TwinFilePut.html +8 -0
  184. package/docs/interfaces/TwinFileReference.html +4 -0
  185. package/docs/interfaces/TwinFileRestore.html +2 -0
  186. package/docs/interfaces/TwinFileSource.html +4 -0
  187. package/docs/interfaces/TwinFileTransform.html +11 -0
  188. package/docs/interfaces/TwinFileVersionListOptions.html +4 -0
  189. package/docs/interfaces/TwinGet.html +48 -0
  190. package/docs/interfaces/TwinGroupGet.html +10 -0
  191. package/docs/interfaces/TwinGroupsGet.html +3 -0
  192. package/docs/interfaces/TwinPermissionsConflictErrorBody.html +8 -0
  193. package/docs/interfaces/TwinPermissionsPut.html +11 -0
  194. package/docs/interfaces/TwinPrincipalPermissionsGet.html +34 -0
  195. package/docs/interfaces/TwinProcessorEvent.html +7 -0
  196. package/docs/interfaces/TwinProcessorResponse.html +5 -0
  197. package/docs/interfaces/TwinPut.html +21 -0
  198. package/docs/interfaces/TwinReference.html +4 -0
  199. package/docs/interfaces/TwinSpecification.html +18 -0
  200. package/docs/interfaces/TwinVersionContentResponse.html +7 -0
  201. package/docs/interfaces/UploadStatusGet.html +3 -0
  202. package/docs/media/twin-management.md +399 -0
  203. package/docs/modules.html +1 -0
  204. package/docs/types/AssetBatchGetStatus.html +1 -0
  205. package/docs/types/AssetBatchOperation.html +1 -0
  206. package/docs/types/AssetBatchOperationStatus.html +1 -0
  207. package/docs/types/DiagnosticCategory.html +2 -0
  208. package/docs/types/DiagnosticLevel.html +2 -0
  209. package/docs/types/EpsgType.html +1 -0
  210. package/docs/types/FacilityClass.html +3 -0
  211. package/docs/types/FacilityPartClass.html +3 -0
  212. package/docs/types/IfcDiagnosticCode.html +1 -0
  213. package/docs/types/Op.html +2 -0
  214. package/docs/types/SinglePropertyValueType.html +3 -0
  215. package/docs/types/SingleQuantityValueType.html +3 -0
  216. package/docs/types/SiteType.html +3 -0
  217. package/docs/types/SpaceType.html +2 -0
  218. package/docs/types/TwinBoundCapabilityName.html +8 -0
  219. package/docs/types/TwinCapability.html +12 -0
  220. package/docs/types/TwinCapabilityName.html +8 -0
  221. package/docs/types/TwinDiagnosticCode.html +1 -0
  222. package/docs/types/TwinErrorCause.html +8 -0
  223. package/docs/types/TwinErrorItemKind.html +4 -0
  224. package/docs/types/TwinPermissionsConflictCause.html +6 -0
  225. package/docs/types/TwinScopedCapability.html +9 -0
  226. package/docs/types/TwinScopedCapabilityName.html +8 -0
  227. package/docs/types/UploadStatus.html +1 -0
  228. package/package.json +52 -0
  229. package/src/BuildInfo.ts +41 -0
  230. package/src/TwinClient.ts +3113 -0
  231. package/src/errors.ts +567 -0
  232. package/src/index.ts +3 -0
  233. package/src/tsconfig.json +13 -0
  234. package/src/types/Twin.ts +7 -0
  235. package/src/types/TwinGeometryInfo.ts +7 -0
  236. package/src/types/asset-api.ts +69 -0
  237. package/src/types/asset-attachment-api.ts +56 -0
  238. package/src/types/asset-batch-api.ts +90 -0
  239. package/src/types/asset-types-api.ts +86 -0
  240. package/src/types/common.ts +10 -0
  241. package/src/types/generated.ts +655 -0
  242. package/src/types/index.ts +9 -0
  243. package/src/types/twin-api.ts +153 -0
  244. package/src/types/twin-file-api.ts +67 -0
  245. package/src/types/twin-permissions-api.ts +257 -0
@@ -0,0 +1,153 @@
1
+ import type { PropertySet, ElementQuantities, TwinSpecification, Diagnostics, EpsgType, Location } from './generated';
2
+ import type { TwinBoundCapabilityName } from './twin-permissions-api';
3
+
4
+ export interface TwinFileReference {
5
+ fileId: string;
6
+ fileVersion: number;
7
+ twinNodeId?: string;
8
+ }
9
+
10
+ /** WGS84 coordinates of a twin, as returned on the list endpoint (coordinates only — the full
11
+ * Location, including elevation and trueNorth, is available on the single-twin GET). */
12
+ export interface Coordinates {
13
+ epsg: EpsgType;
14
+ latitude: number;
15
+ longitude: number;
16
+ }
17
+
18
+ export interface ListTwinItem {
19
+ id: string;
20
+ name: string;
21
+ etag: string;
22
+ propertySets?: PropertySet[];
23
+ computedPropertySets?: PropertySet[];
24
+ elementQuantities?: ElementQuantities[];
25
+ relatedContainerIds: string[];
26
+ version: number;
27
+ isDeleted?: boolean;
28
+ createdBy: string;
29
+ createdUtc: string;
30
+ modifiedBy: string;
31
+ modifiedUtc: string;
32
+ /** Ids of the Twins nested within this Twin, derived by the service from its twin references. */
33
+ aggregatedTwins: string[];
34
+ /** Deduplicated, sorted set of IFC entity classes the twin contains (e.g. IfcBuilding, IfcSpace),
35
+ * computed by the service from the specification's entity collection. */
36
+ classes: string[];
37
+ /** Id of the Twin that references this Twin (its parent), or omitted for a root Twin. */
38
+ parentTwin?: string;
39
+ /** WGS84 coordinates, present only when the twin's specification declares a location. */
40
+ location?: Coordinates;
41
+ /**
42
+ * What the *calling principal* may do with this twin — the whole affordance decision for the
43
+ * row, so a list of a thousand twins needs no probe per row. Never the twin's access-control
44
+ * list: that is `listTwinPermissions(twinId)`, which is administration-gated.
45
+ *
46
+ * Mixes both capability vocabularies, as the twin-scoped probe does. Where each capability was
47
+ * granted is answered by `listTwinPermissions(twinId)`, whose rows split `permissions` from
48
+ * `inheritedPermissions`. Absent on `listTwinVersions`, which does not resolve it.
49
+ */
50
+ effectivePermissions?: TwinBoundCapabilityName[];
51
+ }
52
+
53
+ /**
54
+ * A twin as returned by the service — by `getTwin` and `getTwinVersion`, and by the write methods
55
+ * (`createOrUpdateTwin`, `deleteTwin`, `restoreTwin`), which answer with the same shape. Writing a
56
+ * twin and re-rendering it therefore needs no second fetch.
57
+ */
58
+ export interface TwinGet extends TwinSpecification {
59
+ id: string;
60
+ etag: string;
61
+ relatedContainerIds: string[];
62
+ version: number;
63
+ isDeleted?: boolean;
64
+ createdBy: string;
65
+ createdUtc: string;
66
+ modifiedBy: string;
67
+ modifiedUtc: string;
68
+ fileReferences: TwinFileReference[];
69
+ computedPropertySets?: PropertySet[];
70
+ /** Ids of the Twins nested within this Twin, derived by the service from its twin references. */
71
+ aggregatedTwins: string[];
72
+ /** Id of the Twin that references this Twin (its parent), or omitted for a root Twin. */
73
+ parentTwin?: string;
74
+ /** Name of the Twin, derived by the service from the root entity. Read-only; not part of the
75
+ * stored specification. */
76
+ name: string;
77
+ /** Full WGS84 location of the Twin (including elevation and trueNorth), derived by the service
78
+ * from the root entity. Read-only; not part of the stored specification. */
79
+ location?: Location;
80
+ /**
81
+ * Everything the *calling principal* may do with this twin: the capabilities its own scopes
82
+ * confer, unioned with the twin-bound asset ones held customer-wide. Calculated by the service on
83
+ * every read, never stored, and never accepted in a `TwinPut` body.
84
+ *
85
+ * The verdict, without its provenance — a fetched twin says no more than a listing row does.
86
+ * Which capabilities are granted here and which come from elsewhere is answered by
87
+ * `listTwinPermissions(twinId)`, where they are administered. Never the twin's access-control
88
+ * list either: this describes the caller, not every principal.
89
+ */
90
+ effectivePermissions: TwinBoundCapabilityName[];
91
+ }
92
+
93
+ export interface TwinPut extends TwinSpecification {
94
+ etag?: string;
95
+ relatedContainerIds: string[];
96
+ fileReferences?: TwinFileReference[];
97
+ }
98
+
99
+ export interface TwinDelete {
100
+ etag: string;
101
+ }
102
+
103
+ export interface TwinVersionContentResponse {
104
+ twinId: string;
105
+ twinVersion: number;
106
+ status: string;
107
+ processors: TwinProcessorResponse[];
108
+ content: TwinContentResponse[];
109
+ computedPropertySets: TwinComputedPropertySetsResponse[];
110
+ }
111
+
112
+ export interface TwinProcessorResponse {
113
+ processorId: string;
114
+ processorName: string;
115
+ processorDescription?: string;
116
+ status: string;
117
+ }
118
+
119
+ export interface TwinContentResponse {
120
+ id: string;
121
+ processorId: string;
122
+ format: string;
123
+ description?: string;
124
+ receivedAt: string;
125
+ }
126
+
127
+ export interface TwinComputedPropertySetsResponse {
128
+ processorId: string;
129
+ propertySets: PropertySet[];
130
+ receivedAt: string;
131
+ }
132
+
133
+ export interface TwinProcessorEvent {
134
+ id: string;
135
+ processorId: string;
136
+ eventType: string;
137
+ eventTimestampUtc: string;
138
+ details?: unknown;
139
+ message?: string;
140
+ }
141
+
142
+ export interface DiagnosticsSummary {
143
+ fatalCount: number;
144
+ errorCount: number;
145
+ warningCount: number;
146
+ }
147
+
148
+ export interface TwinDiagnosticsResponse {
149
+ twinId: string;
150
+ twinVersion: number;
151
+ summary: DiagnosticsSummary;
152
+ diagnostics: Diagnostics;
153
+ }
@@ -0,0 +1,67 @@
1
+ export interface TwinFileTransform {
2
+ qx?: number;
3
+ qy?: number;
4
+ qz?: number;
5
+ qw?: number;
6
+ sx?: number;
7
+ sy?: number;
8
+ sz?: number;
9
+ x?: number;
10
+ y?: number;
11
+ z?: number;
12
+ }
13
+
14
+ export interface TwinFileGet {
15
+ id: string;
16
+ twinId: string;
17
+ version: number;
18
+ source: TwinFileSource;
19
+ name: string;
20
+ comment?: string;
21
+ quality: number;
22
+ etag: string;
23
+ isDeleted: boolean;
24
+ createdBy: string;
25
+ createdUtc: string;
26
+ modifiedBy: string;
27
+ modifiedUtc: string;
28
+ transform?: TwinFileTransform;
29
+ }
30
+
31
+ export interface TwinFileSource {
32
+ changeId: string;
33
+ changeVersion: number;
34
+ sourceType: string;
35
+ }
36
+
37
+ export interface TwinFilePut {
38
+ source: TwinFileSource;
39
+ name: string;
40
+ comment?: string;
41
+ quality: number | null;
42
+ etag?: string;
43
+ isDeleted?: boolean;
44
+ transform?: TwinFileTransform;
45
+ }
46
+
47
+ export interface TwinFileDelete {
48
+ etag: string;
49
+ }
50
+
51
+ export interface TwinFileRestore {
52
+ etag: string;
53
+ }
54
+
55
+ export interface TwinFileListOptions {
56
+ includeDeleted?: boolean;
57
+ checkedIn?: boolean;
58
+ version?: number;
59
+ page?: string;
60
+ limit?: number;
61
+ }
62
+
63
+ export interface TwinFileVersionListOptions {
64
+ includeDeleted?: boolean;
65
+ offset?: number;
66
+ limit?: number;
67
+ }
@@ -0,0 +1,257 @@
1
+ /**
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.
15
+ */
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 & {});
30
+
31
+ /**
32
+ * Response body for `GET /twins/permissions/me`. The `permissions` array
33
+ * lists only capabilities the caller actually holds; absence means "not
34
+ * granted." Use `permissions.includes('EditAssetTypes')` etc. for gating.
35
+ *
36
+ * Wrapped under a key (rather than a bare array) so future fields — an
37
+ * etag, an identity echo, expiry — can be added without a shape break.
38
+ */
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
+ */
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[];
257
+ }