@distilled.cloud/core 0.30.3 → 1.0.0-rc.10
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/lib/api.d.ts +165 -0
- package/lib/api.d.ts.map +1 -0
- package/lib/api.js +190 -0
- package/lib/api.js.map +1 -0
- package/lib/category.d.ts +4 -4
- package/lib/category.js +4 -4
- package/lib/codegen/boolean-string-enums.d.ts +36 -0
- package/lib/codegen/boolean-string-enums.d.ts.map +1 -0
- package/lib/codegen/boolean-string-enums.js +94 -0
- package/lib/codegen/boolean-string-enums.js.map +1 -0
- package/lib/codegen/boolean-string-enums.test.d.ts +2 -0
- package/lib/codegen/boolean-string-enums.test.d.ts.map +1 -0
- package/lib/codegen/boolean-string-enums.test.js +147 -0
- package/lib/codegen/boolean-string-enums.test.js.map +1 -0
- package/lib/codegen/cli.d.ts +79 -0
- package/lib/codegen/cli.d.ts.map +1 -0
- package/lib/codegen/cli.js +149 -0
- package/lib/codegen/cli.js.map +1 -0
- package/lib/codegen/emit.d.ts +125 -0
- package/lib/codegen/emit.d.ts.map +1 -0
- package/lib/codegen/emit.js +101 -0
- package/lib/codegen/emit.js.map +1 -0
- package/lib/codegen/format.d.ts +23 -0
- package/lib/codegen/format.d.ts.map +1 -0
- package/lib/codegen/format.js +28 -0
- package/lib/codegen/format.js.map +1 -0
- package/lib/codegen/generator.d.ts +334 -0
- package/lib/codegen/generator.d.ts.map +1 -0
- package/lib/codegen/generator.js +813 -0
- package/lib/codegen/generator.js.map +1 -0
- package/lib/codegen/graph.d.ts +36 -0
- package/lib/codegen/graph.d.ts.map +1 -0
- package/lib/codegen/graph.js +136 -0
- package/lib/codegen/graph.js.map +1 -0
- package/lib/codegen/graphql-client.d.ts +62 -0
- package/lib/codegen/graphql-client.d.ts.map +1 -0
- package/lib/codegen/graphql-client.js +294 -0
- package/lib/codegen/graphql-client.js.map +1 -0
- package/lib/codegen/graphql-client.test.d.ts +2 -0
- package/lib/codegen/graphql-client.test.d.ts.map +1 -0
- package/lib/codegen/graphql-client.test.js +311 -0
- package/lib/codegen/graphql-client.test.js.map +1 -0
- package/lib/codegen/graphql.d.ts +207 -0
- package/lib/codegen/graphql.d.ts.map +1 -0
- package/lib/codegen/graphql.js +799 -0
- package/lib/codegen/graphql.js.map +1 -0
- package/lib/codegen/members.d.ts +25 -0
- package/lib/codegen/members.d.ts.map +1 -0
- package/lib/codegen/members.js +55 -0
- package/lib/codegen/members.js.map +1 -0
- package/lib/codegen/naming.d.ts +29 -0
- package/lib/codegen/naming.d.ts.map +1 -0
- package/lib/codegen/naming.js +74 -0
- package/lib/codegen/naming.js.map +1 -0
- package/lib/codegen/openapi-cli.d.ts +52 -0
- package/lib/codegen/openapi-cli.d.ts.map +1 -0
- package/lib/codegen/openapi-cli.js +109 -0
- package/lib/codegen/openapi-cli.js.map +1 -0
- package/lib/codegen/openapi.d.ts +178 -0
- package/lib/codegen/openapi.d.ts.map +1 -0
- package/lib/codegen/openapi.js +1377 -0
- package/lib/codegen/openapi.js.map +1 -0
- package/lib/codegen/operations.d.ts +24 -0
- package/lib/codegen/operations.d.ts.map +1 -0
- package/lib/codegen/operations.js +56 -0
- package/lib/codegen/operations.js.map +1 -0
- package/lib/codegen/pagination.d.ts +39 -0
- package/lib/codegen/pagination.d.ts.map +1 -0
- package/lib/codegen/pagination.js +33 -0
- package/lib/codegen/pagination.js.map +1 -0
- package/lib/codegen/patches.d.ts +65 -0
- package/lib/codegen/patches.d.ts.map +1 -0
- package/lib/codegen/patches.js +236 -0
- package/lib/codegen/patches.js.map +1 -0
- package/lib/codegen/patches.test.d.ts +2 -0
- package/lib/codegen/patches.test.d.ts.map +1 -0
- package/lib/codegen/patches.test.js +105 -0
- package/lib/codegen/patches.test.js.map +1 -0
- package/lib/codegen/prelude.d.ts +15 -0
- package/lib/codegen/prelude.d.ts.map +1 -0
- package/lib/codegen/prelude.js +60 -0
- package/lib/codegen/prelude.js.map +1 -0
- package/lib/codegen/proto.d.ts +121 -0
- package/lib/codegen/proto.d.ts.map +1 -0
- package/lib/codegen/proto.js +962 -0
- package/lib/codegen/proto.js.map +1 -0
- package/lib/codegen/rewrite-operation-ids.d.ts +131 -0
- package/lib/codegen/rewrite-operation-ids.d.ts.map +1 -0
- package/lib/codegen/rewrite-operation-ids.js +1079 -0
- package/lib/codegen/rewrite-operation-ids.js.map +1 -0
- package/lib/codegen/rewrite-operation-ids.test.d.ts +2 -0
- package/lib/codegen/rewrite-operation-ids.test.d.ts.map +1 -0
- package/lib/codegen/rewrite-operation-ids.test.js +533 -0
- package/lib/codegen/rewrite-operation-ids.test.js.map +1 -0
- package/lib/codegen/spec-path.d.ts +16 -0
- package/lib/codegen/spec-path.d.ts.map +1 -0
- package/lib/codegen/spec-path.js +101 -0
- package/lib/codegen/spec-path.js.map +1 -0
- package/lib/error-category.d.ts +28 -0
- package/lib/error-category.d.ts.map +1 -0
- package/lib/error-category.js +46 -0
- package/lib/error-category.js.map +1 -0
- package/lib/errors.d.ts +1 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +18 -13
- package/lib/errors.js.map +1 -1
- package/lib/graphql.d.ts +284 -0
- package/lib/graphql.d.ts.map +1 -0
- package/lib/graphql.fixture.d.ts +249 -0
- package/lib/graphql.fixture.d.ts.map +1 -0
- package/lib/graphql.fixture.js +240 -0
- package/lib/graphql.fixture.js.map +1 -0
- package/lib/graphql.js +718 -0
- package/lib/graphql.js.map +1 -0
- package/lib/graphql.test.d.ts +2 -0
- package/lib/graphql.test.d.ts.map +1 -0
- package/lib/graphql.test.js +780 -0
- package/lib/graphql.test.js.map +1 -0
- package/lib/graphql.types.d.ts +2 -0
- package/lib/graphql.types.d.ts.map +1 -0
- package/lib/graphql.types.js +45 -0
- package/lib/graphql.types.js.map +1 -0
- package/lib/json-patch.d.ts +30 -30
- package/lib/json-patch.d.ts.map +1 -1
- package/lib/json-patch.js +73 -107
- package/lib/json-patch.js.map +1 -1
- package/lib/pagination.d.ts +77 -51
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +162 -94
- package/lib/pagination.js.map +1 -1
- package/lib/protocol-http.d.ts +74 -0
- package/lib/protocol-http.d.ts.map +1 -0
- package/lib/protocol-http.js +590 -0
- package/lib/protocol-http.js.map +1 -0
- package/lib/protocol-http.test.d.ts +2 -0
- package/lib/protocol-http.test.d.ts.map +1 -0
- package/lib/protocol-http.test.js +88 -0
- package/lib/protocol-http.test.js.map +1 -0
- package/lib/protocol-rest.d.ts +134 -0
- package/lib/protocol-rest.d.ts.map +1 -0
- package/lib/protocol-rest.js +256 -0
- package/lib/protocol-rest.js.map +1 -0
- package/lib/retry.d.ts +8 -2
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +22 -16
- package/lib/retry.js.map +1 -1
- package/lib/schema.d.ts +8 -9
- package/lib/schema.d.ts.map +1 -1
- package/lib/schema.js +8 -9
- package/lib/schema.js.map +1 -1
- package/lib/trait.d.ts +174 -0
- package/lib/trait.d.ts.map +1 -0
- package/lib/trait.js +123 -0
- package/lib/trait.js.map +1 -0
- package/package.json +24 -78
- package/src/api.ts +460 -0
- package/src/category.ts +4 -4
- package/src/codegen/boolean-string-enums.test.ts +168 -0
- package/src/codegen/boolean-string-enums.ts +106 -0
- package/src/codegen/cli.ts +285 -0
- package/src/codegen/emit.ts +203 -0
- package/src/codegen/format.ts +47 -0
- package/src/codegen/generator.ts +1283 -0
- package/src/codegen/graph.ts +151 -0
- package/src/codegen/graphql-client.test.ts +386 -0
- package/src/codegen/graphql-client.ts +419 -0
- package/src/codegen/graphql.ts +1217 -0
- package/src/codegen/members.ts +71 -0
- package/src/codegen/naming.ts +86 -0
- package/src/codegen/openapi-cli.ts +182 -0
- package/src/codegen/openapi.ts +1689 -0
- package/src/codegen/operations.ts +76 -0
- package/src/codegen/pagination.ts +71 -0
- package/src/codegen/patches.test.ts +130 -0
- package/src/codegen/patches.ts +291 -0
- package/src/codegen/prelude.ts +70 -0
- package/src/codegen/proto.ts +1128 -0
- package/src/codegen/rewrite-operation-ids.test.ts +563 -0
- package/src/codegen/rewrite-operation-ids.ts +1206 -0
- package/src/codegen/spec-path.ts +115 -0
- package/src/error-category.ts +84 -0
- package/src/errors.ts +22 -25
- package/src/graphql.fixture.ts +371 -0
- package/src/graphql.test.ts +974 -0
- package/src/graphql.ts +1321 -0
- package/src/graphql.types.ts +185 -0
- package/src/json-patch.ts +95 -122
- package/src/pagination.ts +217 -146
- package/src/protocol-http.test.ts +107 -0
- package/src/protocol-http.ts +735 -0
- package/src/protocol-rest.ts +391 -0
- package/src/retry.ts +21 -22
- package/src/schema.ts +9 -10
- package/src/trait.ts +274 -0
- package/README.md +0 -30
- package/lib/client.d.ts +0 -167
- package/lib/client.d.ts.map +0 -1
- package/lib/client.js +0 -659
- package/lib/client.js.map +0 -1
- package/lib/schemas.d.ts +0 -60
- package/lib/schemas.d.ts.map +0 -1
- package/lib/schemas.js +0 -79
- package/lib/schemas.js.map +0 -1
- package/lib/sensitive.d.ts +0 -71
- package/lib/sensitive.d.ts.map +0 -1
- package/lib/sensitive.js +0 -96
- package/lib/sensitive.js.map +0 -1
- package/lib/traits.d.ts +0 -421
- package/lib/traits.d.ts.map +0 -1
- package/lib/traits.js +0 -737
- package/lib/traits.js.map +0 -1
- package/src/client.ts +0 -1177
- package/src/schemas.ts +0 -128
- package/src/sensitive.ts +0 -119
- package/src/traits.ts +0 -996
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/lib/api.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as S from "effect/Schema";
|
|
5
|
+
import type * as AST from "effect/SchemaAST";
|
|
6
|
+
import type * as Stream from "effect/Stream";
|
|
7
|
+
import * as Pagination from "./pagination.ts";
|
|
8
|
+
import { type Policy as RetryPolicy } from "./retry.ts";
|
|
9
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
10
|
+
import type * as HttpClientError from "effect/unstable/http/HttpClientError";
|
|
11
|
+
import type * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
|
12
|
+
import type * as HttpClientResponse from "effect/unstable/http/HttpClientResponse";
|
|
13
|
+
/**
|
|
14
|
+
* The view of an operation's config that protocols receive on every
|
|
15
|
+
* encode/decode call. The object is the same memoized config instance for
|
|
16
|
+
* every call to a given operation, so protocols can key per-operation
|
|
17
|
+
* preprocessing (handler construction, error maps) off its identity in a
|
|
18
|
+
* WeakMap.
|
|
19
|
+
*/
|
|
20
|
+
export interface ProtocolOperationConfig {
|
|
21
|
+
readonly input?: S.Top;
|
|
22
|
+
readonly output?: S.Top;
|
|
23
|
+
readonly errors?: ReadonlyArray<ApiErrorClass>;
|
|
24
|
+
/**
|
|
25
|
+
* The wire operation name (e.g. the Smithy operation shape name). RPC-style
|
|
26
|
+
* protocols address operations by name (AWS JSON's `X-Amz-Target`, AWS
|
|
27
|
+
* Query's `Action=`) and unwrap responses by it; REST protocols ignore it.
|
|
28
|
+
*/
|
|
29
|
+
readonly operationName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The smithy `smithy.api#endpoint` hostPrefix (e.g. `sync-` for Step
|
|
32
|
+
* Functions' StartSyncExecution). Protocols prepend it to the resolved
|
|
33
|
+
* endpoint host, substituting `{memberName}` labels from the input.
|
|
34
|
+
*/
|
|
35
|
+
readonly endpointHostPrefix?: string;
|
|
36
|
+
readonly pagination?: Pagination.PaginatedTrait;
|
|
37
|
+
}
|
|
38
|
+
declare const Protocol_base: Context.ServiceClass<Protocol, "Protocol", {
|
|
39
|
+
readonly encode: (args: {
|
|
40
|
+
readonly input: unknown;
|
|
41
|
+
readonly inputAst: AST.AST;
|
|
42
|
+
/** The operation's config (memoized per operation — see {@link ProtocolOperationConfig}). */
|
|
43
|
+
readonly config: ProtocolOperationConfig;
|
|
44
|
+
}) => Effect.Effect<HttpClientRequest.HttpClientRequest>;
|
|
45
|
+
readonly decode: (args: {
|
|
46
|
+
readonly response: HttpClientResponse.HttpClientResponse;
|
|
47
|
+
readonly outputAst: AST.AST;
|
|
48
|
+
/**
|
|
49
|
+
* The operation's declared error classes (from `OperationConfig.errors`).
|
|
50
|
+
* Protocols use these to surface wire failures as the operation's typed
|
|
51
|
+
* errors — e.g. by consulting matcher metadata stamped on the class.
|
|
52
|
+
*/
|
|
53
|
+
readonly errors: ReadonlyArray<ApiErrorClass>;
|
|
54
|
+
/** The operation's config (memoized per operation — see {@link ProtocolOperationConfig}). */
|
|
55
|
+
readonly config: ProtocolOperationConfig;
|
|
56
|
+
}) => Effect.Effect<unknown>;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* The Protocol service knows how to turn a value into an HTTP request using
|
|
60
|
+
* only the input schema's trait annotations, and how to turn a response back
|
|
61
|
+
* into an output value using the output schema's trait annotations.
|
|
62
|
+
*
|
|
63
|
+
* Swap implementations by providing a different `Layer<Protocol>`.
|
|
64
|
+
*/
|
|
65
|
+
export declare class Protocol extends Protocol_base {
|
|
66
|
+
}
|
|
67
|
+
export type ApiErrorClass = {
|
|
68
|
+
new (...args: any[]): {
|
|
69
|
+
readonly _tag: string;
|
|
70
|
+
readonly message: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The shape of a generated SDK operation — usable two ways (mirrors the
|
|
75
|
+
* distilled repo's OperationMethod):
|
|
76
|
+
*
|
|
77
|
+
* 1. Direct call: `yield* operation(input)` — an Effect with requirements.
|
|
78
|
+
* 2. Yield first: `const fn = yield* operation` — captures the current
|
|
79
|
+
* context and returns a requirement-free call function.
|
|
80
|
+
*
|
|
81
|
+
* Generated service files annotate every exported operation with this type
|
|
82
|
+
* explicitly (against their hand-emitted interfaces), so the compiler never
|
|
83
|
+
* has to infer it back out of the schema generics.
|
|
84
|
+
*/
|
|
85
|
+
export type OperationMethod<I, O, E, R> = Effect.Effect<(input: I) => Effect.Effect<O, E, never>, never, R> & ((input: I) => Effect.Effect<O, E, R>);
|
|
86
|
+
export interface OperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> {
|
|
87
|
+
input?: I;
|
|
88
|
+
output?: O;
|
|
89
|
+
errors?: E;
|
|
90
|
+
/**
|
|
91
|
+
* The protocol layer that knows how to encode/decode this operation's wire
|
|
92
|
+
* format. Built once per process and shared across all operations that
|
|
93
|
+
* reference the same layer value — it must resolve call-dependent services
|
|
94
|
+
* (credentials etc.) inside encode/decode, not at build time.
|
|
95
|
+
*/
|
|
96
|
+
protocol: Layer.Layer<Protocol, PE, PR>;
|
|
97
|
+
/**
|
|
98
|
+
* SDK-specific retry service tag (see `core/retry`). When provided and the
|
|
99
|
+
* caller's context carries a policy under this tag, every call is retried
|
|
100
|
+
* per that policy (e.g. `Layer.succeed(Cloudflare.Retry.Retry, factory)`).
|
|
101
|
+
*/
|
|
102
|
+
retry?: Context.Key<any, RetryPolicy>;
|
|
103
|
+
/**
|
|
104
|
+
* The wire operation name for RPC-style protocols (see
|
|
105
|
+
* {@link ProtocolOperationConfig.operationName}).
|
|
106
|
+
*/
|
|
107
|
+
operationName?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Host prefix from the smithy endpoint trait (see
|
|
110
|
+
* {@link ProtocolOperationConfig.endpointHostPrefix}).
|
|
111
|
+
*/
|
|
112
|
+
endpointHostPrefix?: string;
|
|
113
|
+
}
|
|
114
|
+
export declare function make<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly []>(configFn: () => OperationConfig<I, O, PE, PR, E>): OperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, InstanceType<E[number]> | PE | HttpClientError.HttpClientError, PR | HttpClient.HttpClient>;
|
|
115
|
+
/**
|
|
116
|
+
* STRUCTURAL fallback for the element type `.items()` yields: the array
|
|
117
|
+
* element of the page response itself, or of its `result` member.
|
|
118
|
+
*
|
|
119
|
+
* It can only see shapes it was taught, so any other envelope
|
|
120
|
+
* (`{ branches: […] }`, `{ data: […] }`, …) lands on `unknown` — which is
|
|
121
|
+
* why generators pass the item type EXPLICITLY as
|
|
122
|
+
* {@link PaginatedOperationMethod}'s `Item` argument, resolved from the
|
|
123
|
+
* pagination trait's `items` path against the response shape. This default
|
|
124
|
+
* only applies to hand-written operations.
|
|
125
|
+
*/
|
|
126
|
+
export type PaginatedItem<A> = A extends ReadonlyArray<infer Item> ? Item : A extends {
|
|
127
|
+
result: ReadonlyArray<infer Item>;
|
|
128
|
+
} ? Item : A extends {
|
|
129
|
+
result?: ReadonlyArray<infer Item> | null | undefined;
|
|
130
|
+
} ? Item : unknown;
|
|
131
|
+
/**
|
|
132
|
+
* The callable half of a paginated operation: the operation call itself, plus
|
|
133
|
+
* `.pages(input)` streaming every page response and `.items(input)` streaming
|
|
134
|
+
* the individual items across pages.
|
|
135
|
+
*
|
|
136
|
+
* Used twice in {@link PaginatedOperationMethod} — once with the operation's
|
|
137
|
+
* requirements (`R`) for the direct-call style, once with `R = never` for the
|
|
138
|
+
* value `yield* operation` hands back, which has the caller's context baked in.
|
|
139
|
+
*/
|
|
140
|
+
export interface PaginatedCall<I, O, E, R, Item> {
|
|
141
|
+
(input: I): Effect.Effect<O, E, R>;
|
|
142
|
+
readonly pages: (input: I) => Stream.Stream<O, E, R>;
|
|
143
|
+
readonly items: (input: I) => Stream.Stream<Item, E, R>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A paginated operation: usable both ways an {@link OperationMethod} is, with
|
|
147
|
+
* `.pages` / `.items` on BOTH — the operation object for
|
|
148
|
+
* `yield* op.items(input)`, and the requirement-free call function for
|
|
149
|
+
* `const op = yield* operation; yield* op.items(input)` (distilled #145).
|
|
150
|
+
*/
|
|
151
|
+
export type PaginatedOperationMethod<I, O, E, R, Item = PaginatedItem<O>> = Effect.Effect<PaginatedCall<I, O, E, never, Item>, never, R> & PaginatedCall<I, O, E, R, Item>;
|
|
152
|
+
export interface PaginatedOperationConfig<I extends S.Top, O extends S.Top, PE, PR, E extends readonly ApiErrorClass[] = readonly ApiErrorClass[]> extends OperationConfig<I, O, PE, PR, E> {
|
|
153
|
+
/** How to advance between pages (mirrors the `smithy.api#paginated` trait). */
|
|
154
|
+
pagination: Pagination.PaginatedTrait;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Like {@link make}, plus `.pages()` / `.items()` streaming built on the
|
|
158
|
+
* operation's pagination trait. The SDK can pass a provider-specific
|
|
159
|
+
* {@link Pagination.PaginationStrategy} (e.g. Cloudflare stops page-mode
|
|
160
|
+
* traversal on the first empty page); the default dispatches on
|
|
161
|
+
* `pagination.mode`.
|
|
162
|
+
*/
|
|
163
|
+
export declare function makePaginated<I extends S.Top, O extends S.Top, PE, PR, const E extends readonly ApiErrorClass[] = readonly []>(configFn: () => PaginatedOperationConfig<I, O, PE, PR, E>, strategy?: Pagination.PaginationStrategy): PaginatedOperationMethod<S.Schema.Type<I>, S.Schema.Type<O>, InstanceType<E[number]> | PE | HttpClientError.HttpClientError, PR | HttpClient.HttpClient>;
|
|
164
|
+
export {};
|
|
165
|
+
//# sourceMappingURL=api.d.ts.map
|
package/lib/api.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,C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,SAAS,EAAE,EAEtD,QAAQ,EAAE,MAAM,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EACzD,QAAQ,CAAC,EAAE,UAAU,CAAC,kBAAkB,GACvC,wBAAwB,CACzB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAChB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAChB,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,eAAe,CAAC,eAAe,EAC9D,EAAE,GAAG,UAAU,CAAC,UAAU,CAC3B,CA2CA"}
|
package/lib/api.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as S from "effect/Schema";
|
|
6
|
+
import { pipeArguments } from "effect/Pipeable";
|
|
7
|
+
import * as Ref from "effect/Ref";
|
|
8
|
+
import * as Scope from "effect/Scope";
|
|
9
|
+
import { SingleShotGen } from "effect/Utils";
|
|
10
|
+
import * as Pagination from "./pagination.js";
|
|
11
|
+
import { makeDefault } from "./retry.js";
|
|
12
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
13
|
+
/**
|
|
14
|
+
* The Protocol service knows how to turn a value into an HTTP request using
|
|
15
|
+
* only the input schema's trait annotations, and how to turn a response back
|
|
16
|
+
* into an output value using the output schema's trait annotations.
|
|
17
|
+
*
|
|
18
|
+
* Swap implementations by providing a different `Layer<Protocol>`.
|
|
19
|
+
*/
|
|
20
|
+
export class Protocol extends Context.Service()("Protocol") {
|
|
21
|
+
}
|
|
22
|
+
// NOTE: request/response ASTs are handed to the protocol RAW (Suspend nodes
|
|
23
|
+
// included). Pre-resolving Suspends here would drop annotations that sit on
|
|
24
|
+
// intermediate nodes — e.g. a bare-payload response whose payload type is
|
|
25
|
+
// itself a suspended schema carries its EnvelopePayloadRoot marker on the
|
|
26
|
+
// inner Suspend, and unwrapping it silently degrades decode to the struct
|
|
27
|
+
// path. The protocol helpers (core/protocol-http getAnn/getProps) descend
|
|
28
|
+
// Suspends themselves, and `Suspend.thunk` memoizes, so raw ASTs cost
|
|
29
|
+
// nothing extra.
|
|
30
|
+
/**
|
|
31
|
+
* Protocol layers are built once per process and shared by every operation
|
|
32
|
+
* call (keyed by layer value identity — generated operations all reference the
|
|
33
|
+
* same module-level layer const). The build runs against a process-lifetime
|
|
34
|
+
* scope, and concurrent first calls are deduplicated through a private
|
|
35
|
+
* MemoMap.
|
|
36
|
+
*
|
|
37
|
+
* Contract for protocol implementations: the layer build must not capture
|
|
38
|
+
* per-call context. Anything call-dependent — credentials, per-request
|
|
39
|
+
* options — must be resolved inside `encode`/`decode`, which execute on the
|
|
40
|
+
* calling fiber and therefore see the caller's services on every request.
|
|
41
|
+
*/
|
|
42
|
+
const protocolMemoMap = Layer.makeMemoMapUnsafe();
|
|
43
|
+
const protocolScope = Scope.makeUnsafe();
|
|
44
|
+
const protocolContexts = new WeakMap();
|
|
45
|
+
const protocolContext = (layer) => {
|
|
46
|
+
const cached = protocolContexts.get(layer);
|
|
47
|
+
if (cached)
|
|
48
|
+
return Effect.succeed(cached);
|
|
49
|
+
return Effect.map(Layer.buildWithMemoMap(layer, protocolMemoMap, protocolScope), (ctx) => {
|
|
50
|
+
protocolContexts.set(layer, ctx);
|
|
51
|
+
return ctx;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Wrap one operation call with the caller-provided retry policy, if the
|
|
56
|
+
* operation declares a retry tag and the context carries a policy for it.
|
|
57
|
+
*/
|
|
58
|
+
const applyRetry = (base, retryKey) => retryKey === undefined
|
|
59
|
+
? base
|
|
60
|
+
: Effect.flatMap(Effect.serviceOption(retryKey), (opt) => Effect.gen(function* () {
|
|
61
|
+
const lastError = yield* Ref.make(undefined);
|
|
62
|
+
// No policy in context → makeDefault (transient/throttling/server
|
|
63
|
+
// errors, capped exponential backoff + jitter, honors server
|
|
64
|
+
// retryAfter hints). Mirrors the distilled client.
|
|
65
|
+
const policy = Option.isSome(opt) ? opt.value : makeDefault;
|
|
66
|
+
const opts = typeof policy === "function" ? policy(lastError) : policy;
|
|
67
|
+
if (!opts.while)
|
|
68
|
+
return yield* base;
|
|
69
|
+
return yield* base.pipe(Effect.tapError((e) => Ref.set(lastError, e)), Effect.retry({
|
|
70
|
+
while: (e) => opts.while(e),
|
|
71
|
+
...(opts.schedule ? { schedule: opts.schedule } : {}),
|
|
72
|
+
}));
|
|
73
|
+
}));
|
|
74
|
+
export function make(configFn) {
|
|
75
|
+
let prepared;
|
|
76
|
+
const prepare = () => {
|
|
77
|
+
if (prepared)
|
|
78
|
+
return prepared;
|
|
79
|
+
const cfg = configFn();
|
|
80
|
+
prepared = {
|
|
81
|
+
cfg,
|
|
82
|
+
inputAst: cfg.input.ast,
|
|
83
|
+
outputAst: cfg.output.ast,
|
|
84
|
+
};
|
|
85
|
+
return prepared;
|
|
86
|
+
};
|
|
87
|
+
const fn = (input) => Effect.suspend(() => {
|
|
88
|
+
const { cfg, inputAst, outputAst } = prepare();
|
|
89
|
+
const call = Effect.flatMap(protocolContext(cfg.protocol), (protocolCtx) => Effect.gen(function* () {
|
|
90
|
+
const protocol = yield* Protocol;
|
|
91
|
+
const client = yield* HttpClient.HttpClient;
|
|
92
|
+
const request = yield* protocol.encode({
|
|
93
|
+
input,
|
|
94
|
+
inputAst,
|
|
95
|
+
config: cfg,
|
|
96
|
+
});
|
|
97
|
+
const response = yield* client.execute(request);
|
|
98
|
+
return yield* protocol.decode({
|
|
99
|
+
response,
|
|
100
|
+
outputAst,
|
|
101
|
+
errors: cfg.errors ?? [],
|
|
102
|
+
config: cfg,
|
|
103
|
+
});
|
|
104
|
+
}).pipe(Effect.provideContext(protocolCtx)));
|
|
105
|
+
return applyRetry(call, cfg.retry);
|
|
106
|
+
});
|
|
107
|
+
// Make the operation itself yieldable: `yield* operation` captures the
|
|
108
|
+
// current context and returns a requirement-free call function (mirrors
|
|
109
|
+
// the distilled repo's OperationMethod). The captured context is a
|
|
110
|
+
// FALLBACK, not a snapshot: entries present on the calling fiber at call
|
|
111
|
+
// time win, so per-call overrides — e.g. providing `Endpoint` with a
|
|
112
|
+
// discovered data-plane address around one invocation — take effect
|
|
113
|
+
// instead of being shadowed by the context captured at yield time.
|
|
114
|
+
const Proto = {
|
|
115
|
+
[Symbol.iterator]() {
|
|
116
|
+
return new SingleShotGen(this.asEffect());
|
|
117
|
+
},
|
|
118
|
+
pipe() {
|
|
119
|
+
return pipeArguments(this.asEffect(), arguments);
|
|
120
|
+
},
|
|
121
|
+
asEffect() {
|
|
122
|
+
return Effect.map(Effect.context(), (context) => (input) =>
|
|
123
|
+
// `Context` is contravariant, so `Context<never>` is not assignable
|
|
124
|
+
// to the `Context<any>` updateContext expects — the widening cast is
|
|
125
|
+
// sound (the merge only ever adds entries).
|
|
126
|
+
Effect.updateContext(fn(input), (current) => Context.merge(context, current)));
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
Object.assign(fn, Proto);
|
|
130
|
+
// Debug/introspection surface carried over from the distilled client:
|
|
131
|
+
// the operation's metadata is readable off the exported callable
|
|
132
|
+
// (e.g. `iam.listRoles.input` / `.output` / `.errors` / `.operationName`
|
|
133
|
+
// / `.pagination`). Lazy getters, so importing a service module doesn't
|
|
134
|
+
// force its suspended schemas.
|
|
135
|
+
Object.defineProperties(fn, {
|
|
136
|
+
input: { get: () => prepare().cfg.input, configurable: true },
|
|
137
|
+
output: { get: () => prepare().cfg.output, configurable: true },
|
|
138
|
+
errors: { get: () => prepare().cfg.errors ?? [], configurable: true },
|
|
139
|
+
operationName: {
|
|
140
|
+
get: () => prepare().cfg.operationName,
|
|
141
|
+
configurable: true,
|
|
142
|
+
},
|
|
143
|
+
pagination: {
|
|
144
|
+
get: () => prepare().cfg.pagination,
|
|
145
|
+
configurable: true,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
return fn;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Like {@link make}, plus `.pages()` / `.items()` streaming built on the
|
|
152
|
+
* operation's pagination trait. The SDK can pass a provider-specific
|
|
153
|
+
* {@link Pagination.PaginationStrategy} (e.g. Cloudflare stops page-mode
|
|
154
|
+
* traversal on the first empty page); the default dispatches on
|
|
155
|
+
* `pagination.mode`.
|
|
156
|
+
*/
|
|
157
|
+
export function makePaginated(configFn, strategy) {
|
|
158
|
+
const fn = make(configFn);
|
|
159
|
+
// configFn is a cheap object literal over already-constructed consts —
|
|
160
|
+
// re-invoking it here just reads the pagination trait (memoized).
|
|
161
|
+
let pagination;
|
|
162
|
+
const pag = () => (pagination ??= configFn().pagination);
|
|
163
|
+
const paginate = strategy ?? Pagination.paginateWithDefaults;
|
|
164
|
+
// The streams are built over a CALL FUNCTION, so the same code serves both
|
|
165
|
+
// call styles: the operation itself (requirements intact), and the
|
|
166
|
+
// context-bound function `yield* operation` hands back — whose streams
|
|
167
|
+
// inherit that captured context and so need nothing after the yield.
|
|
168
|
+
const withStreams = (call) => {
|
|
169
|
+
const pages = (input) => paginate(call, input, pag());
|
|
170
|
+
const items = (input) => {
|
|
171
|
+
const p = pag();
|
|
172
|
+
return p.items
|
|
173
|
+
? Pagination.extractItems(pages(input), p.items)
|
|
174
|
+
: pages(input);
|
|
175
|
+
};
|
|
176
|
+
return Object.assign(call, { pages, items });
|
|
177
|
+
};
|
|
178
|
+
// `yield* operation` runs through `make`'s Proto.asEffect, which builds a
|
|
179
|
+
// fresh arrow and would drop `.pages` / `.items` (distilled #145). Override
|
|
180
|
+
// it here — Proto's `[Symbol.iterator]`/`pipe` dispatch on `this`, so both
|
|
181
|
+
// pick this up. Only paginated operations pay for it. Same fallback (not
|
|
182
|
+
// snapshot) semantics as Proto.asEffect: call-time fiber entries win over
|
|
183
|
+
// the captured context.
|
|
184
|
+
fn.asEffect = () => Effect.map(Effect.context(), (context) => withStreams((input) =>
|
|
185
|
+
// Same contravariance widening as Proto.asEffect above.
|
|
186
|
+
Effect.updateContext(fn(input), (current) => Context.merge(context, current))));
|
|
187
|
+
return withStreams(fn);
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
//# sourceMappingURL=api.js.map
|
package/lib/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAA8B,MAAM,YAAY,CAAC;AACrE,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAC;AAiC9D;;;;;;GAMG;AACH,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,OAAO,EAsB1C,CAAC,UAAU,CAAC;CAAG;AAgClB,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,sEAAsE;AACtE,iBAAiB;AAEjB;;;;;;;;;;;GAWG;AACH,MAAM,eAAe,GAAG,KAAK,CAAC,iBAAiB,EAAE,CAAC;AAClD,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,EA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
|
|
9
9
|
* ```ts
|
|
10
10
|
* import * as Category from "@distilled.cloud/core/category";
|
|
11
11
|
*
|
|
12
|
-
* export class Unauthorized extends Schema.
|
|
12
|
+
* export class Unauthorized extends Schema.TaggedError<Unauthorized>()(
|
|
13
13
|
* "Unauthorized",
|
|
14
14
|
* { message: Schema.String },
|
|
15
15
|
* ).pipe(Category.withAuthError) {}
|
|
@@ -56,7 +56,7 @@ export interface RetryableInfo {
|
|
|
56
56
|
*
|
|
57
57
|
* @example
|
|
58
58
|
* ```ts
|
|
59
|
-
* export class MyError extends Schema.
|
|
59
|
+
* export class MyError extends Schema.TaggedError<MyError>()(
|
|
60
60
|
* "MyError",
|
|
61
61
|
* { message: Schema.String },
|
|
62
62
|
* ).pipe(Category.withCategory(Category.AuthError)) {}
|
|
@@ -76,13 +76,13 @@ export declare const withCategory: <Categories extends Array<Category>>(...categ
|
|
|
76
76
|
* @example
|
|
77
77
|
* ```ts
|
|
78
78
|
* // Standard retryable error
|
|
79
|
-
* export class TransientError extends Schema.
|
|
79
|
+
* export class TransientError extends Schema.TaggedError<TransientError>()(
|
|
80
80
|
* "TransientError",
|
|
81
81
|
* { message: Schema.String },
|
|
82
82
|
* ).pipe(Category.withRetryable()) {}
|
|
83
83
|
*
|
|
84
84
|
* // Throttling error (uses longer backoff)
|
|
85
|
-
* export class RateLimitError extends Schema.
|
|
85
|
+
* export class RateLimitError extends Schema.TaggedError<RateLimitError>()(
|
|
86
86
|
* "RateLimitError",
|
|
87
87
|
* { message: Schema.String },
|
|
88
88
|
* ).pipe(Category.withRetryable({ throttling: true })) {}
|
package/lib/category.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ```ts
|
|
10
10
|
* import * as Category from "@distilled.cloud/core/category";
|
|
11
11
|
*
|
|
12
|
-
* export class Unauthorized extends Schema.
|
|
12
|
+
* export class Unauthorized extends Schema.TaggedError<Unauthorized>()(
|
|
13
13
|
* "Unauthorized",
|
|
14
14
|
* { message: Schema.String },
|
|
15
15
|
* ).pipe(Category.withAuthError) {}
|
|
@@ -62,7 +62,7 @@ export const retryableKey = "@distilled.cloud/error/retryable";
|
|
|
62
62
|
*
|
|
63
63
|
* @example
|
|
64
64
|
* ```ts
|
|
65
|
-
* export class MyError extends Schema.
|
|
65
|
+
* export class MyError extends Schema.TaggedError<MyError>()(
|
|
66
66
|
* "MyError",
|
|
67
67
|
* { message: Schema.String },
|
|
68
68
|
* ).pipe(Category.withCategory(Category.AuthError)) {}
|
|
@@ -84,13 +84,13 @@ export const withCategory = (...categories) => (C) => {
|
|
|
84
84
|
* @example
|
|
85
85
|
* ```ts
|
|
86
86
|
* // Standard retryable error
|
|
87
|
-
* export class TransientError extends Schema.
|
|
87
|
+
* export class TransientError extends Schema.TaggedError<TransientError>()(
|
|
88
88
|
* "TransientError",
|
|
89
89
|
* { message: Schema.String },
|
|
90
90
|
* ).pipe(Category.withRetryable()) {}
|
|
91
91
|
*
|
|
92
92
|
* // Throttling error (uses longer backoff)
|
|
93
|
-
* export class RateLimitError extends Schema.
|
|
93
|
+
* export class RateLimitError extends Schema.TaggedError<RateLimitError>()(
|
|
94
94
|
* "RateLimitError",
|
|
95
95
|
* { message: Schema.String },
|
|
96
96
|
* ).pipe(Category.withRetryable({ throttling: true })) {}
|