@homeflare/distilled-unifi-network 0.2.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.
- package/LICENSE +201 -0
- package/README.md +125 -0
- package/dist/credentials.d.ts +24 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +78 -0
- package/dist/credentials.js.map +1 -0
- package/dist/errors.d.ts +74 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +49 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +18 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +59 -0
- package/dist/protocol.js.map +1 -0
- package/dist/retry.d.ts +57 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +50 -0
- package/dist/retry.js.map +1 -0
- package/dist/services/access_control_acl_rules.d.ts +222 -0
- package/dist/services/access_control_acl_rules.d.ts.map +1 -0
- package/dist/services/access_control_acl_rules.js +225 -0
- package/dist/services/access_control_acl_rules.js.map +1 -0
- package/dist/services/application_info.d.ts +15 -0
- package/dist/services/application_info.d.ts.map +1 -0
- package/dist/services/application_info.js +22 -0
- package/dist/services/application_info.js.map +1 -0
- package/dist/services/clients.d.ts +108 -0
- package/dist/services/clients.d.ts.map +1 -0
- package/dist/services/clients.js +122 -0
- package/dist/services/clients.js.map +1 -0
- package/dist/services/dns_policies.d.ts +143 -0
- package/dist/services/dns_policies.d.ts.map +1 -0
- package/dist/services/dns_policies.js +171 -0
- package/dist/services/dns_policies.js.map +1 -0
- package/dist/services/firewall.d.ts +473 -0
- package/dist/services/firewall.d.ts.map +1 -0
- package/dist/services/firewall.js +521 -0
- package/dist/services/firewall.js.map +1 -0
- package/dist/services/hotspot.d.ts +107 -0
- package/dist/services/hotspot.d.ts.map +1 -0
- package/dist/services/hotspot.js +145 -0
- package/dist/services/hotspot.js.map +1 -0
- package/dist/services/index.d.ts +14 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +15 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/networks.d.ts +251 -0
- package/dist/services/networks.d.ts.map +1 -0
- package/dist/services/networks.js +256 -0
- package/dist/services/networks.js.map +1 -0
- package/dist/services/sites.d.ts +31 -0
- package/dist/services/sites.d.ts.map +1 -0
- package/dist/services/sites.js +38 -0
- package/dist/services/sites.js.map +1 -0
- package/dist/services/supporting_resources.d.ts +238 -0
- package/dist/services/supporting_resources.d.ts.map +1 -0
- package/dist/services/supporting_resources.js +298 -0
- package/dist/services/supporting_resources.js.map +1 -0
- package/dist/services/switching.d.ts +168 -0
- package/dist/services/switching.d.ts.map +1 -0
- package/dist/services/switching.js +226 -0
- package/dist/services/switching.js.map +1 -0
- package/dist/services/traffic_matching_lists.d.ts +75 -0
- package/dist/services/traffic_matching_lists.d.ts.map +1 -0
- package/dist/services/traffic_matching_lists.js +126 -0
- package/dist/services/traffic_matching_lists.js.map +1 -0
- package/dist/services/unifi_devices.d.ts +280 -0
- package/dist/services/unifi_devices.d.ts.map +1 -0
- package/dist/services/unifi_devices.js +338 -0
- package/dist/services/unifi_devices.js.map +1 -0
- package/dist/services/wifi_broadcasts.d.ts +378 -0
- package/dist/services/wifi_broadcasts.d.ts.map +1 -0
- package/dist/services/wifi_broadcasts.js +396 -0
- package/dist/services/wifi_broadcasts.js.map +1 -0
- package/dist/traits.d.ts +11 -0
- package/dist/traits.d.ts.map +1 -0
- package/dist/traits.js +12 -0
- package/dist/traits.js.map +1 -0
- package/package.json +75 -0
- package/src/credentials.ts +112 -0
- package/src/errors.ts +103 -0
- package/src/index.ts +36 -0
- package/src/protocol.ts +86 -0
- package/src/retry.ts +83 -0
- package/src/services/access_control_acl_rules.ts +537 -0
- package/src/services/application_info.ts +44 -0
- package/src/services/clients.ts +272 -0
- package/src/services/dns_policies.ts +363 -0
- package/src/services/firewall.ts +1492 -0
- package/src/services/hotspot.ts +305 -0
- package/src/services/index.ts +14 -0
- package/src/services/networks.ts +613 -0
- package/src/services/sites.ts +81 -0
- package/src/services/supporting_resources.ts +650 -0
- package/src/services/switching.ts +496 -0
- package/src/services/traffic_matching_lists.ts +248 -0
- package/src/services/unifi_devices.ts +795 -0
- package/src/services/wifi_broadcasts.ts +992 -0
- package/src/traits.ts +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# @homeflare/distilled-unifi-network
|
|
2
|
+
|
|
3
|
+
This package is **not a HomeFlare SDK**. It is an unmodified copy of
|
|
4
|
+
`@distilled.cloud/unifi-network`, generated by the
|
|
5
|
+
[distilled](https://github.com/alchemy-run/distilled) pipeline from
|
|
6
|
+
Ubiquiti's own **UniFi Network Integration API** OpenAPI 3.1.0 document
|
|
7
|
+
(10.4.57 — an operator export from a console's own web UI; the vendor
|
|
8
|
+
publishes no stable, anonymously-fetchable spec URL), published here under
|
|
9
|
+
its own name only because `@distilled.cloud/unifi-network` does not exist
|
|
10
|
+
on npm yet — the kit builds it in a local clone of `alchemy-run/distilled`
|
|
11
|
+
but, per house policy, never pushes to that upstream. See
|
|
12
|
+
[`../alchemy/docs/distilled-interim.md`](../alchemy/docs/distilled-interim.md)
|
|
13
|
+
for the full route every distilled-sourced vendor package follows, and why
|
|
14
|
+
this one exists at all.
|
|
15
|
+
|
|
16
|
+
⛔ **Do not hand-edit anything under `src/`.** The whole point of the route
|
|
17
|
+
above is that this directory is _copied_, not written — a fix belongs in
|
|
18
|
+
the distilled clone's `packages/unifi-network/`, regenerated, then copied
|
|
19
|
+
back here.
|
|
20
|
+
|
|
21
|
+
⚠️ **License.** Apache-2.0, not the kit's usual MIT — this content is a
|
|
22
|
+
redistribution of `alchemy-run/distilled`'s own Apache-2.0-licensed output,
|
|
23
|
+
and relicensing a copy would misstate what it is. See `LICENSE`.
|
|
24
|
+
|
|
25
|
+
## What's in it
|
|
26
|
+
|
|
27
|
+
13 service modules, one per UniFi Network API tag — `sites`,
|
|
28
|
+
`unifiDevices`, `clients`, `networks`, `wifiBroadcasts`, `hotspot`,
|
|
29
|
+
`firewall`, `accessControlAclRules`, `switching`, `dnsPolicies`,
|
|
30
|
+
`trafficMatchingLists`, `supportingResources`, plus the single-endpoint
|
|
31
|
+
`applicationInfo` — an Effect-typed operation per API endpoint (73 total
|
|
32
|
+
across 44 paths), with `catchTag`-able errors for every HTTP status the
|
|
33
|
+
protocol layer dispatches on (the spec documents **zero** error responses
|
|
34
|
+
on any operation — see `docs/codegen-notes.md#typed-errors` for what that
|
|
35
|
+
means for this package's error channel).
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import * as UnifiNetwork from '@distilled.cloud/unifi-network'; // aliased onto this package — see docs/distilled-interim.md
|
|
39
|
+
import * as Effect from 'effect/Effect';
|
|
40
|
+
|
|
41
|
+
const program = UnifiNetwork.Services.sites.getSiteOverviewPage({}).pipe(
|
|
42
|
+
Effect.provide(
|
|
43
|
+
UnifiNetwork.credentials({
|
|
44
|
+
// Local console: "https://<console-ip>/proxy/network/integration"
|
|
45
|
+
// Cloud connector: "https://api.ui.com/v1/connector/consoles/<consoleId>/proxy/network/integration"
|
|
46
|
+
apiBaseUrl: process.env.UNIFI_NETWORK_API_BASE_URL!,
|
|
47
|
+
apiKey: process.env.UNIFI_NETWORK_API_KEY!,
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Kit code never imports `@homeflare/distilled-unifi-network` directly —
|
|
54
|
+
always `@distilled.cloud/unifi-network`, aliased in the consuming package's
|
|
55
|
+
`package.json`
|
|
56
|
+
(`"@distilled.cloud/unifi-network": "npm:@homeflare/distilled-unifi-network@<version>"`),
|
|
57
|
+
so the eventual cutover to the real published package is a one-line alias
|
|
58
|
+
swap with no import changes anywhere in the kit.
|
|
59
|
+
|
|
60
|
+
### Authentication is NOT documented in the spec
|
|
61
|
+
|
|
62
|
+
`components.securitySchemes` is absent and no operation carries a
|
|
63
|
+
`security` requirement. The `X-API-KEY` header this SDK sends comes from
|
|
64
|
+
[Ubiquiti's own Integration API guide](https://developer.ui.com/unifi-integration-api-guide/),
|
|
65
|
+
not the machine-readable description — **unverified against a live
|
|
66
|
+
console as of this package's creation**; see the auth-probe handoff this
|
|
67
|
+
package shipped alongside, and re-verify before depending on it for
|
|
68
|
+
anything that writes.
|
|
69
|
+
|
|
70
|
+
## Resource-level traps a future provider must not ignore
|
|
71
|
+
|
|
72
|
+
These are NOT solved in this SDK. Full detail in `src/credentials.ts`'s
|
|
73
|
+
own doc comment and `docs/codegen-notes.md`; the headlines:
|
|
74
|
+
|
|
75
|
+
- **Whole-object PUT.** Nine endpoints (`updateNetwork`,
|
|
76
|
+
`updateFirewallPolicy`, `updateAclRule`, …) silently _disable_ any field
|
|
77
|
+
the caller omits — DHCP, IPv4, IPv6 config each say so in the vendor's
|
|
78
|
+
own schema. A Resource must read-merge-write the whole object and fail
|
|
79
|
+
closed on a partial read.
|
|
80
|
+
- **Ordering endpoints replace the whole list.** `acl-rules/ordering` and
|
|
81
|
+
`firewall/policies/ordering` take the entire ordered list; a partial
|
|
82
|
+
list drops or reorders rules.
|
|
83
|
+
- **Adopt-only objects.** Sites have no create/delete endpoint at all. The
|
|
84
|
+
default network is undeletable and has live dependents. `removeDevice`
|
|
85
|
+
does not delete — it unadopts and factory-resets an online device.
|
|
86
|
+
- **Writes that power-cycle or reboot hardware** hide behind ordinary
|
|
87
|
+
verbs (`executeAdoptedDeviceAction`'s `RESTART`, `executePortAction`'s
|
|
88
|
+
`POWER_CYCLE`) — treat as gated commands, never declared props.
|
|
89
|
+
- **Secrets never become attributes.** The controller API key and the WLAN
|
|
90
|
+
pre-shared key (`passphrase` — not caught by core's generic
|
|
91
|
+
`SENSITIVE_FIELD_PATTERNS`) are both write-only, sourced from OpenBao at
|
|
92
|
+
call time, never read back as plan attributes.
|
|
93
|
+
|
|
94
|
+
## Scope and next steps
|
|
95
|
+
|
|
96
|
+
The **UniFi Site Manager API** (a different, cloud-hosted product) is out
|
|
97
|
+
of scope for this package and belongs in its own — see the distilled
|
|
98
|
+
clone's `packages/unifi-network/docs/scope-and-next-steps.md`. This
|
|
99
|
+
package has no kit provider yet; its first resources should be
|
|
100
|
+
read/adopt-only (`Site`, `Network`, `FirewallZone`/`FirewallPolicy`)
|
|
101
|
+
before any resource attempts a write that has to honor the whole-object-PUT
|
|
102
|
+
and ordering-list traps above.
|
|
103
|
+
|
|
104
|
+
## Updating it
|
|
105
|
+
|
|
106
|
+
From the distilled clone's `homeflare/unifi-network` worktree:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
DISTILLED_SPECS_LOCAL=1 pnpm --filter @distilled.cloud/unifi-network run generate
|
|
110
|
+
pnpm --filter @distilled.cloud/unifi-network run typecheck
|
|
111
|
+
pnpm format && pnpm specs:check
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Then copy `src/` here verbatim, bump this package's own `version` (a patch
|
|
115
|
+
release — the generated content changed, not this package's own shape),
|
|
116
|
+
add a changeset, and let the kit's normal release flow publish it.
|
|
117
|
+
Regenerate against the pinned schema version (10.4.57) only.
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
Apache-2.0 (see `LICENSE`) — not the kit's usual MIT. `src/` is an
|
|
122
|
+
unmodified copy of `@distilled.cloud/unifi-network`'s own output from
|
|
123
|
+
`alchemy-run/distilled`, which is itself Apache-2.0; this package's own
|
|
124
|
+
files (`package.json`, `tsconfig.json`, `scripts/smoke.ts`, this README)
|
|
125
|
+
are offered under the same terms.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Redacted from "effect/Redacted";
|
|
5
|
+
export interface Config {
|
|
6
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Fully-qualified integration API root for one console, e.g.
|
|
9
|
+
* `https://192.168.1.1/proxy/network/integration`. No default: every
|
|
10
|
+
* caller names its own console.
|
|
11
|
+
*/
|
|
12
|
+
readonly apiBaseUrl: string;
|
|
13
|
+
}
|
|
14
|
+
declare const Credentials_base: Context.ServiceClass<Credentials, "UnifiNetworkCredentials", Effect.Effect<Config, never, never>>;
|
|
15
|
+
export declare class Credentials extends Credentials_base {
|
|
16
|
+
}
|
|
17
|
+
export declare const CredentialsFromEnv: Layer.Layer<Credentials, never, never>;
|
|
18
|
+
/** Convenience layer from a plain API key and the console's integration API root. */
|
|
19
|
+
export declare const credentials: (config: {
|
|
20
|
+
readonly apiKey: string | Redacted.Redacted<string>;
|
|
21
|
+
readonly apiBaseUrl: string;
|
|
22
|
+
}) => Layer.Layer<Credentials>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AA0CA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAG5C,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAaD,qBAAa,WAAY,SAAQ,gBAGH;CAAG;AAOjC,eAAO,MAAM,kBAAkB,wCAgB9B,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,WAAW,WAAY;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAUxB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UniFi Network credentials — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* The `Credentials` service resolves `{ apiKey, apiBaseUrl }` per request;
|
|
5
|
+
* the protocol layer sends it as the `X-API-KEY` header. UniFi Network is
|
|
6
|
+
* console-hosted (a local controller, or Ubiquiti's cloud connector proxying
|
|
7
|
+
* to one), so — like Forgejo — there is no default API root: the console's
|
|
8
|
+
* address IS part of the credential, and the caller supplies it exactly.
|
|
9
|
+
*
|
|
10
|
+
* Two console shapes exist, both valid `apiBaseUrl` values (the generated
|
|
11
|
+
* operations' routes already start with `/v1/...`, matching the OpenAPI
|
|
12
|
+
* document's `paths`, so nothing is appended here):
|
|
13
|
+
*
|
|
14
|
+
* - Local console: `https://<console-ip>/proxy/network/integration`
|
|
15
|
+
* - Cloud connector: `https://api.ui.com/v1/connector/consoles/<consoleId>/proxy/network/integration`
|
|
16
|
+
*
|
|
17
|
+
* `<consoleId>` is an account identifier — never log, commit, or otherwise
|
|
18
|
+
* persist an `apiBaseUrl` that contains one outside of the caller's own
|
|
19
|
+
* runtime configuration.
|
|
20
|
+
*
|
|
21
|
+
* ⛔ AUTHENTICATION IS NOT DOCUMENTED IN THE SPEC: `network_v10.4.57_openapi.json`
|
|
22
|
+
* declares no `components.securitySchemes` and no operation carries a
|
|
23
|
+
* `security` requirement — the `X-API-KEY` header below comes from
|
|
24
|
+
* Ubiquiti's own Integration API guide (https://developer.ui.com/unifi-integration-api-guide/),
|
|
25
|
+
* not from the machine-readable description. Re-verify this against a live
|
|
26
|
+
* console (a request without it should 401) before depending on it in
|
|
27
|
+
* anything that writes.
|
|
28
|
+
*
|
|
29
|
+
* The key itself is an Integrations → API Key created in the console's own
|
|
30
|
+
* UI (Settings → Control Plane → Integrations on a local console). It is a
|
|
31
|
+
* SECRET: callers that adopt this package into the kit read it from OpenBao
|
|
32
|
+
* at call time and pass a reference, never a literal value in state — see
|
|
33
|
+
* the package README's "Secrets" section.
|
|
34
|
+
*
|
|
35
|
+
* ⚠️ TLS is this package's caller's problem, not this package's: a local
|
|
36
|
+
* console's certificate is self-signed by default (the cloud connector's is
|
|
37
|
+
* not). `Credentials` carries no TLS configuration — trust decisions belong
|
|
38
|
+
* to the `HttpClient` layer the caller provides (a custom agent pinning the
|
|
39
|
+
* console's cert, or an explicit opt-in to skip verification for a known
|
|
40
|
+
* LAN address), never hard-coded here.
|
|
41
|
+
*/
|
|
42
|
+
import * as EffectConfig from "effect/Config";
|
|
43
|
+
import * as Context from "effect/Context";
|
|
44
|
+
import * as Effect from "effect/Effect";
|
|
45
|
+
import * as Layer from "effect/Layer";
|
|
46
|
+
import * as Redacted from "effect/Redacted";
|
|
47
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
48
|
+
/**
|
|
49
|
+
* Drop trailing slashes; the base URL carries no other structure to fix up.
|
|
50
|
+
* A loop, not `/\/+$/`: that regex backtracks polynomially on a long run of
|
|
51
|
+
* `/` (CodeQL js/polynomial-redos), the same fix as distilled-netbox's.
|
|
52
|
+
*/
|
|
53
|
+
const normalizeBaseUrl = (baseUrl) => {
|
|
54
|
+
let end = baseUrl.length;
|
|
55
|
+
while (end > 0 && baseUrl.charCodeAt(end - 1) === 47)
|
|
56
|
+
end--;
|
|
57
|
+
return baseUrl.slice(0, end);
|
|
58
|
+
};
|
|
59
|
+
export class Credentials extends Context.Service()("UnifiNetworkCredentials") {
|
|
60
|
+
}
|
|
61
|
+
const envConfig = EffectConfig.all({
|
|
62
|
+
apiKey: EffectConfig.String("UNIFI_NETWORK_API_KEY"),
|
|
63
|
+
apiBaseUrl: EffectConfig.String("UNIFI_NETWORK_API_BASE_URL"),
|
|
64
|
+
});
|
|
65
|
+
export const CredentialsFromEnv = Layer.succeed(Credentials, envConfig.pipe(Effect.mapError(() => new ConfigError({
|
|
66
|
+
message: "UNIFI_NETWORK_API_BASE_URL and UNIFI_NETWORK_API_KEY environment variables are required",
|
|
67
|
+
})), Effect.map(({ apiKey, apiBaseUrl }) => ({
|
|
68
|
+
apiKey: Redacted.make(apiKey),
|
|
69
|
+
apiBaseUrl: normalizeBaseUrl(apiBaseUrl),
|
|
70
|
+
})), Effect.orDie));
|
|
71
|
+
/** Convenience layer from a plain API key and the console's integration API root. */
|
|
72
|
+
export const credentials = (config) => Layer.succeed(Credentials, Effect.succeed({
|
|
73
|
+
apiKey: typeof config.apiKey === "string"
|
|
74
|
+
? Redacted.make(config.apiKey)
|
|
75
|
+
: config.apiKey,
|
|
76
|
+
apiBaseUrl: normalizeBaseUrl(config.apiBaseUrl),
|
|
77
|
+
}));
|
|
78
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAY3D;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAU,EAAE;IACnD,IAAI,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IACzB,OAAO,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,CAAC;IAC5D,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAG7C,CAAC,yBAAyB,CAAC;CAAG;AAEjC,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,uBAAuB,CAAC;IACpD,UAAU,EAAE,YAAY,CAAC,MAAM,CAAC,4BAA4B,CAAC;CAC9D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAC7C,WAAW,EACX,SAAS,CAAC,IAAI,CACZ,MAAM,CAAC,QAAQ,CACb,GAAG,EAAE,CACH,IAAI,WAAW,CAAC;IACd,OAAO,EACL,yFAAyF;CAC5F,CAAC,CACL,EACD,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;IACtC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IAC7B,UAAU,EAAE,gBAAgB,CAAC,UAAU,CAAC;CACzC,CAAC,CAAC,EACH,MAAM,CAAC,KAAK,CACb,CACF,CAAC;AAEF,qFAAqF;AACrF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAG3B,EAA4B,EAAE,CAC7B,KAAK,CAAC,OAAO,CACX,WAAW,EACX,MAAM,CAAC,OAAO,CAAC;IACb,MAAM,EACJ,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;QAC/B,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9B,CAAC,CAAC,MAAM,CAAC,MAAM;IACnB,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC;CAChD,CAAC,CACH,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UniFi Network-specific error types.
|
|
3
|
+
*
|
|
4
|
+
* ⛔ THE SPEC DOCUMENTS ZERO ERROR RESPONSES. Every one of the 73 operations
|
|
5
|
+
* in `network_v10.4.57_openapi.json` declares only its success status (65
|
|
6
|
+
* carry `200`, 8 carry `201`) — there is no per-operation 4xx/5xx, and
|
|
7
|
+
* unlike Hetzner's spec there isn't even a blanket `4xx`/`5xx` wildcard to
|
|
8
|
+
* signal "any of these can happen." So there is nothing for the OpenAPI→
|
|
9
|
+
* Smithy converter to type per operation (see `scripts/convert.ts`'s
|
|
10
|
+
* `statusToErrorClass: {}`), and every generated operation's error channel
|
|
11
|
+
* is the SAME open set below, dispatched purely by HTTP status at runtime
|
|
12
|
+
* (`src/protocol.ts`, `@distilled.cloud/core/errors#HTTP_STATUS_MAP`) —
|
|
13
|
+
* exactly the situation core's shared map exists for, just with less
|
|
14
|
+
* upstream signal than usual to say which statuses are actually reachable.
|
|
15
|
+
*
|
|
16
|
+
* Re-exports the common HTTP errors from core (nothing UniFi-specific to
|
|
17
|
+
* add to the status→class mapping — no documented error envelope shape,
|
|
18
|
+
* either, so `UnknownUnifiNetworkError` below carries the raw body rather
|
|
19
|
+
* than any parsed `code`/`message` pair) plus the unknown-error and
|
|
20
|
+
* parse-error wrappers every package needs.
|
|
21
|
+
*
|
|
22
|
+
* Known unknowns — confirm against a live console before hardening on them:
|
|
23
|
+
* - Exact body shape of a failure (no operation's `responses` gives one).
|
|
24
|
+
* - Whether 429 carries `Retry-After` (assume not; see `src/retry.ts`).
|
|
25
|
+
* - Whether a bad/missing `X-API-KEY` answers 401 or 403 (both are wired
|
|
26
|
+
* through `HTTP_STATUS_MAP`; only one will actually fire).
|
|
27
|
+
*/
|
|
28
|
+
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
29
|
+
import type { BadRequest as CoreBadRequest, Conflict as CoreConflict, DefaultErrors as CoreDefaultErrors, Forbidden as CoreForbidden, NotFound as CoreNotFound, UnprocessableEntity as CoreUnprocessableEntity } from "@distilled.cloud/core/errors";
|
|
30
|
+
import * as Schema from "effect/Schema";
|
|
31
|
+
declare const UnknownUnifiNetworkError_base: Schema.Class<UnknownUnifiNetworkError, Schema.TaggedStruct<"UnknownUnifiNetworkError", {
|
|
32
|
+
readonly code: Schema.optional<Schema.String>;
|
|
33
|
+
readonly message: Schema.optional<Schema.String>;
|
|
34
|
+
readonly body: Schema.Unknown;
|
|
35
|
+
}>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
|
|
36
|
+
"@distilled.cloud/error/categories": {
|
|
37
|
+
ServerError: true;
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Unknown UniFi Network error — returned when a failed response's HTTP
|
|
42
|
+
* status has no mapped error class, OR (given the spec's total silence on
|
|
43
|
+
* error shapes) as the fallback for any status this SDK has not been told
|
|
44
|
+
* about by a real failure yet. Carries the raw body for later cataloging.
|
|
45
|
+
*/
|
|
46
|
+
export declare class UnknownUnifiNetworkError extends UnknownUnifiNetworkError_base {
|
|
47
|
+
}
|
|
48
|
+
declare const UnifiNetworkParseError_base: Schema.Class<UnifiNetworkParseError, Schema.TaggedStruct<"UnifiNetworkParseError", {
|
|
49
|
+
readonly body: Schema.Unknown;
|
|
50
|
+
readonly cause: Schema.Unknown;
|
|
51
|
+
}>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
|
|
52
|
+
"@distilled.cloud/error/categories": {
|
|
53
|
+
ParseError: true;
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
/** Schema parse error wrapper. */
|
|
57
|
+
export declare class UnifiNetworkParseError extends UnifiNetworkParseError_base {
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Errors any UniFi Network operation may surface in addition to the shared
|
|
61
|
+
* HTTP status errors.
|
|
62
|
+
*/
|
|
63
|
+
export type ClientErrors = UnknownUnifiNetworkError | UnifiNetworkParseError;
|
|
64
|
+
/**
|
|
65
|
+
* Default UniFi Network operation errors.
|
|
66
|
+
*
|
|
67
|
+
* EVERY operation carries the whole set — the spec types no failure at all,
|
|
68
|
+
* per-operation or wildcard, so the error channel says a `404` (site or
|
|
69
|
+
* object not found), `400` (a malformed whole-object PUT — see the
|
|
70
|
+
* package README) or `409` is possible on any call rather than pretending
|
|
71
|
+
* only the statuses core marks "default" (401/429/5xx) can happen.
|
|
72
|
+
*/
|
|
73
|
+
export type DefaultErrors = CoreDefaultErrors | CoreBadRequest | CoreForbidden | CoreNotFound | CoreConflict | CoreUnprocessableEntity | ClientErrors;
|
|
74
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,UAAU,IAAI,cAAc,EAC5B,QAAQ,IAAI,YAAY,EACxB,aAAa,IAAI,iBAAiB,EAClC,SAAS,IAAI,aAAa,EAC1B,QAAQ,IAAI,YAAY,EACxB,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;;;;;AAGxC;;;;;GAKG;AACH,qBAAa,wBAAyB,SAAQ,6BAOd;CAAG;;;;;;;;;AAEnC,kCAAkC;AAClC,qBAAa,sBAAuB,SAAQ,2BAMb;CAAG;AAElC;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,wBAAwB,GAAG,sBAAsB,CAAC;AAE7E;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,uBAAuB,GACvB,YAAY,CAAC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UniFi Network-specific error types.
|
|
3
|
+
*
|
|
4
|
+
* ⛔ THE SPEC DOCUMENTS ZERO ERROR RESPONSES. Every one of the 73 operations
|
|
5
|
+
* in `network_v10.4.57_openapi.json` declares only its success status (65
|
|
6
|
+
* carry `200`, 8 carry `201`) — there is no per-operation 4xx/5xx, and
|
|
7
|
+
* unlike Hetzner's spec there isn't even a blanket `4xx`/`5xx` wildcard to
|
|
8
|
+
* signal "any of these can happen." So there is nothing for the OpenAPI→
|
|
9
|
+
* Smithy converter to type per operation (see `scripts/convert.ts`'s
|
|
10
|
+
* `statusToErrorClass: {}`), and every generated operation's error channel
|
|
11
|
+
* is the SAME open set below, dispatched purely by HTTP status at runtime
|
|
12
|
+
* (`src/protocol.ts`, `@distilled.cloud/core/errors#HTTP_STATUS_MAP`) —
|
|
13
|
+
* exactly the situation core's shared map exists for, just with less
|
|
14
|
+
* upstream signal than usual to say which statuses are actually reachable.
|
|
15
|
+
*
|
|
16
|
+
* Re-exports the common HTTP errors from core (nothing UniFi-specific to
|
|
17
|
+
* add to the status→class mapping — no documented error envelope shape,
|
|
18
|
+
* either, so `UnknownUnifiNetworkError` below carries the raw body rather
|
|
19
|
+
* than any parsed `code`/`message` pair) plus the unknown-error and
|
|
20
|
+
* parse-error wrappers every package needs.
|
|
21
|
+
*
|
|
22
|
+
* Known unknowns — confirm against a live console before hardening on them:
|
|
23
|
+
* - Exact body shape of a failure (no operation's `responses` gives one).
|
|
24
|
+
* - Whether 429 carries `Retry-After` (assume not; see `src/retry.ts`).
|
|
25
|
+
* - Whether a bad/missing `X-API-KEY` answers 401 or 403 (both are wired
|
|
26
|
+
* through `HTTP_STATUS_MAP`; only one will actually fire).
|
|
27
|
+
*/
|
|
28
|
+
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
29
|
+
import * as Schema from "effect/Schema";
|
|
30
|
+
import * as Category from "@distilled.cloud/core/category";
|
|
31
|
+
/**
|
|
32
|
+
* Unknown UniFi Network error — returned when a failed response's HTTP
|
|
33
|
+
* status has no mapped error class, OR (given the spec's total silence on
|
|
34
|
+
* error shapes) as the fallback for any status this SDK has not been told
|
|
35
|
+
* about by a real failure yet. Carries the raw body for later cataloging.
|
|
36
|
+
*/
|
|
37
|
+
export class UnknownUnifiNetworkError extends Schema.TaggedError()("UnknownUnifiNetworkError", {
|
|
38
|
+
code: Schema.optional(Schema.String),
|
|
39
|
+
message: Schema.optional(Schema.String),
|
|
40
|
+
body: Schema.Unknown,
|
|
41
|
+
}).pipe(Category.withServerError) {
|
|
42
|
+
}
|
|
43
|
+
/** Schema parse error wrapper. */
|
|
44
|
+
export class UnifiNetworkParseError extends Schema.TaggedError()("UnifiNetworkParseError", {
|
|
45
|
+
body: Schema.Unknown,
|
|
46
|
+
cause: Schema.Unknown,
|
|
47
|
+
}).pipe(Category.withParseError) {
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AAUtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,OAAO,wBAAyB,SAAQ,MAAM,CAAC,WAAW,EAA4B,CAC1F,0BAA0B,EAC1B;IACE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC,OAAO;CACrB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;CAAG;AAEnC,kCAAkC;AAClC,MAAM,OAAO,sBAAuB,SAAQ,MAAM,CAAC,WAAW,EAA0B,CACtF,wBAAwB,EACxB;IACE,IAAI,EAAE,MAAM,CAAC,OAAO;IACpB,KAAK,EAAE,MAAM,CAAC,OAAO;CACtB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;CAAG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @distilled.cloud/unifi-network — UniFi Network Integration API SDK for
|
|
3
|
+
* Effect.
|
|
4
|
+
*
|
|
5
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy models
|
|
6
|
+
* in `.generated-specs` (written by `scripts/convert.ts` from the OpenAPI
|
|
7
|
+
* document at `specs/spec-mirror-unifi-network/specs/openapi.json`).
|
|
8
|
+
* Everything else in this folder is hand-written.
|
|
9
|
+
*
|
|
10
|
+
* One module per UniFi Network API tag (Sites, UniFi Devices, Clients,
|
|
11
|
+
* Networks, WiFi Broadcasts, Hotspot, Firewall, Access Control, Switching,
|
|
12
|
+
* DNS Policies, Traffic Matching Lists, Supporting Resources, Application
|
|
13
|
+
* Info) — the same split the API reference uses.
|
|
14
|
+
*
|
|
15
|
+
* ⛔ READ THE PACKAGE README before writing a Resource against this SDK: it
|
|
16
|
+
* documents traps this SDK does NOT paper over on purpose (whole-object PUT
|
|
17
|
+
* semantics, ordering endpoints, adopt-only objects, hardware-affecting
|
|
18
|
+
* writes) — this package is the API walk-down, not a provider.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import * as UnifiNetwork from "@distilled.cloud/unifi-network";
|
|
23
|
+
*
|
|
24
|
+
* const { data: sites } = yield* UnifiNetwork.Services.sites.getSiteOverviewPage({});
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export * from "./credentials.ts";
|
|
28
|
+
export * from "./errors.ts";
|
|
29
|
+
export * as T from "./traits.ts";
|
|
30
|
+
export { UnifiNetworkProtocol, type UnifiNetworkOpError, type UnifiNetworkOpContext, } from "./protocol.ts";
|
|
31
|
+
export * as Retry from "./retry.ts";
|
|
32
|
+
export * as Services from "./services/index.ts";
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @distilled.cloud/unifi-network — UniFi Network Integration API SDK for
|
|
3
|
+
* Effect.
|
|
4
|
+
*
|
|
5
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy models
|
|
6
|
+
* in `.generated-specs` (written by `scripts/convert.ts` from the OpenAPI
|
|
7
|
+
* document at `specs/spec-mirror-unifi-network/specs/openapi.json`).
|
|
8
|
+
* Everything else in this folder is hand-written.
|
|
9
|
+
*
|
|
10
|
+
* One module per UniFi Network API tag (Sites, UniFi Devices, Clients,
|
|
11
|
+
* Networks, WiFi Broadcasts, Hotspot, Firewall, Access Control, Switching,
|
|
12
|
+
* DNS Policies, Traffic Matching Lists, Supporting Resources, Application
|
|
13
|
+
* Info) — the same split the API reference uses.
|
|
14
|
+
*
|
|
15
|
+
* ⛔ READ THE PACKAGE README before writing a Resource against this SDK: it
|
|
16
|
+
* documents traps this SDK does NOT paper over on purpose (whole-object PUT
|
|
17
|
+
* semantics, ordering endpoints, adopt-only objects, hardware-affecting
|
|
18
|
+
* writes) — this package is the API walk-down, not a provider.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import * as UnifiNetwork from "@distilled.cloud/unifi-network";
|
|
23
|
+
*
|
|
24
|
+
* const { data: sites } = yield* UnifiNetwork.Services.sites.getSiteOverviewPage({});
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export * from "./credentials.js";
|
|
28
|
+
export * from "./errors.js";
|
|
29
|
+
export * as T from "./traits.js";
|
|
30
|
+
export { UnifiNetworkProtocol, } from "./protocol.js";
|
|
31
|
+
export * as Retry from "./retry.js";
|
|
32
|
+
export * as Services from "./services/index.js";
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,oBAAoB,GAGrB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
|