@camstack/types 1.2.52 → 1.2.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capabilities/connection-test.cap.d.ts +103 -0
- package/dist/capabilities/device-manager.cap.d.ts +67 -0
- package/dist/capabilities/index.d.ts +4 -2
- package/dist/capabilities/integrations.cap.d.ts +48 -1
- package/dist/capabilities/oauth-integration.cap.d.ts +59 -0
- package/dist/generated/addon-api.d.ts +44 -0
- package/dist/generated/capability-router-map.d.ts +5 -2
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/system-proxy.d.ts +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +377 -1
- package/dist/index.mjs +368 -2
- package/dist/interfaces/adoption-job.d.ts +113 -0
- package/package.json +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Adoption job — the background form of `device-adoption.adopt`.
|
|
4
|
+
*
|
|
5
|
+
* ## Why this exists
|
|
6
|
+
*
|
|
7
|
+
* `adopt({childNativeIds: [...]})` materialises one CamStack device per
|
|
8
|
+
* candidate PLUS every accessory child, and the whole array shares ONE UDS
|
|
9
|
+
* request deadline (60s). Measured on the live hub against Home Assistant:
|
|
10
|
+
* each device the kernel creates costs ~450 ms — `devices.create` pre-seeds
|
|
11
|
+
* meta with up to eleven SEQUENTIAL round trips (`setName`, `setType`,
|
|
12
|
+
* `setRole`, … `persistConfig`) before the class is constructed — and an
|
|
13
|
+
* accessory child costs the same as its parent. So the real unit of work is
|
|
14
|
+
* the CHILD, not the candidate:
|
|
15
|
+
*
|
|
16
|
+
* - 25 candidates averaging 6 children → ~150 devices → **>60s, times out**
|
|
17
|
+
* - ONE candidate with 217 children → ~217 devices → **>60s, times out**
|
|
18
|
+
*
|
|
19
|
+
* That second line is why this is a job and not a smaller batch. No chunking,
|
|
20
|
+
* no bounded concurrency over candidates and no per-call tuning can fix a
|
|
21
|
+
* shape where **N=1 already exceeds the deadline** — the count that blows the
|
|
22
|
+
* budget is the source system's accessory fan-out, which the operator does not
|
|
23
|
+
* choose and cannot see. A design that only works below some N is the same bug
|
|
24
|
+
* deferred.
|
|
25
|
+
*
|
|
26
|
+
* ## What the timeout did NOT do
|
|
27
|
+
*
|
|
28
|
+
* It did not stop the work. The UDS deadline ends the CALLER's wait; the
|
|
29
|
+
* provider's loop runs to completion. Measured: a 25-candidate adopt that
|
|
30
|
+
* "failed" at 60s had adopted 17 by 87s and all 25 by ~130s. The operator saw
|
|
31
|
+
* an error and had no way to learn that. Every field below exists so that
|
|
32
|
+
* question has an answer.
|
|
33
|
+
*
|
|
34
|
+
* ## Idempotency
|
|
35
|
+
*
|
|
36
|
+
* Jobs are in-RAM; a restart forgets them. That is safe here because adoption
|
|
37
|
+
* is keyed by a stable id (`ha:<broker>:dev:<nativeId>` and equivalents), so
|
|
38
|
+
* re-running a job re-adopts nothing: an already-adopted candidate is SKIPPED
|
|
39
|
+
* by the engine before any provider call and lands in `alreadyAdopted`. It is
|
|
40
|
+
* never a duplicate device, and never an error the operator has to interpret.
|
|
41
|
+
*/
|
|
42
|
+
export declare const AdoptionJobStateSchema: z.ZodEnum<{
|
|
43
|
+
done: "done";
|
|
44
|
+
failed: "failed";
|
|
45
|
+
running: "running";
|
|
46
|
+
cancelled: "cancelled";
|
|
47
|
+
}>;
|
|
48
|
+
export type AdoptionJobState = z.infer<typeof AdoptionJobStateSchema>;
|
|
49
|
+
/**
|
|
50
|
+
* Per-candidate result. Every candidate the job was asked to adopt ends in
|
|
51
|
+
* exactly one of these buckets — there is no silent drop, and the operator can
|
|
52
|
+
* always answer "which of my 25 landed?".
|
|
53
|
+
*
|
|
54
|
+
* - `adopted` — created now by this job.
|
|
55
|
+
* - `already-adopted` — a device for this candidate existed before the job
|
|
56
|
+
* reached it (a re-run, or a retry after a timeout). Not an error.
|
|
57
|
+
* - `failed` — the provider threw; `error` carries the message.
|
|
58
|
+
* - `cancelled` — the operator cancelled before this candidate was reached.
|
|
59
|
+
*/
|
|
60
|
+
export declare const AdoptionOutcomeSchema: z.ZodEnum<{
|
|
61
|
+
failed: "failed";
|
|
62
|
+
cancelled: "cancelled";
|
|
63
|
+
adopted: "adopted";
|
|
64
|
+
"already-adopted": "already-adopted";
|
|
65
|
+
}>;
|
|
66
|
+
export type AdoptionOutcome = z.infer<typeof AdoptionOutcomeSchema>;
|
|
67
|
+
export declare const AdoptionCandidateResultSchema: z.ZodObject<{
|
|
68
|
+
childNativeId: z.ZodString;
|
|
69
|
+
outcome: z.ZodEnum<{
|
|
70
|
+
failed: "failed";
|
|
71
|
+
cancelled: "cancelled";
|
|
72
|
+
adopted: "adopted";
|
|
73
|
+
"already-adopted": "already-adopted";
|
|
74
|
+
}>;
|
|
75
|
+
parentDeviceId: z.ZodNullable<z.ZodNumber>;
|
|
76
|
+
accessoryCount: z.ZodNumber;
|
|
77
|
+
error: z.ZodNullable<z.ZodString>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export type AdoptionCandidateResult = z.infer<typeof AdoptionCandidateResultSchema>;
|
|
80
|
+
export declare const AdoptionJobSchema: z.ZodObject<{
|
|
81
|
+
jobId: z.ZodString;
|
|
82
|
+
addonId: z.ZodString;
|
|
83
|
+
integrationId: z.ZodString;
|
|
84
|
+
state: z.ZodEnum<{
|
|
85
|
+
done: "done";
|
|
86
|
+
failed: "failed";
|
|
87
|
+
running: "running";
|
|
88
|
+
cancelled: "cancelled";
|
|
89
|
+
}>;
|
|
90
|
+
total: z.ZodNumber;
|
|
91
|
+
processed: z.ZodNumber;
|
|
92
|
+
adopted: z.ZodNumber;
|
|
93
|
+
alreadyAdopted: z.ZodNumber;
|
|
94
|
+
failed: z.ZodNumber;
|
|
95
|
+
accessoriesCreated: z.ZodNumber;
|
|
96
|
+
currentChildNativeId: z.ZodNullable<z.ZodString>;
|
|
97
|
+
results: z.ZodReadonly<z.ZodArray<z.ZodObject<{
|
|
98
|
+
childNativeId: z.ZodString;
|
|
99
|
+
outcome: z.ZodEnum<{
|
|
100
|
+
failed: "failed";
|
|
101
|
+
cancelled: "cancelled";
|
|
102
|
+
adopted: "adopted";
|
|
103
|
+
"already-adopted": "already-adopted";
|
|
104
|
+
}>;
|
|
105
|
+
parentDeviceId: z.ZodNullable<z.ZodNumber>;
|
|
106
|
+
accessoryCount: z.ZodNumber;
|
|
107
|
+
error: z.ZodNullable<z.ZodString>;
|
|
108
|
+
}, z.core.$strip>>>;
|
|
109
|
+
startedAt: z.ZodNumber;
|
|
110
|
+
finishedAt: z.ZodNullable<z.ZodNumber>;
|
|
111
|
+
error: z.ZodNullable<z.ZodString>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
export type AdoptionJob = z.infer<typeof AdoptionJobSchema>;
|