@timbereye/sdk 0.0.0-stage → 0.1.0

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 (53) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/LICENSE +202 -0
  3. package/README.md +330 -2
  4. package/dist/cjs/case.d.ts +23 -0
  5. package/dist/cjs/case.js +46 -0
  6. package/dist/cjs/client.d.ts +89 -0
  7. package/dist/cjs/client.js +122 -0
  8. package/dist/cjs/errors.d.ts +63 -0
  9. package/dist/cjs/errors.js +107 -0
  10. package/dist/cjs/generated/schema.d.ts +13436 -0
  11. package/dist/cjs/generated/schema.js +6 -0
  12. package/dist/cjs/http.d.ts +92 -0
  13. package/dist/cjs/http.js +238 -0
  14. package/dist/cjs/index.d.ts +14 -0
  15. package/dist/cjs/index.js +28 -0
  16. package/dist/cjs/package.json +1 -0
  17. package/dist/cjs/pagination.d.ts +31 -0
  18. package/dist/cjs/pagination.js +52 -0
  19. package/dist/cjs/resources.d.ts +7879 -0
  20. package/dist/cjs/resources.js +456 -0
  21. package/dist/cjs/runtime.d.ts +20 -0
  22. package/dist/cjs/runtime.js +74 -0
  23. package/dist/cjs/types.d.ts +525 -0
  24. package/dist/cjs/types.js +2 -0
  25. package/dist/cjs/units.d.ts +26 -0
  26. package/dist/cjs/units.js +45 -0
  27. package/dist/cjs/webhooks.d.ts +44 -0
  28. package/dist/cjs/webhooks.js +149 -0
  29. package/dist/esm/case.d.ts +23 -0
  30. package/dist/esm/case.js +39 -0
  31. package/dist/esm/client.d.ts +89 -0
  32. package/dist/esm/client.js +118 -0
  33. package/dist/esm/errors.d.ts +63 -0
  34. package/dist/esm/errors.js +93 -0
  35. package/dist/esm/generated/schema.d.ts +13436 -0
  36. package/dist/esm/generated/schema.js +5 -0
  37. package/dist/esm/http.d.ts +92 -0
  38. package/dist/esm/http.js +232 -0
  39. package/dist/esm/index.d.ts +14 -0
  40. package/dist/esm/index.js +6 -0
  41. package/dist/esm/pagination.d.ts +31 -0
  42. package/dist/esm/pagination.js +49 -0
  43. package/dist/esm/resources.d.ts +7879 -0
  44. package/dist/esm/resources.js +453 -0
  45. package/dist/esm/runtime.d.ts +20 -0
  46. package/dist/esm/runtime.js +46 -0
  47. package/dist/esm/types.d.ts +525 -0
  48. package/dist/esm/types.js +1 -0
  49. package/dist/esm/units.d.ts +26 -0
  50. package/dist/esm/units.js +38 -0
  51. package/dist/esm/webhooks.d.ts +44 -0
  52. package/dist/esm/webhooks.js +145 -0
  53. package/package.json +51 -5
@@ -0,0 +1,525 @@
1
+ import type { Camel } from "./case.js";
2
+ import type { components, operations } from "./generated/schema.js";
3
+ type S = components["schemas"];
4
+ /** Every schema of the API, camelCased. Generated mechanically from the OpenAPI types. */
5
+ export type Schemas = {
6
+ [K in keyof S]: Camel<S[K]>;
7
+ };
8
+ /**
9
+ * A group. Lumber and panel groups (in development) also carry `spec`, `bundle`, `rule`, `expected`,
10
+ * `totalsConvention`, `photos` and `images`, and `summary.pieces` and `summary.tally`.
11
+ */
12
+ export type Group = Omit<Schemas["Group"], "spec" | "bundle" | "rule" | "expected" | "summary" | "parent"> & {
13
+ summary: Omit<Schemas["Group"]["summary"], "tally"> & {
14
+ tally?: LumberTotals | null;
15
+ };
16
+ /** The parent group, present only with `expand[]=parent`. */
17
+ parent?: Group | null;
18
+ spec?: Record<string, unknown> | null;
19
+ bundle?: Record<string, unknown> | null;
20
+ rule?: TallyRuleApplied | null;
21
+ expected?: LumberExpected | null;
22
+ photos?: PhotosStatus;
23
+ images?: Record<string, unknown>[];
24
+ };
25
+ export type Item = Schemas["Item"];
26
+ export type Scan = Schemas["Scan"];
27
+ export type Measurement = Schemas["Measurement"];
28
+ export type Image = Schemas["Image"];
29
+ export type GroupImage = Schemas["GroupImage"];
30
+ export type ItemImage = Schemas["ItemImage"];
31
+ export type UploadSession = Schemas["UploadSession"];
32
+ export type Place = Schemas["Place"];
33
+ export type PlaceValidation = Schemas["PlaceValidation"];
34
+ export type Species = Schemas["Species"];
35
+ export type Volume = Schemas["Volume"];
36
+ export type VolumeRule = Schemas["VolumeRule"];
37
+ export type Origin = Schemas["Origin"];
38
+ export type Event = Schemas["Event"];
39
+ export type EventType = Schemas["EventType"];
40
+ export type WebhookEndpoint = Schemas["WebhookEndpoint"];
41
+ export type WebhookEndpointDeleted = Schemas["WebhookEndpointDeleted"];
42
+ export type GroupDeleted = Schemas["GroupDeleted"];
43
+ export type PlaceDeleted = Schemas["PlaceDeleted"];
44
+ export type CaptureToken = Schemas["CaptureToken"];
45
+ export type ApiKey = Schemas["ApiKey"];
46
+ /**
47
+ * Metered usage. Lumber and panels (in development): `lumber` and `panels` hold the period's figures; only `m3` is
48
+ * billed (at the one price per m³), the rest are counts for display.
49
+ */
50
+ export type Usage = Omit<Schemas["Usage"], "lumber" | "panels"> & {
51
+ lumber?: {
52
+ m3: number;
53
+ boardFeet: number;
54
+ pieces: number;
55
+ photos: number;
56
+ };
57
+ panels?: {
58
+ m3: number;
59
+ m2: number;
60
+ pieces: number;
61
+ photos: number;
62
+ };
63
+ };
64
+ export type UsageRecord = Schemas["UsageRecord"];
65
+ export type DetectorModel = Schemas["DetectorModel"];
66
+ export type BulkUpdateResult = Schemas["BulkUpdateResult"];
67
+ export type GroupMembership = Schemas["GroupMembership"];
68
+ export type TeamMember = Schemas["TeamMember"];
69
+ export type TeamMemberDeleted = Schemas["TeamMemberDeleted"];
70
+ export type TeamRole = Schemas["TeamMember"]["role"];
71
+ export type Invitation = Schemas["Invitation"];
72
+ export type InvitationStatus = S["InvitationStatus"];
73
+ export type InvitationAcceptance = Schemas["InvitationAcceptance"];
74
+ export type TeamScanner = Schemas["TeamScanner"];
75
+ export type DeviceSignIn = Schemas["DeviceSignIn"];
76
+ export type AuditLogEntry = Schemas["AuditLogEntry"];
77
+ export type LengthUnit = S["LengthUnit"];
78
+ export type WeightUnit = S["WeightUnit"];
79
+ /** The union of events a webhook delivers or `events` lists; narrow on `type`. */
80
+ export type WebhookEvent = Event;
81
+ export type ItemLengthInput = Schemas["ItemLengthInput"];
82
+ export type LengthInput = Schemas["LengthInput"];
83
+ export type GroupWeightInput = Schemas["GroupWeightInput"];
84
+ export type ItemRefSelector = Schemas["ItemRefSelector"];
85
+ export type ItemPatch = Schemas["ItemPatch"];
86
+ export type ScanItemInput = Schemas["ScanItemInput"];
87
+ export type ScanItemResult = Schemas["ScanItemResult"];
88
+ export type ScanItemStatus = Schemas["ScanItemStatus"];
89
+ export type KeyRights = Schemas["KeyRights"];
90
+ export type BulkUpdateParams = Schemas["BulkUpdateRequest"];
91
+ export type Geometry = Schemas["Geometry"];
92
+ export type Account = Schemas["Account"];
93
+ export type WebhookTest = Schemas["WebhookTest"];
94
+ export type WebhookDelivery = Schemas["WebhookDelivery"];
95
+ export type WebhookDeliveryDetail = Schemas["WebhookDeliveryDetail"];
96
+ export type WebhookDeliveryAttempt = Schemas["WebhookDeliveryAttempt"];
97
+ export type ConsoleBootstrap = Schemas["ConsoleBootstrap"];
98
+ export type ConsoleOnboarding = Schemas["ConsoleOnboarding"];
99
+ export type OnboardingUseCase = Schemas["OnboardingUseCase"];
100
+ export type OnboardingStep = Schemas["OnboardingStep"];
101
+ export type OnboardingAboutYou = Schemas["OnboardingAboutYou"];
102
+ export type OnboardingOrganisation = Schemas["OnboardingOrganisation"];
103
+ export type OnboardingMeasures = Schemas["OnboardingMeasures"];
104
+ export type ConsoleOrganisation = Schemas["ConsoleOrganisation"];
105
+ export type AccountDataUse = Schemas["AccountDataUse"];
106
+ export type AccountDataRequest = Schemas["AccountDataRequest"];
107
+ export type AccountDataRequestList = Schemas["AccountDataRequestList"];
108
+ export type LegalAgreement = Schemas["LegalAgreement"];
109
+ export type ConsoleAgreement = Schemas["ConsoleAgreement"];
110
+ export type LiveAccess = Schemas["LiveAccess"];
111
+ /** Billing. `currentPeriod` gains `lumberM3` and `panelM3` (in development) where the server reports them. */
112
+ export type Billing = Omit<Schemas["Billing"], "currentPeriod"> & {
113
+ currentPeriod: Schemas["Billing"]["currentPeriod"] & {
114
+ lumberM3?: number;
115
+ panelM3?: number;
116
+ };
117
+ };
118
+ export type BillingInvoice = Schemas["BillingInvoice"];
119
+ export type BillingRedirect = Schemas["BillingRedirect"];
120
+ export type LiveWrites = S["LiveWrites"];
121
+ export type AccountBilling = Schemas["AccountBilling"];
122
+ export type LabelTemplate = Schemas["LabelTemplate"];
123
+ export type TagBatch = Schemas["TagBatch"];
124
+ export type PrintedTag = Schemas["PrintedTag"];
125
+ export type PrintFile = Schemas["PrintFile"];
126
+ export type TagQrGeometry = Schemas["TagQrGeometry"];
127
+ /** The fields of `POST /groups`, with the lumber and panel fields typed (see `LumberGroupFields`). */
128
+ export type GroupCreateParams = Omit<Schemas["GroupCreate"], keyof LumberGroupFields> & LumberGroupFields;
129
+ export type GroupUpdateParams = Schemas["GroupUpdate"];
130
+ export type ScanCreateParams = Schemas["ScanCreate"];
131
+ export type SimulateScanParams = Schemas["SimulateScanCreate"];
132
+ export type SimulatedRefinementRun = Schemas["SimulatedRefinementRun"];
133
+ export type PlaceCreateParams = Schemas["PlaceCreate"];
134
+ export type PlaceUpdateParams = Schemas["PlaceUpdate"];
135
+ export type SpeciesCreateParams = Schemas["SpeciesCreate"];
136
+ export type SpeciesUpdateParams = Schemas["SpeciesUpdate"];
137
+ export type ManualMeasurementParams = Schemas["ManualMeasurementRequest"];
138
+ export type CreateImageParams = Schemas["CreateImageRequest"];
139
+ export type ItemPhoto = Schemas["ItemPhoto"];
140
+ export type WebhookEndpointCreateParams = Schemas["WebhookEndpointCreate"];
141
+ export type WebhookEndpointUpdateParams = Schemas["WebhookEndpointUpdate"];
142
+ export type WebhookTestParams = Schemas["WebhookTestRequest"];
143
+ export type CaptureTokenCreateParams = Schemas["CaptureTokenCreate"];
144
+ export type ApiKeyCreateParams = Schemas["ApiKeyCreate"];
145
+ export type ApiKeyRollParams = Schemas["ApiKeyRoll"];
146
+ export type ApiKeyRevealParams = Schemas["ApiKeyRevealRequest"];
147
+ export type ApiKeySecret = Schemas["ApiKeySecret"];
148
+ export type CliLoginRequest = Schemas["CliLoginRequest"];
149
+ export type ApiKeyUpdateParams = Schemas["ApiKeyUpdate"];
150
+ export type ApiKeyRecordsVoidParams = Schemas["ApiKeyRecordsVoid"];
151
+ export type ApiKeyRecordsVoidResult = Schemas["ApiKeyRecordsVoidResult"];
152
+ export type GroupOpenParams = Schemas["GroupOpen"];
153
+ export type GroupLookup = Schemas["GroupLookup"];
154
+ export type GroupLookupParams = {
155
+ kind: string;
156
+ externalRef: string;
157
+ };
158
+ export type CaptureGroup = Schemas["CaptureGroup"];
159
+ export type TeamMemberUpdateParams = Schemas["TeamMemberUpdate"];
160
+ export type OwnershipTransferParams = Schemas["OwnershipTransfer"];
161
+ export type InvitationCreateParams = Schemas["InvitationCreate"];
162
+ export type InvitationAcceptParams = Schemas["InvitationAccept"];
163
+ export type TeamScannerCreateParams = Schemas["TeamScannerCreate"];
164
+ export type ConsoleOnboardingUpdateParams = Schemas["ConsoleOnboardingUpdate"];
165
+ export type ConsoleOrganisationCreateParams = Schemas["ConsoleOrganisationCreate"];
166
+ export type ConsoleDataUseUpdateParams = Schemas["ConsoleDataUseUpdate"];
167
+ export type AccountDataRequestCreateParams = Schemas["AccountDataRequestCreate"];
168
+ export type ConsoleAgreementCreateParams = Schemas["ConsoleAgreementCreate"];
169
+ export type LiveAccessUpdateParams = Schemas["LiveAccessUpdate"];
170
+ export type BillingUpdateParams = Schemas["BillingUpdate"];
171
+ export type BillingTermsAcceptanceParams = Schemas["BillingTermsAcceptance"];
172
+ export type BillingReturnUrlParams = Schemas["BillingReturnUrl"];
173
+ export type BillingCardSetupConfirmParams = Schemas["BillingCardSetupConfirm"];
174
+ export type BillingTestCardParams = Schemas["BillingTestCard"];
175
+ export type BillingPlanUpdateParams = Schemas["BillingPlanUpdate"];
176
+ export type LabelTemplateCreateParams = Schemas["LabelTemplateCreate"];
177
+ export type LabelTemplateUpdateParams = Schemas["LabelTemplateUpdate"];
178
+ export type TagBatchCreateParams = Schemas["TagBatchCreate"];
179
+ export type PrintFileParams = QueryParams<"getTagBatchPrintFile">;
180
+ /** Every invitation is on one page; `startingAfter` is accepted for the list iterator's sake. */
181
+ export type InvitationListParams = ListParams<"listInvitations"> & {
182
+ startingAfter?: string;
183
+ };
184
+ /** Every phone is on one page; `startingAfter` is accepted for the list iterator's sake. */
185
+ export type DeviceSignInListParams = ListParams<"listTeamDeviceSignIns"> & {
186
+ startingAfter?: string;
187
+ };
188
+ export type ObservationsParams = Schemas["ObservationsRequest"];
189
+ export type LumberProduct = S["LumberProduct"];
190
+ export type GroupImageKind = S["GroupImageKind"];
191
+ export type LumberDimension = Schemas["LumberDimension"];
192
+ export type LumberSpecInput = Schemas["LumberSpecInput"];
193
+ export type BundleAttributes = Schemas["BundleAttributes"];
194
+ /** A tally rule and its policies (see `volumeRules.list`); omitted policies take the rule's defaults. */
195
+ export type TallyRuleInput = {
196
+ id: string;
197
+ version?: string;
198
+ policies?: Record<string, string | number | boolean>;
199
+ };
200
+ /** What you expect a bundle to hold; compared on the tally, never used in a figure. */
201
+ export type LumberExpected = {
202
+ pieces?: number;
203
+ m3?: number;
204
+ boardFeet?: number;
205
+ m2?: number;
206
+ };
207
+ /**
208
+ * The photographs a lumber or panel tally needs before it can finish. By default `bundle_end` and `label` for
209
+ * lumber, `label` and `unit_edge` for panels. `{ required: false, reason }` waives them for this group.
210
+ */
211
+ export type PhotosPolicyInput = {
212
+ required: false;
213
+ reason: string;
214
+ } | {
215
+ required: GroupImageKind[];
216
+ };
217
+ /** The lumber and panel fields of a group create (`groups.create` and each entry of `groups.createBatch`). */
218
+ export type LumberGroupFields = {
219
+ product?: LumberProduct;
220
+ spec?: LumberSpecInput;
221
+ bundle?: BundleAttributes;
222
+ rule?: TallyRuleInput;
223
+ expected?: LumberExpected;
224
+ /** A packing list's totals convention: `exact` (sum of unrounded volumes) or `reported` (sum of printed ones). */
225
+ totals?: "exact" | "reported";
226
+ photos?: PhotosPolicyInput;
227
+ };
228
+ /** One group of a batch: the fields of `groups.create`, including the lumber and panel fields. */
229
+ export type LumberGroupCreateParams = Omit<Schemas["LumberGroupCreate"], keyof LumberGroupFields> & LumberGroupFields;
230
+ export type GroupBatchCreateParams = {
231
+ /** A parent created in the same call (a packing list). */
232
+ parent?: LumberGroupCreateParams;
233
+ /** Or an existing parent. */
234
+ parentId?: string;
235
+ /** Up to 500 groups; `externalRef` must be unique within the batch. */
236
+ groups: LumberGroupCreateParams[];
237
+ };
238
+ export type GroupBatch = Omit<Schemas["GroupBatch"], "parent" | "data"> & {
239
+ parent: Group | null;
240
+ data: Group[];
241
+ };
242
+ type Source = "vision" | "operator" | "corrected" | "group_default" | "bulk";
243
+ /** A dimension of a tally line. `source` says who entered it; `measured` keeps a machine's original value. */
244
+ export type TallyLineDimension = {
245
+ value: number;
246
+ unit: "in" | "ft" | "mm" | "cm" | "m";
247
+ source?: Source;
248
+ actual?: number;
249
+ measured?: {
250
+ value: number;
251
+ unit: string;
252
+ source?: string;
253
+ model?: string;
254
+ };
255
+ };
256
+ /** One tally line: a board, a counted run of identical boards, a width class, or a count of sheets. */
257
+ export type TallyLineInput = {
258
+ clientId?: string;
259
+ count?: number;
260
+ width?: TallyLineDimension;
261
+ length?: TallyLineDimension;
262
+ thickness?: TallyLineDimension;
263
+ /** Surface measure read off a board rule, kept as entered (no width needed). */
264
+ surfaceMeasure?: number;
265
+ countSource?: Source;
266
+ species?: string;
267
+ grade?: string;
268
+ panelType?: string;
269
+ evidence?: Record<string, unknown>;
270
+ };
271
+ export type GroupTallySubmitParams = {
272
+ /** Your id for this submission: the same tally sent again returns the same result. */
273
+ clientId: string;
274
+ lines: TallyLineInput[];
275
+ /** The submission this one replaces; 409 `tally_replaced` when it is not the current one. */
276
+ replaces?: string;
277
+ /** Photos of the bundle already uploaded with `images.createUploadSession` (subject group). */
278
+ imageIds?: string[];
279
+ device?: Record<string, unknown>;
280
+ sdk?: Record<string, unknown>;
281
+ location?: Schemas["Location"];
282
+ capturedAt?: string;
283
+ };
284
+ export type TallyCorrection = {
285
+ action: "update" | "split" | "remove" | "add";
286
+ itemId?: string;
287
+ /** Fields to set: width, length, thickness, count, surfaceMeasure, species or grade. */
288
+ set?: Partial<Omit<TallyLineInput, "clientId" | "evidence">>;
289
+ /** `split`: how many pieces move to the new line. */
290
+ count?: number;
291
+ /** `add`: the new line. */
292
+ line?: TallyLineInput;
293
+ reason: string;
294
+ };
295
+ export type GroupTallyCorrectionsParams = {
296
+ corrections: TallyCorrection[];
297
+ };
298
+ export type GroupTallyParams = {
299
+ rule?: string;
300
+ lines?: "all" | "none";
301
+ limit?: number;
302
+ startingAfter?: string;
303
+ };
304
+ export type TallySheetParams = {
305
+ format?: "json" | "html";
306
+ rule?: string;
307
+ };
308
+ export type PackingListParams = {
309
+ totals?: "exact" | "reported";
310
+ include?: "tally_sheets";
311
+ format?: "json" | "html";
312
+ };
313
+ export type TallyRevisionListParams = {
314
+ itemId?: string;
315
+ limit?: number;
316
+ startingAfter?: string;
317
+ };
318
+ /** Totals in the rule's units: reported numbers plus `*Exact` strings (`m3` and `m3Exact`, `boardFeet`...). */
319
+ export type LumberTotals = {
320
+ pieces: number;
321
+ boardFeet?: number;
322
+ boardFeetExact?: string;
323
+ m3?: number;
324
+ m3Exact?: string;
325
+ m2?: number;
326
+ /** MSF by thickness basis, e.g. `{ "3/4 in": 2.31 }`. */
327
+ msf?: Record<string, number>;
328
+ [quantity: string]: unknown;
329
+ };
330
+ export type PhotosStatus = {
331
+ required: string[];
332
+ waived: boolean;
333
+ waivedReason: string | null;
334
+ /** The photos were waived and none were taken. */
335
+ noPhoto: boolean;
336
+ missing: string[];
337
+ count: number;
338
+ byKind: Record<string, number>;
339
+ ids: string[];
340
+ };
341
+ export type TallyLine = {
342
+ itemId: string;
343
+ line: number;
344
+ clientId: string | null;
345
+ type: "board" | "sheet";
346
+ count: number;
347
+ width: TallyLineDimension | null;
348
+ length: TallyLineDimension | null;
349
+ thickness: TallyLineDimension | null;
350
+ [field: string]: unknown;
351
+ };
352
+ export type TallyRuleApplied = {
353
+ id: string;
354
+ version: string;
355
+ policies: Record<string, unknown>;
356
+ primary: string | null;
357
+ basis: string | null;
358
+ unconfirmedPolicies: string[];
359
+ };
360
+ type DocumentBlock = {
361
+ generatedAt: string;
362
+ contentSha256: string;
363
+ [field: string]: unknown;
364
+ };
365
+ /** A bundle's or unit's tally (`object: group_tally`, or `tally_sheet` with a `document` block). */
366
+ export type GroupTally = Omit<Schemas["LumberGroupTally"], "totals" | "lines"> & {
367
+ kind: string;
368
+ name: string | null;
369
+ externalRef: string | null;
370
+ /** When the tally (at this revision) became final; a tally is final when submitted. */
371
+ settledAt: string | null;
372
+ /** 1 for the first submitted tally, +1 for each re-tally or correction; 0 for none. */
373
+ revision: number;
374
+ /** Pieces counted on a photo (a vision count sent with the tally), beside the tally's `pieces`. */
375
+ countedPieces: number | null;
376
+ countMatches: boolean | null;
377
+ countDifference: number | null;
378
+ rule: TallyRuleApplied | null;
379
+ spec: Record<string, unknown>;
380
+ bundle: Record<string, unknown>;
381
+ label: Record<string, unknown> | null;
382
+ expected: LumberExpected | null;
383
+ lineCount: number;
384
+ totals: LumberTotals | null;
385
+ byLength: {
386
+ length: {
387
+ value: number;
388
+ unit: string;
389
+ };
390
+ pieces: number;
391
+ [quantity: string]: unknown;
392
+ }[];
393
+ byWidth: {
394
+ width: {
395
+ value: number;
396
+ unit: string;
397
+ };
398
+ pieces: number;
399
+ }[];
400
+ widthDevM: number | null;
401
+ sources: Record<string, number>;
402
+ submission: {
403
+ id: string;
404
+ clientId: string;
405
+ lineCount: number;
406
+ imageIds: string[];
407
+ visionCount: {
408
+ countedPieces: number;
409
+ imageId: string | null;
410
+ regions: unknown[] | null;
411
+ model: string | null;
412
+ confirmed: boolean;
413
+ } | null;
414
+ pieces: number;
415
+ createdAt: string;
416
+ } | null;
417
+ photos: PhotosStatus;
418
+ images: Record<string, unknown>[];
419
+ lines?: TallyLine[];
420
+ linesHasMore?: boolean;
421
+ document?: DocumentBlock;
422
+ [field: string]: unknown;
423
+ };
424
+ /** One row of a packing list: a bundle with its pieces, figures and (for width-class tallies) its histogram. */
425
+ export type PackingListRow = {
426
+ groupId: string;
427
+ externalRef: string | null;
428
+ number: string | null;
429
+ qualityCode: string | null;
430
+ drying: string | null;
431
+ species: string | null;
432
+ final: boolean;
433
+ rule: string | null;
434
+ pieces: number;
435
+ histogram: Record<string, number> | null;
436
+ [field: string]: unknown;
437
+ };
438
+ export type PackingListTotals = LumberTotals & {
439
+ convention: "exact" | "reported";
440
+ bundles: number;
441
+ };
442
+ export type PackingList = {
443
+ object: "packing_list";
444
+ livemode: boolean;
445
+ groupId: string;
446
+ kind: string;
447
+ name: string | null;
448
+ externalRef: string | null;
449
+ product: LumberProduct | null;
450
+ /** Every bundle has a final (submitted) tally. */
451
+ complete: boolean;
452
+ rules: TallyRuleApplied[];
453
+ totalsConvention: "exact" | "reported";
454
+ bundles: PackingListRow[];
455
+ widthClasses: {
456
+ value: number;
457
+ unit: string;
458
+ }[];
459
+ pivot: Record<string, unknown>[];
460
+ /** Under the list's convention. */
461
+ totals: PackingListTotals;
462
+ /** Under the other convention. */
463
+ totalsAlternative: PackingListTotals;
464
+ tallySheets?: GroupTally[];
465
+ document?: DocumentBlock;
466
+ [field: string]: unknown;
467
+ };
468
+ /** A tally sheet or packing list as a self-contained printable HTML page (`format: "html"`). */
469
+ export type LumberHtmlDocument = {
470
+ object: "document";
471
+ livemode: boolean;
472
+ format: "html";
473
+ content: string;
474
+ [field: string]: unknown;
475
+ };
476
+ export type TallyRevision = Camel<Schemas["TallyRevisionList"]["data"][number]> & {
477
+ itemId?: string | null;
478
+ field?: string | null;
479
+ from?: unknown;
480
+ to?: unknown;
481
+ createdAt?: string;
482
+ [field: string]: unknown;
483
+ };
484
+ export type GroupParent = Schemas["GroupParentList"]["data"][number];
485
+ export type SimulatePackingListParams = Schemas["SimulatePackingListCreate"];
486
+ export type SimulatedPackingList = Omit<Schemas["SimulatedPackingList"], "packingList"> & {
487
+ packingList: PackingList;
488
+ };
489
+ type QueryOf<K extends keyof operations> = operations[K] extends {
490
+ parameters: {
491
+ query?: infer Q;
492
+ };
493
+ } ? NonNullable<Q> : object;
494
+ /** Query parameters of an operation, camelCased. `expand[]` becomes `expand: string[]`. */
495
+ export type QueryParams<K extends keyof operations> = Camel<Omit<QueryOf<K>, "expand[]">> & ("expand[]" extends keyof QueryOf<K> ? {
496
+ expand?: string[];
497
+ } : object);
498
+ /** Parameters of every list operation also accept `limit` (1 to 100) and `startingAfter`; the iterators set the latter. */
499
+ export type ListParams<K extends keyof operations> = QueryParams<K>;
500
+ export type ScanImageParams = {
501
+ subject: "group" | "item";
502
+ /** A group image kind (`subject: "group"`) or an item image kind (`subject: "item"`). */
503
+ kind: string;
504
+ /** An item image names its item by `itemId` or by `itemClientId` (exactly one). */
505
+ itemId?: string;
506
+ /** The `clientId` the item was sent with in this scan. */
507
+ itemClientId?: string;
508
+ clientId?: string;
509
+ capturedAt?: string;
510
+ /** Lowercase hex SHA-256 of the file; the server refuses a difference with 409 `upload_hash_mismatch`. */
511
+ sha256?: string;
512
+ width?: number;
513
+ height?: number;
514
+ /** The GPS fix at capture. */
515
+ location?: Schemas["Location"];
516
+ /** Item images: where the crop lies in its source image. */
517
+ region?: Schemas["NormalizedBox"];
518
+ sourceImageId?: string;
519
+ /** Group images: the logs the device found in it. */
520
+ detections?: Schemas["ImageDetectionsInput"];
521
+ /** The JPEG, at most 10 MB. */
522
+ file: Blob | Uint8Array | ArrayBuffer;
523
+ filename?: string;
524
+ };
525
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Display-only helpers. The API stores and returns SI values; an account's `display_units`
3
+ * (`metric` or `imperial`) says how a UI should show them. Nothing here is used for requests.
4
+ */
5
+ export type DisplayUnits = "metric" | "imperial";
6
+ /** Either the units themselves or anything carrying them, such as the object from `te.account.retrieve()`. */
7
+ export type UnitsSource = DisplayUnits | {
8
+ displayUnits: DisplayUnits;
9
+ };
10
+ export declare const M_PER_FOOT = 0.3048;
11
+ export declare const M_PER_INCH = 0.0254;
12
+ export declare const KG_PER_POUND = 0.45359237;
13
+ export declare const KG_PER_SHORT_TON = 907.18474;
14
+ export declare const M3_PER_CUBIC_FOOT = 0.028316846592;
15
+ export interface Formatted {
16
+ value: number;
17
+ unit: string;
18
+ }
19
+ /** Lengths: metres, or feet. */
20
+ export declare function formatLength(valueM: number, source: UnitsSource, digits?: number): string;
21
+ /** Diameters: centimetres, or inches. */
22
+ export declare function formatDiameter(valueM: number, source: UnitsSource, digits?: number): string;
23
+ /** Weights: kilograms below one tonne and tonnes above; pounds below one short ton and short tons above. */
24
+ export declare function formatWeight(valueKg: number, source: UnitsSource, digits?: number): string;
25
+ /** Volumes: cubic metres, or cubic feet. Board-foot rule outputs are shown from `volume.native`, not converted. */
26
+ export declare function formatVolume(valueM3: number, source: UnitsSource, digits?: number): string;
@@ -0,0 +1,38 @@
1
+ function resolve(u) {
2
+ return typeof u === "string" ? u : u.displayUnits;
3
+ }
4
+ export const M_PER_FOOT = 0.3048;
5
+ export const M_PER_INCH = 0.0254;
6
+ export const KG_PER_POUND = 0.45359237;
7
+ export const KG_PER_SHORT_TON = 907.18474;
8
+ export const M3_PER_CUBIC_FOOT = 0.028316846592;
9
+ function fmt(n, digits) {
10
+ return String(Number(n.toFixed(digits)));
11
+ }
12
+ /** Lengths: metres, or feet. */
13
+ export function formatLength(valueM, source, digits = 2) {
14
+ const units = resolve(source);
15
+ return units === "imperial" ? `${fmt(valueM / M_PER_FOOT, digits)} ft` : `${fmt(valueM, digits)} m`;
16
+ }
17
+ /** Diameters: centimetres, or inches. */
18
+ export function formatDiameter(valueM, source, digits = 1) {
19
+ const units = resolve(source);
20
+ return units === "imperial" ? `${fmt(valueM / M_PER_INCH, digits)} in` : `${fmt(valueM * 100, digits)} cm`;
21
+ }
22
+ /** Weights: kilograms below one tonne and tonnes above; pounds below one short ton and short tons above. */
23
+ export function formatWeight(valueKg, source, digits = 2) {
24
+ const units = resolve(source);
25
+ if (units === "imperial") {
26
+ return Math.abs(valueKg) >= KG_PER_SHORT_TON
27
+ ? `${fmt(valueKg / KG_PER_SHORT_TON, digits)} short tons`
28
+ : `${fmt(valueKg / KG_PER_POUND, digits)} lb`;
29
+ }
30
+ return Math.abs(valueKg) >= 1000 ? `${fmt(valueKg / 1000, digits)} t` : `${fmt(valueKg, digits)} kg`;
31
+ }
32
+ /** Volumes: cubic metres, or cubic feet. Board-foot rule outputs are shown from `volume.native`, not converted. */
33
+ export function formatVolume(valueM3, source, digits = 3) {
34
+ const units = resolve(source);
35
+ return units === "imperial"
36
+ ? `${fmt(valueM3 / M3_PER_CUBIC_FOOT, digits)} ft³`
37
+ : `${fmt(valueM3, digits)} m³`;
38
+ }
@@ -0,0 +1,44 @@
1
+ import type { WebhookEvent } from "./types.js";
2
+ export type HeadersInput = {
3
+ get(name: string): string | null;
4
+ } | Record<string, string | string[] | undefined>;
5
+ export interface VerifyOptions {
6
+ /** Maximum age (and clock skew) of `webhook-timestamp` in seconds. Default 300. */
7
+ toleranceSeconds?: number;
8
+ /** Advanced (used by tests): the clock, in milliseconds. */
9
+ now?: () => number;
10
+ }
11
+ /**
12
+ * A request a webhook arrived on, for `te.webhooks.verify(req)`:
13
+ *
14
+ * - a Fetch `Request` (Next.js route handlers, Hono, Cloudflare Workers, Deno, Bun): its body is read here;
15
+ * - a Node `IncomingMessage` (Express, Fastify, plain `http`) whose `body` is the raw bytes, as
16
+ * `express.raw({ type: "application/json" })` leaves it, or whose body has not been read by anything yet.
17
+ */
18
+ export type WebhookRequest = {
19
+ headers: {
20
+ get(name: string): string | null;
21
+ };
22
+ arrayBuffer(): Promise<ArrayBuffer>;
23
+ bodyUsed?: boolean;
24
+ } | {
25
+ headers: Record<string, string | string[] | undefined>;
26
+ body?: unknown;
27
+ readableEnded?: boolean;
28
+ on?: (event: string, listener: (...args: any[]) => void) => unknown;
29
+ };
30
+ /**
31
+ * The raw body and headers of a webhook request, or a {@link WebhookSignatureError} (`raw_body_required`)
32
+ * that says how to get the raw body when the request's body was already parsed or consumed.
33
+ */
34
+ export declare function readWebhookRequest(req: WebhookRequest): Promise<{
35
+ body: Uint8Array | string;
36
+ headers: HeadersInput;
37
+ }>;
38
+ /**
39
+ * Verify a Standard Webhooks delivery and return the event. Pass the raw body exactly as received
40
+ * (string, Uint8Array, a Node buffer or ArrayBuffer), never a re-serialised parse.
41
+ *
42
+ * It is async because Web Crypto is: `await te.webhooks.verify(...)`.
43
+ */
44
+ export declare function verifyWebhook(rawBody: string | Uint8Array | ArrayBuffer, headers: HeadersInput, secret: string | string[], options?: VerifyOptions): Promise<WebhookEvent>;