@arbol-ai/sdk 0.0.0-stage → 1.20261017.200040
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 +202 -0
- package/README.md +68 -2
- package/dist/_/codec.d.ts +93 -0
- package/dist/_/codec.js +298 -0
- package/dist/_/error.d.ts +27 -0
- package/dist/_/error.js +68 -0
- package/dist/_/hooks/envelope.d.ts +11 -0
- package/dist/_/hooks/envelope.js +15 -0
- package/dist/_/index.d.ts +3 -0
- package/dist/_/index.js +5 -0
- package/dist/_/transport.d.ts +146 -0
- package/dist/_/transport.js +220 -0
- package/dist/account/apiKeys/client.d.ts +107 -0
- package/dist/account/apiKeys/client.js +43 -0
- package/dist/account/apiKeys/index.d.ts +5 -0
- package/dist/account/apiKeys/index.js +4 -0
- package/dist/account/apiKeys/models.d.ts +42 -0
- package/dist/account/apiKeys/models.js +12 -0
- package/dist/account/billing/client.d.ts +28 -0
- package/dist/account/billing/client.js +18 -0
- package/dist/account/billing/index.d.ts +5 -0
- package/dist/account/billing/index.js +4 -0
- package/dist/account/billing/models.d.ts +42 -0
- package/dist/account/billing/models.js +7 -0
- package/dist/account/billingProfiles/client.d.ts +50 -0
- package/dist/account/billingProfiles/client.js +25 -0
- package/dist/account/billingProfiles/index.d.ts +5 -0
- package/dist/account/billingProfiles/index.js +4 -0
- package/dist/account/billingProfiles/models.d.ts +10 -0
- package/dist/account/billingProfiles/models.js +3 -0
- package/dist/account/client.d.ts +37 -0
- package/dist/account/client.js +75 -0
- package/dist/account/connections/client.d.ts +210 -0
- package/dist/account/connections/client.js +42 -0
- package/dist/account/connections/index.d.ts +5 -0
- package/dist/account/connections/index.js +4 -0
- package/dist/account/connections/models.d.ts +96 -0
- package/dist/account/connections/models.js +3 -0
- package/dist/account/index.d.ts +5 -0
- package/dist/account/index.js +4 -0
- package/dist/account/invitations/client.d.ts +90 -0
- package/dist/account/invitations/client.js +35 -0
- package/dist/account/invitations/index.d.ts +5 -0
- package/dist/account/invitations/index.js +4 -0
- package/dist/account/invitations/models.d.ts +29 -0
- package/dist/account/invitations/models.js +10 -0
- package/dist/account/invoices/client.d.ts +74 -0
- package/dist/account/invoices/client.js +33 -0
- package/dist/account/invoices/index.d.ts +5 -0
- package/dist/account/invoices/index.js +4 -0
- package/dist/account/invoices/models.d.ts +70 -0
- package/dist/account/invoices/models.js +16 -0
- package/dist/account/members/client.d.ts +113 -0
- package/dist/account/members/client.js +42 -0
- package/dist/account/members/index.d.ts +5 -0
- package/dist/account/members/index.js +4 -0
- package/dist/account/members/models.d.ts +35 -0
- package/dist/account/members/models.js +3 -0
- package/dist/account/models.d.ts +267 -0
- package/dist/account/models.js +3 -0
- package/dist/account/organizations/client.d.ts +80 -0
- package/dist/account/organizations/client.js +33 -0
- package/dist/account/organizations/index.d.ts +5 -0
- package/dist/account/organizations/index.js +4 -0
- package/dist/account/organizations/models.d.ts +64 -0
- package/dist/account/organizations/models.js +3 -0
- package/dist/account/payments/client.d.ts +40 -0
- package/dist/account/payments/client.js +19 -0
- package/dist/account/payments/index.d.ts +5 -0
- package/dist/account/payments/index.js +4 -0
- package/dist/account/payments/models.d.ts +37 -0
- package/dist/account/payments/models.js +9 -0
- package/dist/account/permissions/client.d.ts +41 -0
- package/dist/account/permissions/client.js +18 -0
- package/dist/account/permissions/index.d.ts +5 -0
- package/dist/account/permissions/index.js +4 -0
- package/dist/account/permissions/models.d.ts +27 -0
- package/dist/account/permissions/models.js +3 -0
- package/dist/account/roles/client.d.ts +41 -0
- package/dist/account/roles/client.js +18 -0
- package/dist/account/roles/index.d.ts +5 -0
- package/dist/account/roles/index.js +4 -0
- package/dist/account/roles/models.d.ts +31 -0
- package/dist/account/roles/models.js +3 -0
- package/dist/account/usage/client.d.ts +84 -0
- package/dist/account/usage/client.js +26 -0
- package/dist/account/usage/index.d.ts +5 -0
- package/dist/account/usage/index.js +4 -0
- package/dist/account/usage/models.d.ts +25 -0
- package/dist/account/usage/models.js +3 -0
- package/dist/account/walletTransactions/client.d.ts +40 -0
- package/dist/account/walletTransactions/client.js +19 -0
- package/dist/account/walletTransactions/index.d.ts +5 -0
- package/dist/account/walletTransactions/index.js +4 -0
- package/dist/account/walletTransactions/models.d.ts +31 -0
- package/dist/account/walletTransactions/models.js +9 -0
- package/dist/agenda/appointments/client.d.ts +277 -0
- package/dist/agenda/appointments/client.js +53 -0
- package/dist/agenda/appointments/index.d.ts +5 -0
- package/dist/agenda/appointments/index.js +4 -0
- package/dist/agenda/appointments/models.d.ts +17 -0
- package/dist/agenda/appointments/models.js +7 -0
- package/dist/agenda/availability/client.d.ts +140 -0
- package/dist/agenda/availability/client.js +28 -0
- package/dist/agenda/availability/index.d.ts +4 -0
- package/dist/agenda/availability/index.js +4 -0
- package/dist/agenda/bookings/client.d.ts +614 -0
- package/dist/agenda/bookings/client.js +95 -0
- package/dist/agenda/bookings/index.d.ts +5 -0
- package/dist/agenda/bookings/index.js +4 -0
- package/dist/agenda/bookings/models.d.ts +242 -0
- package/dist/agenda/bookings/models.js +12 -0
- package/dist/agenda/client.d.ts +27 -0
- package/dist/agenda/client.js +50 -0
- package/dist/agenda/index.d.ts +5 -0
- package/dist/agenda/index.js +4 -0
- package/dist/agenda/locations/client.d.ts +41 -0
- package/dist/agenda/locations/client.js +19 -0
- package/dist/agenda/locations/index.d.ts +4 -0
- package/dist/agenda/locations/index.js +4 -0
- package/dist/agenda/models.d.ts +1060 -0
- package/dist/agenda/models.js +29 -0
- package/dist/agenda/offerings/client.d.ts +51 -0
- package/dist/agenda/offerings/client.js +19 -0
- package/dist/agenda/offerings/index.d.ts +5 -0
- package/dist/agenda/offerings/index.js +4 -0
- package/dist/agenda/offerings/models.d.ts +102 -0
- package/dist/agenda/offerings/models.js +9 -0
- package/dist/agenda/resources/client.d.ts +50 -0
- package/dist/agenda/resources/client.js +19 -0
- package/dist/agenda/resources/index.d.ts +5 -0
- package/dist/agenda/resources/index.js +4 -0
- package/dist/agenda/resources/models.d.ts +75 -0
- package/dist/agenda/resources/models.js +9 -0
- package/dist/agenda/services/client.d.ts +45 -0
- package/dist/agenda/services/client.js +19 -0
- package/dist/agenda/services/index.d.ts +5 -0
- package/dist/agenda/services/index.js +4 -0
- package/dist/agenda/services/models.d.ts +63 -0
- package/dist/agenda/services/models.js +9 -0
- package/dist/agenda/waitlist/client.d.ts +92 -0
- package/dist/agenda/waitlist/client.js +19 -0
- package/dist/agenda/waitlist/index.d.ts +5 -0
- package/dist/agenda/waitlist/index.js +4 -0
- package/dist/agenda/waitlist/models.d.ts +101 -0
- package/dist/agenda/waitlist/models.js +7 -0
- package/dist/client.d.ts +21 -0
- package/dist/client.js +35 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/models.d.ts +58 -0
- package/dist/models.js +3 -0
- package/dist/raiz/agents/client.d.ts +244 -0
- package/dist/raiz/agents/client.js +45 -0
- package/dist/raiz/agents/index.d.ts +5 -0
- package/dist/raiz/agents/index.js +4 -0
- package/dist/raiz/agents/models.d.ts +285 -0
- package/dist/raiz/agents/models.js +18 -0
- package/dist/raiz/campaigns/client.d.ts +237 -0
- package/dist/raiz/campaigns/client.js +45 -0
- package/dist/raiz/campaigns/index.d.ts +5 -0
- package/dist/raiz/campaigns/index.js +4 -0
- package/dist/raiz/campaigns/models.d.ts +196 -0
- package/dist/raiz/campaigns/models.js +26 -0
- package/dist/raiz/changes/client.d.ts +69 -0
- package/dist/raiz/changes/client.js +19 -0
- package/dist/raiz/changes/index.d.ts +5 -0
- package/dist/raiz/changes/index.js +4 -0
- package/dist/raiz/changes/models.d.ts +54 -0
- package/dist/raiz/changes/models.js +9 -0
- package/dist/raiz/channels/client.d.ts +185 -0
- package/dist/raiz/channels/client.js +45 -0
- package/dist/raiz/channels/index.d.ts +5 -0
- package/dist/raiz/channels/index.js +4 -0
- package/dist/raiz/channels/models.d.ts +499 -0
- package/dist/raiz/channels/models.js +20 -0
- package/dist/raiz/client.d.ts +51 -0
- package/dist/raiz/client.js +110 -0
- package/dist/raiz/contacts/client.d.ts +297 -0
- package/dist/raiz/contacts/client.js +61 -0
- package/dist/raiz/contacts/index.d.ts +5 -0
- package/dist/raiz/contacts/index.js +4 -0
- package/dist/raiz/contacts/models.d.ts +206 -0
- package/dist/raiz/contacts/models.js +29 -0
- package/dist/raiz/conversations/client.d.ts +384 -0
- package/dist/raiz/conversations/client.js +51 -0
- package/dist/raiz/conversations/index.d.ts +5 -0
- package/dist/raiz/conversations/index.js +4 -0
- package/dist/raiz/conversations/models.d.ts +382 -0
- package/dist/raiz/conversations/models.js +41 -0
- package/dist/raiz/definitions/client.d.ts +211 -0
- package/dist/raiz/definitions/client.js +43 -0
- package/dist/raiz/definitions/index.d.ts +5 -0
- package/dist/raiz/definitions/index.js +4 -0
- package/dist/raiz/definitions/models.d.ts +75 -0
- package/dist/raiz/definitions/models.js +10 -0
- package/dist/raiz/evalCases/client.d.ts +83 -0
- package/dist/raiz/evalCases/client.js +27 -0
- package/dist/raiz/evalCases/index.d.ts +5 -0
- package/dist/raiz/evalCases/index.js +4 -0
- package/dist/raiz/evalCases/models.d.ts +57 -0
- package/dist/raiz/evalCases/models.js +10 -0
- package/dist/raiz/evalRuns/client.d.ts +86 -0
- package/dist/raiz/evalRuns/client.js +27 -0
- package/dist/raiz/evalRuns/index.d.ts +5 -0
- package/dist/raiz/evalRuns/index.js +4 -0
- package/dist/raiz/evalRuns/models.d.ts +55 -0
- package/dist/raiz/evalRuns/models.js +9 -0
- package/dist/raiz/facts/client.d.ts +102 -0
- package/dist/raiz/facts/client.js +28 -0
- package/dist/raiz/facts/index.d.ts +4 -0
- package/dist/raiz/facts/index.js +4 -0
- package/dist/raiz/index.d.ts +5 -0
- package/dist/raiz/index.js +4 -0
- package/dist/raiz/knowledge/client.d.ts +234 -0
- package/dist/raiz/knowledge/client.js +53 -0
- package/dist/raiz/knowledge/index.d.ts +5 -0
- package/dist/raiz/knowledge/index.js +4 -0
- package/dist/raiz/knowledge/models.d.ts +163 -0
- package/dist/raiz/knowledge/models.js +19 -0
- package/dist/raiz/members/client.d.ts +101 -0
- package/dist/raiz/members/client.js +35 -0
- package/dist/raiz/members/index.d.ts +5 -0
- package/dist/raiz/members/index.js +4 -0
- package/dist/raiz/members/models.d.ts +48 -0
- package/dist/raiz/members/models.js +10 -0
- package/dist/raiz/models.d.ts +913 -0
- package/dist/raiz/models.js +16 -0
- package/dist/raiz/organization/client.d.ts +116 -0
- package/dist/raiz/organization/client.js +35 -0
- package/dist/raiz/organization/index.d.ts +5 -0
- package/dist/raiz/organization/index.js +4 -0
- package/dist/raiz/organization/models.d.ts +58 -0
- package/dist/raiz/organization/models.js +7 -0
- package/dist/raiz/profiles/client.d.ts +175 -0
- package/dist/raiz/profiles/client.js +43 -0
- package/dist/raiz/profiles/index.d.ts +5 -0
- package/dist/raiz/profiles/index.js +4 -0
- package/dist/raiz/profiles/models.d.ts +90 -0
- package/dist/raiz/profiles/models.js +10 -0
- package/dist/raiz/reports/client.d.ts +71 -0
- package/dist/raiz/reports/client.js +19 -0
- package/dist/raiz/reports/index.d.ts +5 -0
- package/dist/raiz/reports/index.js +4 -0
- package/dist/raiz/reports/models.d.ts +84 -0
- package/dist/raiz/reports/models.js +4 -0
- package/dist/raiz/roles/client.d.ts +42 -0
- package/dist/raiz/roles/client.js +18 -0
- package/dist/raiz/roles/index.d.ts +5 -0
- package/dist/raiz/roles/index.js +4 -0
- package/dist/raiz/roles/models.d.ts +32 -0
- package/dist/raiz/roles/models.js +3 -0
- package/dist/raiz/suppressions/client.d.ts +90 -0
- package/dist/raiz/suppressions/client.js +27 -0
- package/dist/raiz/suppressions/index.d.ts +5 -0
- package/dist/raiz/suppressions/index.js +4 -0
- package/dist/raiz/suppressions/models.d.ts +33 -0
- package/dist/raiz/suppressions/models.js +9 -0
- package/dist/raiz/tasks/client.d.ts +116 -0
- package/dist/raiz/tasks/client.js +44 -0
- package/dist/raiz/tasks/index.d.ts +5 -0
- package/dist/raiz/tasks/index.js +4 -0
- package/dist/raiz/tasks/models.d.ts +17 -0
- package/dist/raiz/tasks/models.js +7 -0
- package/dist/raiz/templates/client.d.ts +140 -0
- package/dist/raiz/templates/client.js +27 -0
- package/dist/raiz/templates/index.d.ts +5 -0
- package/dist/raiz/templates/index.js +4 -0
- package/dist/raiz/templates/models.d.ts +55 -0
- package/dist/raiz/templates/models.js +3 -0
- package/dist/raiz/voices/client.d.ts +52 -0
- package/dist/raiz/voices/client.js +18 -0
- package/dist/raiz/voices/index.d.ts +5 -0
- package/dist/raiz/voices/index.js +4 -0
- package/dist/raiz/voices/models.d.ts +40 -0
- package/dist/raiz/voices/models.js +3 -0
- package/dist/sura/affiliations/client.d.ts +48 -0
- package/dist/sura/affiliations/client.js +19 -0
- package/dist/sura/affiliations/index.d.ts +4 -0
- package/dist/sura/affiliations/index.js +4 -0
- package/dist/sura/appointments/client.d.ts +323 -0
- package/dist/sura/appointments/client.js +43 -0
- package/dist/sura/appointments/index.d.ts +4 -0
- package/dist/sura/appointments/index.js +4 -0
- package/dist/sura/authorizations/client.d.ts +58 -0
- package/dist/sura/authorizations/client.js +19 -0
- package/dist/sura/authorizations/index.d.ts +4 -0
- package/dist/sura/authorizations/index.js +4 -0
- package/dist/sura/availability/client.d.ts +79 -0
- package/dist/sura/availability/client.js +19 -0
- package/dist/sura/availability/index.d.ts +4 -0
- package/dist/sura/availability/index.js +4 -0
- package/dist/sura/client.d.ts +29 -0
- package/dist/sura/client.js +55 -0
- package/dist/sura/connections/client.d.ts +157 -0
- package/dist/sura/connections/client.js +42 -0
- package/dist/sura/connections/index.d.ts +5 -0
- package/dist/sura/connections/index.js +4 -0
- package/dist/sura/connections/models.d.ts +106 -0
- package/dist/sura/connections/models.js +12 -0
- package/dist/sura/copays/client.d.ts +53 -0
- package/dist/sura/copays/client.js +19 -0
- package/dist/sura/copays/index.d.ts +4 -0
- package/dist/sura/copays/index.js +4 -0
- package/dist/sura/index.d.ts +5 -0
- package/dist/sura/index.js +4 -0
- package/dist/sura/models.d.ts +594 -0
- package/dist/sura/models.js +51 -0
- package/dist/sura/operations/client.d.ts +47 -0
- package/dist/sura/operations/client.js +19 -0
- package/dist/sura/operations/index.d.ts +4 -0
- package/dist/sura/operations/index.js +4 -0
- package/dist/sura/patients/client.d.ts +59 -0
- package/dist/sura/patients/client.js +19 -0
- package/dist/sura/patients/index.d.ts +4 -0
- package/dist/sura/patients/index.js +4 -0
- package/dist/sura/services/client.d.ts +67 -0
- package/dist/sura/services/client.js +19 -0
- package/dist/sura/services/index.d.ts +4 -0
- package/dist/sura/services/index.js +4 -0
- package/dist/visoft/agencies/client.d.ts +58 -0
- package/dist/visoft/agencies/client.js +18 -0
- package/dist/visoft/agencies/index.d.ts +5 -0
- package/dist/visoft/agencies/index.js +4 -0
- package/dist/visoft/agencies/models.d.ts +29 -0
- package/dist/visoft/agencies/models.js +3 -0
- package/dist/visoft/appointments/client.d.ts +215 -0
- package/dist/visoft/appointments/client.js +26 -0
- package/dist/visoft/appointments/index.d.ts +4 -0
- package/dist/visoft/appointments/index.js +4 -0
- package/dist/visoft/availability/client.d.ts +178 -0
- package/dist/visoft/availability/client.js +19 -0
- package/dist/visoft/availability/index.d.ts +5 -0
- package/dist/visoft/availability/index.js +4 -0
- package/dist/visoft/availability/models.d.ts +74 -0
- package/dist/visoft/availability/models.js +9 -0
- package/dist/visoft/client.d.ts +33 -0
- package/dist/visoft/client.js +65 -0
- package/dist/visoft/clinics/client.d.ts +66 -0
- package/dist/visoft/clinics/client.js +25 -0
- package/dist/visoft/clinics/index.d.ts +5 -0
- package/dist/visoft/clinics/index.js +4 -0
- package/dist/visoft/clinics/models.d.ts +39 -0
- package/dist/visoft/clinics/models.js +3 -0
- package/dist/visoft/connections/client.d.ts +145 -0
- package/dist/visoft/connections/client.js +42 -0
- package/dist/visoft/connections/index.d.ts +5 -0
- package/dist/visoft/connections/index.js +4 -0
- package/dist/visoft/connections/models.d.ts +69 -0
- package/dist/visoft/connections/models.js +11 -0
- package/dist/visoft/contracts/client.d.ts +87 -0
- package/dist/visoft/contracts/client.js +18 -0
- package/dist/visoft/contracts/index.d.ts +5 -0
- package/dist/visoft/contracts/index.js +4 -0
- package/dist/visoft/contracts/models.d.ts +31 -0
- package/dist/visoft/contracts/models.js +3 -0
- package/dist/visoft/groups/client.d.ts +69 -0
- package/dist/visoft/groups/client.js +18 -0
- package/dist/visoft/groups/index.d.ts +5 -0
- package/dist/visoft/groups/index.js +4 -0
- package/dist/visoft/groups/models.d.ts +39 -0
- package/dist/visoft/groups/models.js +3 -0
- package/dist/visoft/index.d.ts +5 -0
- package/dist/visoft/index.js +4 -0
- package/dist/visoft/models.d.ts +142 -0
- package/dist/visoft/models.js +3 -0
- package/dist/visoft/patients/client.d.ts +285 -0
- package/dist/visoft/patients/client.js +34 -0
- package/dist/visoft/patients/index.d.ts +4 -0
- package/dist/visoft/patients/index.js +4 -0
- package/dist/visoft/services/client.d.ts +99 -0
- package/dist/visoft/services/client.js +18 -0
- package/dist/visoft/services/index.d.ts +5 -0
- package/dist/visoft/services/index.js +4 -0
- package/dist/visoft/services/models.d.ts +29 -0
- package/dist/visoft/services/models.js +3 -0
- package/dist/visoft/specialtyRules/client.d.ts +50 -0
- package/dist/visoft/specialtyRules/client.js +18 -0
- package/dist/visoft/specialtyRules/index.d.ts +4 -0
- package/dist/visoft/specialtyRules/index.js +4 -0
- package/dist/visoft/tools/client.d.ts +57 -0
- package/dist/visoft/tools/client.js +18 -0
- package/dist/visoft/tools/index.d.ts +5 -0
- package/dist/visoft/tools/index.js +4 -0
- package/dist/visoft/tools/models.d.ts +37 -0
- package/dist/visoft/tools/models.js +3 -0
- package/package.json +48 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @arbol-ai/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Arbol API for TypeScript and JavaScript, generated by
|
|
4
|
+
[Cloudflare Forge](https://github.com/cloudflare/forge) from the platform's public OpenAPI,
|
|
5
|
+
[`https://api.getarbol.com/openapi.json`](https://api.getarbol.com/openapi.json). Everything in `src/`
|
|
6
|
+
is Forge's TypeScript output, unedited, and the package's version is the API release it was generated
|
|
7
|
+
from (`1.YYYYMMDD.n`).
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @arbol-ai/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { ApiError, createClient } from '@arbol-ai/sdk';
|
|
15
|
+
|
|
16
|
+
const arbol = createClient({ baseUrl: 'https://api.getarbol.com', token });
|
|
17
|
+
|
|
18
|
+
const { data } = await arbol.agenda.appointments.get({ id: 'apt_…' });
|
|
19
|
+
data.startsAt; // Temporal.Instant
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Every operation is `client.<service>.<resource>.<verb>(request, options?)`, with its request and
|
|
23
|
+
response types beside it (`agenda/appointments`: `GetRequest`, `GetResponse`, …).
|
|
24
|
+
|
|
25
|
+
## Credentials
|
|
26
|
+
|
|
27
|
+
`token` is sent as `Authorization: Bearer <token>`. It is one of:
|
|
28
|
+
|
|
29
|
+
- an Arbol API key, created in Arbol Account. Keep it in a secret manager and never ship it to a
|
|
30
|
+
browser;
|
|
31
|
+
- an access token for the audience `https://api.getarbol.com`, from any OAuth client, such as a
|
|
32
|
+
person's session in your app.
|
|
33
|
+
|
|
34
|
+
The SDK holds no OAuth logic: sign people in however your application does, and create a client with
|
|
35
|
+
the token you have.
|
|
36
|
+
|
|
37
|
+
## Responses and errors
|
|
38
|
+
|
|
39
|
+
A method resolves with the response the API declares: `{ success: true, data, error: null, metadata }`.
|
|
40
|
+
Any other status throws `ApiError`, with `status`, the `response`, and its declared body in `details`
|
|
41
|
+
(`{ success: false, error: { code, message, retryable, data }, metadata }`).
|
|
42
|
+
|
|
43
|
+
Each call sends one request and is never retried. Pass `fetch` to send requests through your own
|
|
44
|
+
function, `headers` or `query` to add to every request, and `signal` to abort a call.
|
|
45
|
+
|
|
46
|
+
The server authorizes every call: a method in the client is not a grant.
|
|
47
|
+
|
|
48
|
+
## Requirements
|
|
49
|
+
|
|
50
|
+
`date-time` fields are `Temporal.Instant` and `date` fields `Temporal.PlainDate`, so the runtime needs
|
|
51
|
+
`fetch` and `Temporal` (Node.js 26, Bun 1.4, current browsers), and TypeScript needs `"lib": ["ESNext"]`.
|
|
52
|
+
|
|
53
|
+
## Development
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
bun install
|
|
57
|
+
bun run forge # build the pinned Cloudflare Forge with cargo into .forge/ (once; needs Rust)
|
|
58
|
+
bun run openapi # download https://api.getarbol.com/openapi.json
|
|
59
|
+
bun run generate # src/ from openapi.json with `forge --target ts`; the version from its info.version
|
|
60
|
+
bun run verify # typecheck and build dist/
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`openapi.json` is downloaded at generation time and not committed; `package.json`'s version is the
|
|
64
|
+
OpenAPI version `src/` was generated from. Forge is pinned to its commit
|
|
65
|
+
`7f86447210b7bea3779bfdab3cd5655eade0eadb` (0.1.0) in the `forge` script.
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
[Apache License 2.0](LICENSE)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A codec converts a value between its wire form, as JSON has it, and its
|
|
3
|
+
* TypeScript form. A value whose shape does not match the codec is kept as
|
|
4
|
+
* it is.
|
|
5
|
+
*/
|
|
6
|
+
export interface Codec {
|
|
7
|
+
/**
|
|
8
|
+
* Converts a wire value. `source` is the source text of a number whose
|
|
9
|
+
* value JSON.parse could not hold exactly.
|
|
10
|
+
*/
|
|
11
|
+
decode(value: unknown, source?: string): unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Converts a TypeScript value to its wire form.
|
|
14
|
+
*/
|
|
15
|
+
encode(value: unknown): unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A codec, or a function that returns one, so codecs can form cycles.
|
|
19
|
+
*/
|
|
20
|
+
export type CodecRef = Codec | (() => Codec);
|
|
21
|
+
/**
|
|
22
|
+
* An entry of an object codec: the wire name of a key, its field name when
|
|
23
|
+
* it is renamed, and the codec of its value when the value is converted.
|
|
24
|
+
*/
|
|
25
|
+
export type Entry = readonly [wire: string, field: string] | readonly [wire: string, field: string | null, codec: CodecRef];
|
|
26
|
+
type Record = {
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Reports whether value is a plain object, as JSON.parse creates them.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isRecord(value: unknown): value is Record;
|
|
33
|
+
/**
|
|
34
|
+
* Sets a key of a new object, including one named `__proto__`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function set(target: Record, key: string, value: unknown): void;
|
|
37
|
+
/**
|
|
38
|
+
* Parses JSON, and keeps the source text of integers too large for a number,
|
|
39
|
+
* so that `int64` decodes them exactly.
|
|
40
|
+
*/
|
|
41
|
+
export declare function parse(text: string): unknown;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the codec of an object, with an entry for each key that is renamed
|
|
44
|
+
* or whose value is converted. Other keys are kept as they are.
|
|
45
|
+
*/
|
|
46
|
+
export declare function object(entries: readonly Entry[]): Codec;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the codec of an array, which converts its items.
|
|
49
|
+
*/
|
|
50
|
+
export declare function array(items: CodecRef): Codec;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the codec of a map, which converts its values and keeps its keys.
|
|
53
|
+
*/
|
|
54
|
+
export declare function map(values: CodecRef): Codec;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the codec of a union. Each member's codec converts the parts of
|
|
57
|
+
* the value it knows, and keeps the rest.
|
|
58
|
+
*/
|
|
59
|
+
export declare function union(members: readonly CodecRef[]): Codec;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the codec of an intersection, which converts the value with the
|
|
62
|
+
* codec of each member.
|
|
63
|
+
*/
|
|
64
|
+
export declare function intersection(members: readonly CodecRef[]): Codec;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the codec of a union that a property discriminates: the codec of
|
|
67
|
+
* the member that the property's value names. `wire` and `field` are the
|
|
68
|
+
* property's names, with `field` null when it is not renamed.
|
|
69
|
+
*/
|
|
70
|
+
export declare function discriminated(wire: string, field: string | null, cases: {
|
|
71
|
+
readonly [value: string]: CodecRef;
|
|
72
|
+
}): Codec;
|
|
73
|
+
/**
|
|
74
|
+
* Converts a `date-time` string and a Temporal.Instant.
|
|
75
|
+
*/
|
|
76
|
+
export declare const instant: Codec;
|
|
77
|
+
/**
|
|
78
|
+
* Converts a `date` string and a Temporal.PlainDate.
|
|
79
|
+
*/
|
|
80
|
+
export declare const date: Codec;
|
|
81
|
+
/**
|
|
82
|
+
* Returns the base64 encoding of bytes.
|
|
83
|
+
*/
|
|
84
|
+
export declare function toBase64(bytes: Uint8Array): string;
|
|
85
|
+
/**
|
|
86
|
+
* Converts a `byte` string, in base64, and a Uint8Array.
|
|
87
|
+
*/
|
|
88
|
+
export declare const bytes: Codec;
|
|
89
|
+
/**
|
|
90
|
+
* Converts an `int64` number and a bigint, without losing digits.
|
|
91
|
+
*/
|
|
92
|
+
export declare const int64: Codec;
|
|
93
|
+
export {};
|
package/dist/_/codec.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// Code generated by forge. DO NOT EDIT.
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
function resolve(ref) {
|
|
4
|
+
return typeof ref === 'function' ? ref() : ref;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Reports whether value is a plain object, as JSON.parse creates them.
|
|
8
|
+
*/
|
|
9
|
+
export function isRecord(value) {
|
|
10
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const proto = Object.getPrototypeOf(value);
|
|
14
|
+
return proto === Object.prototype || proto === null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Sets a key of a new object, including one named `__proto__`.
|
|
18
|
+
*/
|
|
19
|
+
export function set(target, key, value) {
|
|
20
|
+
if (key === '__proto__') {
|
|
21
|
+
Object.defineProperty(target, key, {
|
|
22
|
+
value,
|
|
23
|
+
enumerable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
target[key] = value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// The source text of the numbers that JSON.parse could not hold exactly, by
|
|
33
|
+
// the object or array they are in and their key.
|
|
34
|
+
const sources = new WeakMap();
|
|
35
|
+
function sourceOf(holder, key) {
|
|
36
|
+
return sources.get(holder)?.get(key);
|
|
37
|
+
}
|
|
38
|
+
const recordSource = function (key, value, context) {
|
|
39
|
+
const source = context?.source;
|
|
40
|
+
if (typeof value === 'number' && !Number.isSafeInteger(value) && source !== undefined && /^-?\d+$/.test(source)) {
|
|
41
|
+
const holder = this;
|
|
42
|
+
let keys = sources.get(holder);
|
|
43
|
+
if (keys === undefined) {
|
|
44
|
+
keys = new Map();
|
|
45
|
+
sources.set(holder, keys);
|
|
46
|
+
}
|
|
47
|
+
keys.set(key, source);
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
};
|
|
51
|
+
const parseWithReviver = JSON.parse;
|
|
52
|
+
/**
|
|
53
|
+
* Parses JSON, and keeps the source text of integers too large for a number,
|
|
54
|
+
* so that `int64` decodes them exactly.
|
|
55
|
+
*/
|
|
56
|
+
export function parse(text) {
|
|
57
|
+
// An integer that a number cannot hold has at least 16 digits.
|
|
58
|
+
if (!/\d{16}/.test(text)) {
|
|
59
|
+
return JSON.parse(text);
|
|
60
|
+
}
|
|
61
|
+
return parseWithReviver(text, recordSource);
|
|
62
|
+
}
|
|
63
|
+
class ObjectCodec {
|
|
64
|
+
#entries;
|
|
65
|
+
#decodeTable;
|
|
66
|
+
#encodeTable;
|
|
67
|
+
constructor(entries) {
|
|
68
|
+
this.#entries = entries;
|
|
69
|
+
}
|
|
70
|
+
#table(decode) {
|
|
71
|
+
const table = new Map();
|
|
72
|
+
for (const [wire, field, codec] of this.#entries) {
|
|
73
|
+
const resolved = codec === undefined ? undefined : resolve(codec);
|
|
74
|
+
if (decode) {
|
|
75
|
+
table.set(wire, [field ?? wire, resolved]);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
table.set(field ?? wire, [wire, resolved]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return table;
|
|
82
|
+
}
|
|
83
|
+
decode(value) {
|
|
84
|
+
if (!isRecord(value)) {
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
this.#decodeTable ??= this.#table(true);
|
|
88
|
+
return convert(value, this.#decodeTable, true);
|
|
89
|
+
}
|
|
90
|
+
encode(value) {
|
|
91
|
+
if (!isRecord(value)) {
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
this.#encodeTable ??= this.#table(false);
|
|
95
|
+
return convert(value, this.#encodeTable, false);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function convert(value, table, decode) {
|
|
99
|
+
const out = {};
|
|
100
|
+
for (const key of Object.keys(value)) {
|
|
101
|
+
const item = value[key];
|
|
102
|
+
const entry = table.get(key);
|
|
103
|
+
if (entry === undefined) {
|
|
104
|
+
set(out, key, item);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const [name, codec] = entry;
|
|
108
|
+
if (codec === undefined || item === undefined || item === null) {
|
|
109
|
+
set(out, name, item);
|
|
110
|
+
}
|
|
111
|
+
else if (decode) {
|
|
112
|
+
set(out, name, codec.decode(item, sourceOf(value, key)));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
set(out, name, codec.encode(item));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns the codec of an object, with an entry for each key that is renamed
|
|
122
|
+
* or whose value is converted. Other keys are kept as they are.
|
|
123
|
+
*/
|
|
124
|
+
export function object(entries) {
|
|
125
|
+
return new ObjectCodec(entries);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Returns the codec of an array, which converts its items.
|
|
129
|
+
*/
|
|
130
|
+
export function array(items) {
|
|
131
|
+
return {
|
|
132
|
+
decode(value) {
|
|
133
|
+
if (!Array.isArray(value)) {
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
const codec = resolve(items);
|
|
137
|
+
return value.map((item, i) => (item === null ? item : codec.decode(item, sourceOf(value, String(i)))));
|
|
138
|
+
},
|
|
139
|
+
encode(value) {
|
|
140
|
+
if (!Array.isArray(value)) {
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
const codec = resolve(items);
|
|
144
|
+
return value.map((item) => (item === null || item === undefined ? item : codec.encode(item)));
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Returns the codec of a map, which converts its values and keeps its keys.
|
|
150
|
+
*/
|
|
151
|
+
export function map(values) {
|
|
152
|
+
return {
|
|
153
|
+
decode(value) {
|
|
154
|
+
if (!isRecord(value)) {
|
|
155
|
+
return value;
|
|
156
|
+
}
|
|
157
|
+
const codec = resolve(values);
|
|
158
|
+
const out = {};
|
|
159
|
+
for (const key of Object.keys(value)) {
|
|
160
|
+
const item = value[key];
|
|
161
|
+
set(out, key, item === null ? item : codec.decode(item, sourceOf(value, key)));
|
|
162
|
+
}
|
|
163
|
+
return out;
|
|
164
|
+
},
|
|
165
|
+
encode(value) {
|
|
166
|
+
if (!isRecord(value)) {
|
|
167
|
+
return value;
|
|
168
|
+
}
|
|
169
|
+
const codec = resolve(values);
|
|
170
|
+
const out = {};
|
|
171
|
+
for (const key of Object.keys(value)) {
|
|
172
|
+
const item = value[key];
|
|
173
|
+
set(out, key, item === null || item === undefined ? item : codec.encode(item));
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function every(members) {
|
|
180
|
+
return {
|
|
181
|
+
decode(value, source) {
|
|
182
|
+
for (const member of members) {
|
|
183
|
+
value = resolve(member).decode(value, source);
|
|
184
|
+
}
|
|
185
|
+
return value;
|
|
186
|
+
},
|
|
187
|
+
encode(value) {
|
|
188
|
+
for (const member of members) {
|
|
189
|
+
value = resolve(member).encode(value);
|
|
190
|
+
}
|
|
191
|
+
return value;
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Returns the codec of a union. Each member's codec converts the parts of
|
|
197
|
+
* the value it knows, and keeps the rest.
|
|
198
|
+
*/
|
|
199
|
+
export function union(members) {
|
|
200
|
+
return every(members);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Returns the codec of an intersection, which converts the value with the
|
|
204
|
+
* codec of each member.
|
|
205
|
+
*/
|
|
206
|
+
export function intersection(members) {
|
|
207
|
+
return every(members);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Returns the codec of a union that a property discriminates: the codec of
|
|
211
|
+
* the member that the property's value names. `wire` and `field` are the
|
|
212
|
+
* property's names, with `field` null when it is not renamed.
|
|
213
|
+
*/
|
|
214
|
+
export function discriminated(wire, field, cases) {
|
|
215
|
+
const pick = (value) => {
|
|
216
|
+
const key = String(value);
|
|
217
|
+
return Object.hasOwn(cases, key) ? resolve(cases[key]) : undefined;
|
|
218
|
+
};
|
|
219
|
+
return {
|
|
220
|
+
decode(value, source) {
|
|
221
|
+
if (!isRecord(value)) {
|
|
222
|
+
return value;
|
|
223
|
+
}
|
|
224
|
+
const codec = pick(value[wire]);
|
|
225
|
+
return codec === undefined ? value : codec.decode(value, source);
|
|
226
|
+
},
|
|
227
|
+
encode(value) {
|
|
228
|
+
if (!isRecord(value)) {
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
231
|
+
const codec = pick(value[field ?? wire]);
|
|
232
|
+
return codec === undefined ? value : codec.encode(value);
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
// attempt returns the result of fn, or fallback when the value is not in the
|
|
237
|
+
// form fn expects. A missing global, such as Temporal, is still thrown.
|
|
238
|
+
function attempt(fn, fallback) {
|
|
239
|
+
try {
|
|
240
|
+
return fn();
|
|
241
|
+
}
|
|
242
|
+
catch (e) {
|
|
243
|
+
if (e instanceof ReferenceError) {
|
|
244
|
+
throw e;
|
|
245
|
+
}
|
|
246
|
+
return fallback;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function toText(value) {
|
|
250
|
+
return typeof value === 'object' && value !== null ? String(value) : value;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Converts a `date-time` string and a Temporal.Instant.
|
|
254
|
+
*/
|
|
255
|
+
export const instant = {
|
|
256
|
+
decode: (value) => (typeof value === 'string' ? attempt(() => Temporal.Instant.from(value), value) : value),
|
|
257
|
+
encode: toText,
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* Converts a `date` string and a Temporal.PlainDate.
|
|
261
|
+
*/
|
|
262
|
+
export const date = {
|
|
263
|
+
decode: (value) => (typeof value === 'string' ? attempt(() => Temporal.PlainDate.from(value), value) : value),
|
|
264
|
+
encode: toText,
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Returns the base64 encoding of bytes.
|
|
268
|
+
*/
|
|
269
|
+
export function toBase64(bytes) {
|
|
270
|
+
let binary = '';
|
|
271
|
+
for (let i = 0; i < bytes.length; i += 0x8000) {
|
|
272
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));
|
|
273
|
+
}
|
|
274
|
+
return btoa(binary);
|
|
275
|
+
}
|
|
276
|
+
function fromBase64(text) {
|
|
277
|
+
const binary = atob(text);
|
|
278
|
+
const bytes = new Uint8Array(binary.length);
|
|
279
|
+
for (let i = 0; i < binary.length; i++) {
|
|
280
|
+
bytes[i] = binary.charCodeAt(i);
|
|
281
|
+
}
|
|
282
|
+
return bytes;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Converts a `byte` string, in base64, and a Uint8Array.
|
|
286
|
+
*/
|
|
287
|
+
export const bytes = {
|
|
288
|
+
decode: (value) => (typeof value === 'string' ? attempt(() => fromBase64(value), value) : value),
|
|
289
|
+
encode: (value) => (value instanceof Uint8Array ? toBase64(value) : value),
|
|
290
|
+
};
|
|
291
|
+
const rawJSON = JSON.rawJSON;
|
|
292
|
+
/**
|
|
293
|
+
* Converts an `int64` number and a bigint, without losing digits.
|
|
294
|
+
*/
|
|
295
|
+
export const int64 = {
|
|
296
|
+
decode: (value, source) => (typeof value === 'number' && Number.isInteger(value) ? BigInt(source ?? value) : value),
|
|
297
|
+
encode: (value) => (typeof value === 'bigint' ? rawJSON(value.toString()) : value),
|
|
298
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error response from the API, or a success response whose body is not
|
|
3
|
+
* valid JSON.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ApiError extends Error {
|
|
6
|
+
/**
|
|
7
|
+
* The status of the response.
|
|
8
|
+
*/
|
|
9
|
+
readonly status: number;
|
|
10
|
+
/**
|
|
11
|
+
* The response, whose body has been read.
|
|
12
|
+
*/
|
|
13
|
+
readonly response: Response;
|
|
14
|
+
/**
|
|
15
|
+
* The body decoded as the error the API declares for the status, or the
|
|
16
|
+
* body as text when it declares none or the body does not parse, or
|
|
17
|
+
* undefined when the body is empty.
|
|
18
|
+
*/
|
|
19
|
+
readonly details: unknown;
|
|
20
|
+
constructor(message: string, response: Response, details: unknown, options?: ErrorOptions);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the message of a JSON error body: a string `message`, `error`,
|
|
24
|
+
* `detail` or `title`, then `error.message` or `error.detail`, then the
|
|
25
|
+
* messages of an `errors` array.
|
|
26
|
+
*/
|
|
27
|
+
export declare function errorMessage(body: unknown): string | undefined;
|