@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
package/dist/errors.js ADDED
@@ -0,0 +1,357 @@
1
+ /**
2
+ * Parse a non-OK response body as a {@link TwinErrorBody}. Falls back to a
3
+ * synthetic body carrying the response text (or statusText) when the body
4
+ * isn't valid JSON — for example when a WAF or intermediate proxy injects
5
+ * an HTML 4xx page. Callers can therefore always pattern-match on
6
+ * `errorBody.cause` without an outer try/catch around a bare
7
+ * `response.json()`.
8
+ *
9
+ * The synthetic body uses `cause: 'Unknown'`, which is permitted by the
10
+ * `(string & {})` forward-compat tail on {@link TwinErrorCause}. Consumers
11
+ * that switch on known causes will fall through to a default arm.
12
+ */
13
+ export async function readErrorBody(response) {
14
+ // Parse a clone, so that a body which turns out not to be JSON can still be read as text below.
15
+ // `json()` consumes the stream: on a real Response, reading the original here would leave the
16
+ // fallback unreachable and every non-JSON diagnostic would degrade to `statusText`.
17
+ const parseFrom = typeof response.clone === 'function' ? response.clone() : response;
18
+ try {
19
+ const parsed = (await parseFrom.json());
20
+ // Defensive shape check — JSON-but-not-our-shape (e.g. an upstream
21
+ // ProblemDetails payload from a non-Twinfinity component) should still
22
+ // surface usefully. `detail` is the only field every consumer reads.
23
+ if (parsed && typeof parsed.detail === 'string')
24
+ return parsed;
25
+ return { detail: JSON.stringify(parsed), cause: 'Unknown' };
26
+ }
27
+ catch {
28
+ const text = await response.text().catch(() => '');
29
+ return { detail: text || response.statusText || `HTTP ${response.status}`, cause: 'Unknown' };
30
+ }
31
+ }
32
+ export class TwinValidationError extends Error {
33
+ errorBody;
34
+ constructor(message, errorBody) {
35
+ super(message);
36
+ this.name = 'TwinValidationError';
37
+ this.errorBody = errorBody;
38
+ }
39
+ }
40
+ export class TwinConflictError extends Error {
41
+ currentTwin;
42
+ constructor(message, currentTwin) {
43
+ super(message);
44
+ this.name = 'TwinConflictError';
45
+ this.currentTwin = currentTwin;
46
+ }
47
+ }
48
+ export class TwinNotFoundError extends Error {
49
+ /** The server's envelope, when there was one — `item.kind` names what was not found. */
50
+ errorBody;
51
+ constructor(message, errorBody) {
52
+ super(message);
53
+ this.name = 'TwinNotFoundError';
54
+ this.errorBody = errorBody;
55
+ }
56
+ }
57
+ export class ProcessorNotFoundError extends Error {
58
+ constructor(message) {
59
+ super(message);
60
+ this.name = 'ProcessorNotFoundError';
61
+ }
62
+ }
63
+ export class AssetValidationError extends Error {
64
+ errorBody;
65
+ constructor(message, errorBody) {
66
+ super(message);
67
+ this.name = 'AssetValidationError';
68
+ this.errorBody = errorBody;
69
+ }
70
+ }
71
+ export class AssetForbiddenError extends Error {
72
+ constructor(message) {
73
+ super(message);
74
+ this.name = 'AssetForbiddenError';
75
+ }
76
+ }
77
+ export class AssetConflictError extends Error {
78
+ currentAsset;
79
+ constructor(message, currentAsset) {
80
+ super(message);
81
+ this.name = 'AssetConflictError';
82
+ this.currentAsset = currentAsset;
83
+ }
84
+ }
85
+ export class AssetNotFoundError extends Error {
86
+ constructor(message) {
87
+ super(message);
88
+ this.name = 'AssetNotFoundError';
89
+ }
90
+ }
91
+ export class AssetAttachmentConflictError extends Error {
92
+ currentAttachment;
93
+ constructor(message, currentAttachment) {
94
+ super(message);
95
+ this.name = 'AssetAttachmentConflictError';
96
+ this.currentAttachment = currentAttachment;
97
+ }
98
+ }
99
+ export class AssetAttachmentNotFoundError extends Error {
100
+ constructor(message) {
101
+ super(message);
102
+ this.name = 'AssetAttachmentNotFoundError';
103
+ }
104
+ }
105
+ export class AssetBatchError extends Error {
106
+ response;
107
+ constructor(message, response) {
108
+ super(message);
109
+ this.name = 'AssetBatchError';
110
+ this.response = response;
111
+ }
112
+ }
113
+ export class TwinFileValidationError extends Error {
114
+ errorBody;
115
+ constructor(message, errorBody) {
116
+ super(message);
117
+ this.name = 'TwinFileValidationError';
118
+ this.errorBody = errorBody;
119
+ }
120
+ }
121
+ export class TwinFileConflictError extends Error {
122
+ currentTwinFile;
123
+ constructor(message, currentTwinFile) {
124
+ super(message);
125
+ this.name = 'TwinFileConflictError';
126
+ this.currentTwinFile = currentTwinFile;
127
+ }
128
+ }
129
+ export class TwinFileNotFoundError extends Error {
130
+ constructor(message) {
131
+ super(message);
132
+ this.name = 'TwinFileNotFoundError';
133
+ }
134
+ }
135
+ // ---------- Asset categories ----------
136
+ export class AssetCategoryValidationError extends Error {
137
+ errorBody;
138
+ constructor(message, errorBody) {
139
+ super(message);
140
+ this.name = 'AssetCategoryValidationError';
141
+ this.errorBody = errorBody;
142
+ }
143
+ }
144
+ export class AssetCategoryConflictError extends Error {
145
+ currentCategory;
146
+ constructor(message, currentCategory) {
147
+ super(message);
148
+ this.name = 'AssetCategoryConflictError';
149
+ this.currentCategory = currentCategory;
150
+ }
151
+ }
152
+ export class AssetCategoryNotFoundError extends Error {
153
+ constructor(message) {
154
+ super(message);
155
+ this.name = 'AssetCategoryNotFoundError';
156
+ }
157
+ }
158
+ export class AssetCategoryForbiddenError extends Error {
159
+ constructor(message) {
160
+ super(message);
161
+ this.name = 'AssetCategoryForbiddenError';
162
+ }
163
+ }
164
+ // ---------- Asset types ----------
165
+ export class AssetTypeValidationError extends Error {
166
+ errorBody;
167
+ constructor(message, errorBody) {
168
+ super(message);
169
+ this.name = 'AssetTypeValidationError';
170
+ this.errorBody = errorBody;
171
+ }
172
+ }
173
+ export class AssetTypeConflictError extends Error {
174
+ currentType;
175
+ constructor(message, currentType) {
176
+ super(message);
177
+ this.name = 'AssetTypeConflictError';
178
+ this.currentType = currentType;
179
+ }
180
+ }
181
+ export class AssetTypeNotFoundError extends Error {
182
+ constructor(message) {
183
+ super(message);
184
+ this.name = 'AssetTypeNotFoundError';
185
+ }
186
+ }
187
+ export class AssetTypeForbiddenError extends Error {
188
+ constructor(message) {
189
+ super(message);
190
+ this.name = 'AssetTypeForbiddenError';
191
+ }
192
+ }
193
+ /**
194
+ * Thrown by `getAssetTypeCatalog` when the customer's catalog exceeds the
195
+ * per-customer cap. The catalog endpoint is a single-round-trip view; tenants
196
+ * over the cap must switch to a paginated endpoint (not yet shipped). Surfaced
197
+ * as a hard failure rather than silent truncation so picker UIs can render
198
+ * "too many rows, use search" instead of "out of types."
199
+ *
200
+ * `categoriesOverflowed` / `typesOverflowed` identify which side(s) breached
201
+ * the cap; both can be true. `categoriesCount` / `typesCount` are the observed
202
+ * counts (≥ `maxCatalogSize` for the overflowing side(s)).
203
+ */
204
+ export class AssetCatalogTooLargeError extends Error {
205
+ errorBody;
206
+ categoriesCount;
207
+ typesCount;
208
+ maxCatalogSize;
209
+ categoriesOverflowed;
210
+ typesOverflowed;
211
+ constructor(message, errorBody) {
212
+ super(message);
213
+ this.name = 'AssetCatalogTooLargeError';
214
+ this.errorBody = errorBody;
215
+ this.categoriesCount = errorBody.categoriesCount;
216
+ this.typesCount = errorBody.typesCount;
217
+ this.maxCatalogSize = errorBody.maxCatalogSize;
218
+ this.categoriesOverflowed = errorBody.categoriesOverflowed;
219
+ this.typesOverflowed = errorBody.typesOverflowed;
220
+ }
221
+ }
222
+ /**
223
+ * Type guard for a {@link TwinErrorBody} that carries `CatalogTooLarge`
224
+ * with the structured count fields the dedicated wire shape adds on top of
225
+ * the standard envelope. Used by the client to decide whether to throw a
226
+ * typed {@link AssetCatalogTooLargeError} or fall through to a generic
227
+ * validation error when the server sends a malformed payload.
228
+ */
229
+ export function isAssetCatalogTooLargeErrorBody(body) {
230
+ return (body.cause === 'CatalogTooLarge' &&
231
+ typeof body.categoriesCount === 'number' &&
232
+ typeof body.typesCount === 'number' &&
233
+ typeof body.maxCatalogSize === 'number' &&
234
+ typeof body.categoriesOverflowed === 'boolean' &&
235
+ typeof body.typesOverflowed === 'boolean');
236
+ }
237
+ // ---------- Authentication ----------
238
+ /**
239
+ * Thrown when the server returns 401 (Unauthorized). Distinct from forbidden
240
+ * errors: 401 means "no valid auth context" (the caller should redirect to
241
+ * login / refresh tokens), while 403 means "authenticated but not granted"
242
+ * (the UI should surface a permissions hint or render disabled affordances).
243
+ */
244
+ export class TwinUnauthenticatedError extends Error {
245
+ constructor(message) {
246
+ super(message);
247
+ this.name = 'TwinUnauthenticatedError';
248
+ }
249
+ }
250
+ /**
251
+ * Thrown by the twin permission mutation and listing methods on a 409.
252
+ *
253
+ * The three causes need different handling, which is why they are distinguishable
254
+ * rather than collapsed into one "modified by another user":
255
+ * - `EtagMismatch` — the etag is stale; re-read (or use {@link currentState}) and retry.
256
+ * - `EtagRequired` — the write omitted an etag but the principal already held an entry,
257
+ * so it would have replaced state the caller never read. Retried by reading at all.
258
+ * - `ScopesNotProvisioned` — the twin owns no Twinfinity scope, so there is no permission
259
+ * state to read or write. Nothing provisions on read, so retrying will not help.
260
+ */
261
+ export class TwinPermissionsConflictError extends Error {
262
+ /**
263
+ * Which of the three conflicts this is. Named `conflictCause` rather than `cause` so the
264
+ * standard `Error.cause` — whose consumers expect a wrapped error, not a string — is left
265
+ * alone; the same value is on {@link errorBody}`.cause`.
266
+ */
267
+ conflictCause;
268
+ /** The entry as the server holds it, including the etag to retry with. */
269
+ currentState;
270
+ errorBody;
271
+ constructor(message, errorBody) {
272
+ super(message);
273
+ this.name = 'TwinPermissionsConflictError';
274
+ this.conflictCause = errorBody.cause;
275
+ this.currentState = errorBody.currentState;
276
+ this.errorBody = errorBody;
277
+ }
278
+ }
279
+ /**
280
+ * Thrown on a 403 from the twin-scoped permission surface: the caller can see the twin
281
+ * but does not hold `ManageTwinPermissions` on it. Distinct from
282
+ * {@link TwinNotFoundError}, which is what a twin the caller cannot see at all answers —
283
+ * the surface refuses to confirm such a twin exists.
284
+ */
285
+ export class TwinPermissionsForbiddenError extends Error {
286
+ /**
287
+ * The server's envelope, when there was one. Its presence is load-bearing: a genuine refusal
288
+ * carries `cause: 'InsufficientPermissions'`, while a Twin service that could not evaluate the
289
+ * request at all (a customer-database lookup that threw, a missing twin feature) falls through
290
+ * to the framework's default forbid handler and answers a 403 with no body. Without this a
291
+ * caller cannot tell "you may not" from "we could not tell", and would report the first.
292
+ */
293
+ errorBody;
294
+ constructor(message, errorBody) {
295
+ super(message);
296
+ this.name = 'TwinPermissionsForbiddenError';
297
+ this.errorBody = errorBody;
298
+ }
299
+ }
300
+ /**
301
+ * Thrown when a 404 names the principal rather than the twin — an id that no principal
302
+ * in the tenant carries, or one holding nothing on the twin for a `DELETE` to revoke.
303
+ */
304
+ export class TwinPrincipalNotFoundError extends Error {
305
+ errorBody;
306
+ constructor(message, errorBody) {
307
+ super(message);
308
+ this.name = 'TwinPrincipalNotFoundError';
309
+ this.errorBody = errorBody;
310
+ }
311
+ }
312
+ /**
313
+ * Thrown on a 503: the Twin service could neither carry out the request nor answer it
314
+ * truthfully. The request is unchanged and safe to retry as-is — unlike
315
+ * {@link TwinPermissionsConflictError}, which never clears on its own.
316
+ */
317
+ export class TwinTemporarilyUnavailableError extends Error {
318
+ errorBody;
319
+ /**
320
+ * The `Retry-After` the service sent, in seconds, when it sent one. The Twin service pairs the
321
+ * status with this header deliberately, so that "retrying is worthwhile" does not rest on the
322
+ * status alone — pass it to whatever backoff the caller uses instead of inventing a delay.
323
+ */
324
+ retryAfterSeconds;
325
+ constructor(message, errorBody, retryAfterSeconds) {
326
+ super(message);
327
+ this.name = 'TwinTemporarilyUnavailableError';
328
+ this.errorBody = errorBody;
329
+ this.retryAfterSeconds = retryAfterSeconds;
330
+ }
331
+ }
332
+ /**
333
+ * Thrown by the asset permission mutation methods on a 409, which on this surface is always an
334
+ * etag failure:
335
+ * - `EtagMismatch` — the etag is stale; re-read (or use {@link currentState}) and retry. Expect
336
+ * this routinely: the scope's etag is customer-wide, so any administrator's write invalidates it.
337
+ * - `EtagRequired` — the write omitted an etag but the principal already held capabilities, so it
338
+ * would have replaced state the caller never read.
339
+ */
340
+ export class AssetPermissionsConflictError extends Error {
341
+ /**
342
+ * Which of the two conflicts this is. Named `conflictCause` rather than `cause` so the standard
343
+ * `Error.cause` — whose consumers expect a wrapped error, not a string — is left alone.
344
+ */
345
+ conflictCause;
346
+ /** The entry as the server holds it, including the etag to retry with. */
347
+ currentState;
348
+ errorBody;
349
+ constructor(message, errorBody) {
350
+ super(message);
351
+ this.name = 'AssetPermissionsConflictError';
352
+ this.conflictCause = errorBody.cause;
353
+ this.currentState = errorBody.currentState;
354
+ this.errorBody = errorBody;
355
+ }
356
+ }
357
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAgGA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAkB;IAClD,gGAAgG;IAChG,8FAA8F;IAC9F,oFAAoF;IACpF,MAAM,SAAS,GAAG,OAAO,QAAQ,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;IACrF,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,CAAC,MAAM,SAAS,CAAC,IAAI,EAAE,CAAkB,CAAC;QACzD,mEAAmE;QACnE,uEAAuE;QACvE,qE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,CAAC;IAC/C,CAAC;CACJ;AAmBD;;;;;;;GAOG;AACH,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACpD;;;OAGG;IACa,aAAa,CAA+B;IAC5D,0EAA0E;IAC1D,YAAY,CAAgC;IAC5C,SAAS,CAAoC;IAE7D,YAAY,OAAe,EAAE,SAA4C;QACrE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;QAC5C,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC,KAAK,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;CACJ"}
@@ -0,0 +1,4 @@
1
+ export { type ITwinClient, TwinClient } from './TwinClient';
2
+ export * from './types';
3
+ export * from './errors';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { TwinClient } from './TwinClient';
2
+ export * from './types';
3
+ export * from './errors';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}