@distilled.cloud/datadog 0.0.0 → 1.0.0-rc.9
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/credentials.d.ts +42 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +57 -0
- package/lib/credentials.js.map +1 -0
- package/lib/errors.d.ts +36 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +26 -0
- package/lib/errors.js.map +1 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +22 -0
- package/lib/index.js.map +1 -0
- package/lib/pagination.d.ts +11 -0
- package/lib/pagination.d.ts.map +1 -0
- package/lib/pagination.js +11 -0
- package/lib/pagination.js.map +1 -0
- package/lib/protocol.d.ts +18 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +87 -0
- package/lib/protocol.js.map +1 -0
- package/lib/retry.d.ts +32 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +32 -0
- package/lib/retry.js.map +1 -0
- package/lib/services/index.d.ts +3 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +4 -0
- package/lib/services/index.js.map +1 -0
- package/lib/services/v1.d.ts +12737 -0
- package/lib/services/v1.d.ts.map +1 -0
- package/lib/services/v1.js +9659 -0
- package/lib/services/v1.js.map +1 -0
- package/lib/services/v2.d.ts +75167 -0
- package/lib/services/v2.d.ts.map +1 -0
- package/lib/services/v2.js +69959 -0
- package/lib/services/v2.js.map +1 -0
- package/lib/traits.d.ts +11 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +11 -0
- package/lib/traits.js.map +1 -0
- package/package.json +77 -6
- package/src/credentials.ts +88 -0
- package/src/errors.ts +50 -0
- package/src/index.ts +25 -0
- package/src/pagination.ts +10 -0
- package/src/protocol.ts +116 -0
- package/src/retry.ts +54 -0
- package/src/services/index.ts +3 -0
- package/src/services/v1.ts +27861 -0
- package/src/services/v2.ts +181842 -0
- package/src/traits.ts +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datadog credentials — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* API-compatible port of the distilled v0 Neon credentials module, adapted
|
|
5
|
+
* for Datadog's dual-header auth (`DD-API-KEY` + optional
|
|
6
|
+
* `DD-APPLICATION-KEY`) and regional sites. The `Credentials` service holds
|
|
7
|
+
* an *effect* that resolves the current credentials on every request (the
|
|
8
|
+
* protocol layer resolves it per request on the calling fiber).
|
|
9
|
+
*/
|
|
10
|
+
import * as Context from "effect/Context";
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
import * as Layer from "effect/Layer";
|
|
13
|
+
import * as Redacted from "effect/Redacted";
|
|
14
|
+
/** Default Datadog site (US1). */
|
|
15
|
+
export declare const DEFAULT_SITE = "datadoghq.com";
|
|
16
|
+
/** US1 REST API root — `https://api.${DEFAULT_SITE}`. */
|
|
17
|
+
export declare const DEFAULT_API_BASE_URL = "https://api.datadoghq.com";
|
|
18
|
+
/** Map a Datadog site (`datadoghq.eu`, `us3.datadoghq.com`, …) to its API origin. */
|
|
19
|
+
export declare const apiBaseUrlForSite: (site: string) => string;
|
|
20
|
+
export interface Config {
|
|
21
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
22
|
+
readonly applicationKey?: Redacted.Redacted<string>;
|
|
23
|
+
readonly site: string;
|
|
24
|
+
readonly apiBaseUrl: string;
|
|
25
|
+
}
|
|
26
|
+
declare const Credentials_base: Context.ServiceClass<Credentials, "DatadogCredentials", Effect.Effect<Config, never, never>>;
|
|
27
|
+
export declare class Credentials extends Credentials_base {
|
|
28
|
+
}
|
|
29
|
+
/** Layer from a plain API key + optional application key / site / base URL. */
|
|
30
|
+
export declare const fromApiKey: (config: {
|
|
31
|
+
readonly apiKey: string;
|
|
32
|
+
readonly applicationKey?: string;
|
|
33
|
+
readonly site?: string;
|
|
34
|
+
readonly apiBaseUrl?: string;
|
|
35
|
+
}) => Layer.Layer<Credentials>;
|
|
36
|
+
/**
|
|
37
|
+
* Reads DD_API_KEY (required), DD_APP_KEY (optional), DD_SITE (optional)
|
|
38
|
+
* and DD_API_BASE_URL (optional override of `https://api.${site}`).
|
|
39
|
+
*/
|
|
40
|
+
export declare const CredentialsFromEnv: Layer.Layer<Credentials>;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAG5C,kCAAkC;AAClC,eAAO,MAAM,YAAY,kBAAkB,CAAC;AAE5C,yDAAyD;AACzD,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAEhE,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,SAAU,MAAM,KAAG,MAC1B,CAAC;AAExB,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAGR;CAAG;AAE5B,+EAA+E;AAC/E,eAAO,MAAM,UAAU,WAAY;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAc1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAwBvD,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datadog credentials — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* API-compatible port of the distilled v0 Neon credentials module, adapted
|
|
5
|
+
* for Datadog's dual-header auth (`DD-API-KEY` + optional
|
|
6
|
+
* `DD-APPLICATION-KEY`) and regional sites. The `Credentials` service holds
|
|
7
|
+
* an *effect* that resolves the current credentials on every request (the
|
|
8
|
+
* protocol layer resolves it per request on the calling fiber).
|
|
9
|
+
*/
|
|
10
|
+
import * as Context from "effect/Context";
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
import * as Layer from "effect/Layer";
|
|
13
|
+
import * as Redacted from "effect/Redacted";
|
|
14
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
15
|
+
/** Default Datadog site (US1). */
|
|
16
|
+
export const DEFAULT_SITE = "datadoghq.com";
|
|
17
|
+
/** US1 REST API root — `https://api.${DEFAULT_SITE}`. */
|
|
18
|
+
export const DEFAULT_API_BASE_URL = "https://api.datadoghq.com";
|
|
19
|
+
/** Map a Datadog site (`datadoghq.eu`, `us3.datadoghq.com`, …) to its API origin. */
|
|
20
|
+
export const apiBaseUrlForSite = (site) => `https://api.${site}`;
|
|
21
|
+
export class Credentials extends Context.Service()("DatadogCredentials") {
|
|
22
|
+
}
|
|
23
|
+
/** Layer from a plain API key + optional application key / site / base URL. */
|
|
24
|
+
export const fromApiKey = (config) => {
|
|
25
|
+
const site = config.site ?? DEFAULT_SITE;
|
|
26
|
+
return Layer.succeed(Credentials, Effect.succeed({
|
|
27
|
+
apiKey: Redacted.make(config.apiKey),
|
|
28
|
+
applicationKey: config.applicationKey !== undefined
|
|
29
|
+
? Redacted.make(config.applicationKey)
|
|
30
|
+
: undefined,
|
|
31
|
+
site,
|
|
32
|
+
apiBaseUrl: config.apiBaseUrl ?? apiBaseUrlForSite(site),
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Reads DD_API_KEY (required), DD_APP_KEY (optional), DD_SITE (optional)
|
|
37
|
+
* and DD_API_BASE_URL (optional override of `https://api.${site}`).
|
|
38
|
+
*/
|
|
39
|
+
export const CredentialsFromEnv = Layer.succeed(Credentials, Effect.gen(function* () {
|
|
40
|
+
const apiKey = process.env.DD_API_KEY;
|
|
41
|
+
if (!apiKey) {
|
|
42
|
+
return yield* new ConfigError({
|
|
43
|
+
message: "DD_API_KEY environment variable is required",
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const site = process.env.DD_SITE ?? DEFAULT_SITE;
|
|
47
|
+
const applicationKey = process.env.DD_APP_KEY;
|
|
48
|
+
return {
|
|
49
|
+
apiKey: Redacted.make(apiKey),
|
|
50
|
+
applicationKey: applicationKey !== undefined
|
|
51
|
+
? Redacted.make(applicationKey)
|
|
52
|
+
: undefined,
|
|
53
|
+
site,
|
|
54
|
+
apiBaseUrl: process.env.DD_API_BASE_URL ?? apiBaseUrlForSite(site),
|
|
55
|
+
};
|
|
56
|
+
}).pipe(Effect.orDie));
|
|
57
|
+
//# sourceMappingURL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ACH,MAAM,CAAC,MAAM,kBAAkB,GAA6B,KAAK,CAAC,OAAO,CACvE,WAAW,EACX,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAEtC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC;YAC5B,OAAO,EAAE,6CAA6C;SACvD,CAAC,CAAC;IACL,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,YAAY,CAAC;IACjD,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAE9C,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;QAC7B,cAAc,EACZ,cAAc,KAAK,SAAS;YAC1B,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC;YAC/B,CAAC,CAAC,SAAS;QACf,IAAI;QACJ,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,iBAAiB,CAAC,IAAI,CAAC;KACnE,CAAC;AACJ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CACtB,CAAC"}
|
package/lib/errors.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datadog-specific error types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the common HTTP errors from core and adds the Datadog fallback
|
|
5
|
+
* errors. Note the generated service modules additionally define their own
|
|
6
|
+
* per-status matcher classes (BadRequest/NotFound/…) for the statuses each
|
|
7
|
+
* operation declares — those share `_tag`s with the core classes here, so
|
|
8
|
+
* `catchTag` works against either.
|
|
9
|
+
*/
|
|
10
|
+
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
11
|
+
export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
12
|
+
import * as Schema from "effect/Schema";
|
|
13
|
+
declare const UnknownDatadogError_base: Schema.Class<UnknownDatadogError, Schema.TaggedStruct<"UnknownDatadogError", {
|
|
14
|
+
readonly code: Schema.optional<Schema.String>;
|
|
15
|
+
readonly message: Schema.optional<Schema.String>;
|
|
16
|
+
readonly body: Schema.Unknown;
|
|
17
|
+
}>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
|
|
18
|
+
"@distilled.cloud/error/categories": {
|
|
19
|
+
ServerError: true;
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
/** Unknown Datadog error — returned when nothing else matches the failure. */
|
|
23
|
+
export declare class UnknownDatadogError extends UnknownDatadogError_base {
|
|
24
|
+
}
|
|
25
|
+
declare const DatadogParseError_base: Schema.Class<DatadogParseError, Schema.TaggedStruct<"DatadogParseError", {
|
|
26
|
+
readonly body: Schema.Unknown;
|
|
27
|
+
readonly cause: Schema.Unknown;
|
|
28
|
+
}>, import("effect/Cause").YieldableError> & (new (...args: any[]) => {
|
|
29
|
+
"@distilled.cloud/error/categories": {
|
|
30
|
+
ParseError: true;
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
/** Schema parse error wrapper. */
|
|
34
|
+
export declare class DatadogParseError extends DatadogParseError_base {
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;;;;;AAGxC,8EAA8E;AAC9E,qBAAa,mBAAoB,SAAQ,wBAOT;CAAG;;;;;;;;;AAEnC,kCAAkC;AAClC,qBAAa,iBAAkB,SAAQ,sBAMR;CAAG"}
|
package/lib/errors.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datadog-specific error types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the common HTTP errors from core and adds the Datadog fallback
|
|
5
|
+
* errors. Note the generated service modules additionally define their own
|
|
6
|
+
* per-status matcher classes (BadRequest/NotFound/…) for the statuses each
|
|
7
|
+
* operation declares — those share `_tag`s with the core classes here, so
|
|
8
|
+
* `catchTag` works against either.
|
|
9
|
+
*/
|
|
10
|
+
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
12
|
+
import * as Category from "@distilled.cloud/core/category";
|
|
13
|
+
/** Unknown Datadog error — returned when nothing else matches the failure. */
|
|
14
|
+
export class UnknownDatadogError extends Schema.TaggedError()("UnknownDatadogError", {
|
|
15
|
+
code: Schema.optional(Schema.String),
|
|
16
|
+
message: Schema.optional(Schema.String),
|
|
17
|
+
body: Schema.Unknown,
|
|
18
|
+
}).pipe(Category.withServerError) {
|
|
19
|
+
}
|
|
20
|
+
/** Schema parse error wrapper. */
|
|
21
|
+
export class DatadogParseError extends Schema.TaggedError()("DatadogParseError", {
|
|
22
|
+
body: Schema.Unknown,
|
|
23
|
+
cause: Schema.Unknown,
|
|
24
|
+
}).pipe(Category.withParseError) {
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAE3D,8EAA8E;AAC9E,MAAM,OAAO,mBAAoB,SAAQ,MAAM,CAAC,WAAW,EAAuB,CAChF,qBAAqB,EACrB;IACE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC,OAAO;CACrB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;CAAG;AAEnC,kCAAkC;AAClC,MAAM,OAAO,iBAAkB,SAAQ,MAAM,CAAC,WAAW,EAAqB,CAC5E,mBAAmB,EACnB;IACE,IAAI,EAAE,MAAM,CAAC,OAAO;IACpB,KAAK,EAAE,MAAM,CAAC,OAAO;CACtB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;CAAG"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @distilled.cloud/datadog — Datadog REST API SDK for Effect.
|
|
3
|
+
*
|
|
4
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy models
|
|
5
|
+
* in `.generated-specs` (written by `scripts/convert.ts` from the OpenAPI
|
|
6
|
+
* specs). Everything else in this folder is hand-written.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import * as Datadog from "@distilled.cloud/datadog";
|
|
11
|
+
*
|
|
12
|
+
* const dashboards = yield* Datadog.Services.v1.listDashboards({});
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export * from "./credentials.ts";
|
|
16
|
+
export * from "./errors.ts";
|
|
17
|
+
export * as T from "./traits.ts";
|
|
18
|
+
export { DatadogProtocol, type DatadogOpError, type DatadogOpContext, } from "./protocol.ts";
|
|
19
|
+
export { paginateCursor } from "./pagination.ts";
|
|
20
|
+
export * as Retry from "./retry.ts";
|
|
21
|
+
export * as Services from "./services/index.ts";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @distilled.cloud/datadog — Datadog REST API SDK for Effect.
|
|
3
|
+
*
|
|
4
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy models
|
|
5
|
+
* in `.generated-specs` (written by `scripts/convert.ts` from the OpenAPI
|
|
6
|
+
* specs). Everything else in this folder is hand-written.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import * as Datadog from "@distilled.cloud/datadog";
|
|
11
|
+
*
|
|
12
|
+
* const dashboards = yield* Datadog.Services.v1.listDashboards({});
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export * from "./credentials.js";
|
|
16
|
+
export * from "./errors.js";
|
|
17
|
+
export * as T from "./traits.js";
|
|
18
|
+
export { DatadogProtocol, } from "./protocol.js";
|
|
19
|
+
export { paginateCursor } from "./pagination.js";
|
|
20
|
+
export * as Retry from "./retry.js";
|
|
21
|
+
export * as Services from "./services/index.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,eAAe,GAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datadog pagination — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Generated operations that the converter stamps as cursor-paginated pass
|
|
5
|
+
* core's {@link paginateCursor} strategy to `API.makePaginated`. Many
|
|
6
|
+
* Datadog list endpoints use `page[number]` / `page[size]` or `page[cursor]`
|
|
7
|
+
* query parameters without an in-body next-page token; those stay plain
|
|
8
|
+
* inputs.
|
|
9
|
+
*/
|
|
10
|
+
export { paginateCursor } from "@distilled.cloud/core/pagination";
|
|
11
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datadog pagination — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Generated operations that the converter stamps as cursor-paginated pass
|
|
5
|
+
* core's {@link paginateCursor} strategy to `API.makePaginated`. Many
|
|
6
|
+
* Datadog list endpoints use `page[number]` / `page[size]` or `page[cursor]`
|
|
7
|
+
* query parameters without an in-body next-page token; those stay plain
|
|
8
|
+
* inputs.
|
|
9
|
+
*/
|
|
10
|
+
export { paginateCursor } from "@distilled.cloud/core/pagination";
|
|
11
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as Layer from "effect/Layer";
|
|
2
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
3
|
+
import type * as HttpClientError from "effect/unstable/http/HttpClientError";
|
|
4
|
+
import type * as API from "@distilled.cloud/core/api";
|
|
5
|
+
import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
|
|
6
|
+
import { Credentials } from "./credentials.ts";
|
|
7
|
+
import { UnknownDatadogError } from "./errors.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Error channel shared by every generated Datadog operation. Generated
|
|
10
|
+
* service files annotate operations with `API.OperationMethod<I, O,
|
|
11
|
+
* DatadogOpError, DatadogOpContext>` explicitly so the compiler never infers
|
|
12
|
+
* these back out of the schema generics.
|
|
13
|
+
*/
|
|
14
|
+
export type DatadogOpError = InstanceType<(typeof API_ERRORS)[number]> | UnknownDatadogError | ConfigError | HttpClientError.HttpClientError;
|
|
15
|
+
/** Context (requirements) shared by every generated Datadog operation. */
|
|
16
|
+
export type DatadogOpContext = Credentials | HttpClient.HttpClient;
|
|
17
|
+
export declare const DatadogProtocol: Layer.Layer<API.Protocol>;
|
|
18
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,KAAK,UAAU,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,KAAK,eAAe,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AAKtD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB,YAAY,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GACzC,mBAAmB,GACnB,WAAW,GACX,eAAe,CAAC,eAAe,CAAC;AAEpC,0EAA0E;AAC1E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AA0CnE,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CA+BlD,CAAC"}
|
package/lib/protocol.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DatadogProtocol — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Datadog speaks plain JSON REST (no response envelope), so the whole
|
|
5
|
+
* protocol is one `makeRestProtocol` call from `core/protocol-rest`:
|
|
6
|
+
*
|
|
7
|
+
* request: credentials → `DD-API-KEY` + optional `DD-APPLICATION-KEY` +
|
|
8
|
+
* base URL (default https://api.datadoghq.com), resolved from
|
|
9
|
+
* the calling fiber on every request
|
|
10
|
+
*
|
|
11
|
+
* response: 2xx JSON is the payload (sensitive members delivered as
|
|
12
|
+
* `Redacted`); non-2xx `{ errors: string[] | object[] }` bodies
|
|
13
|
+
* map to the operation's typed error classes by status, then the
|
|
14
|
+
* shared HTTP-status classes, then {@link UnknownDatadogError}.
|
|
15
|
+
*/
|
|
16
|
+
import * as Effect from "effect/Effect";
|
|
17
|
+
import * as Redacted from "effect/Redacted";
|
|
18
|
+
import { makeRestProtocol, } from "@distilled.cloud/core/protocol-rest";
|
|
19
|
+
import { Credentials } from "./credentials.js";
|
|
20
|
+
import { UnknownDatadogError } from "./errors.js";
|
|
21
|
+
/**
|
|
22
|
+
* Datadog error bodies are typically `{ errors: string[] }` or JSON:API
|
|
23
|
+
* `{ errors: [{ title?, detail?, status? }] }`. Surface the first entry as
|
|
24
|
+
* `message` so status matchers and logs have something to key on.
|
|
25
|
+
*/
|
|
26
|
+
const errorEnvelope = (body) => {
|
|
27
|
+
if (body === null || typeof body !== "object")
|
|
28
|
+
return undefined;
|
|
29
|
+
const b = body;
|
|
30
|
+
const first = Array.isArray(b.errors) ? b.errors[0] : undefined;
|
|
31
|
+
if (typeof first === "string") {
|
|
32
|
+
return { message: first };
|
|
33
|
+
}
|
|
34
|
+
if (first !== null && typeof first === "object") {
|
|
35
|
+
const e = first;
|
|
36
|
+
const message = typeof e.detail === "string"
|
|
37
|
+
? e.detail
|
|
38
|
+
: typeof e.title === "string"
|
|
39
|
+
? e.title
|
|
40
|
+
: typeof b.message === "string"
|
|
41
|
+
? b.message
|
|
42
|
+
: undefined;
|
|
43
|
+
const code = typeof e.code === "string"
|
|
44
|
+
? e.code
|
|
45
|
+
: typeof e.status === "string"
|
|
46
|
+
? e.status
|
|
47
|
+
: undefined;
|
|
48
|
+
return { code, message };
|
|
49
|
+
}
|
|
50
|
+
const message = typeof b.message === "string" ? b.message : undefined;
|
|
51
|
+
const code = typeof b.code === "string" || typeof b.code === "number"
|
|
52
|
+
? b.code
|
|
53
|
+
: undefined;
|
|
54
|
+
return message !== undefined || code !== undefined
|
|
55
|
+
? { code, message }
|
|
56
|
+
: undefined;
|
|
57
|
+
};
|
|
58
|
+
export const DatadogProtocol = makeRestProtocol({
|
|
59
|
+
// The Credentials service holds an effect — resolving it here (per
|
|
60
|
+
// request, on the calling fiber) picks up context-provided credentials.
|
|
61
|
+
credentials: Effect.gen(function* () {
|
|
62
|
+
const resolve = yield* Credentials;
|
|
63
|
+
return yield* resolve;
|
|
64
|
+
}),
|
|
65
|
+
baseUrl: (creds) => creds.apiBaseUrl,
|
|
66
|
+
headers: (creds) => {
|
|
67
|
+
const headers = {
|
|
68
|
+
"DD-API-KEY": Redacted.value(creds.apiKey),
|
|
69
|
+
Accept: "application/json",
|
|
70
|
+
};
|
|
71
|
+
if (creds.applicationKey !== undefined) {
|
|
72
|
+
headers["DD-APPLICATION-KEY"] = Redacted.value(creds.applicationKey);
|
|
73
|
+
}
|
|
74
|
+
return headers;
|
|
75
|
+
},
|
|
76
|
+
errorEnvelope,
|
|
77
|
+
unknownError: ({ code, message, body }) => new UnknownDatadogError({
|
|
78
|
+
code: typeof code === "string"
|
|
79
|
+
? code
|
|
80
|
+
: code !== undefined
|
|
81
|
+
? String(code)
|
|
82
|
+
: undefined,
|
|
83
|
+
message,
|
|
84
|
+
body,
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,MAAM,MAAM,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ACvE,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,aAAa;IACb,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CACxC,IAAI,mBAAmB,CAAC;QACtB,IAAI,EACF,OAAO,IAAI,KAAK,QAAQ;YACtB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI,KAAK,SAAS;gBAClB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;gBACd,CAAC,CAAC,SAAS;QACjB,OAAO;QACP,IAAI;KACL,CAAC;CACL,CAAC,CAAC"}
|
package/lib/retry.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datadog retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that generated operations
|
|
5
|
+
* wire into `API.make`. Callers can install a blanket retry policy at the
|
|
6
|
+
* layer level and have every Datadog API call below it pick it up:
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import * as Datadog from "@distilled.cloud/datadog";
|
|
11
|
+
*
|
|
12
|
+
* myEffect.pipe(Datadog.Retry.transient);
|
|
13
|
+
* Effect.provide(myEffect, Layer.succeed(Datadog.Retry.Retry, customPolicy));
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import * as Context from "effect/Context";
|
|
17
|
+
import * as Effect from "effect/Effect";
|
|
18
|
+
import { type Policy } from "@distilled.cloud/core/retry";
|
|
19
|
+
export { type Options, type Factory, type Policy, makeDefault, jittered, capped, throttlingOptions, transientOptions, throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
|
|
20
|
+
declare const Retry_base: Context.ServiceClass<Retry, "DatadogRetry", Policy>;
|
|
21
|
+
/** Context tag for configuring retry behavior of Datadog API calls. */
|
|
22
|
+
export declare class Retry extends Retry_base {
|
|
23
|
+
}
|
|
24
|
+
/** Provides a custom retry policy to every Datadog API call below it. */
|
|
25
|
+
export declare const policy: (optionsOrFactory: Policy) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
26
|
+
/** Disables all automatic retries. */
|
|
27
|
+
export declare const none: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
28
|
+
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
29
|
+
export declare const throttling: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
30
|
+
/** Apply the transient retry policy (retries all transient errors indefinitely). */
|
|
31
|
+
export declare const transient: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
32
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EACL,KAAK,MAAM,EAGZ,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,WAAW,EACX,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;;AAErC,uEAAuE;AACvE,qBAAa,KAAM,SAAQ,UAAgD;CAAG;AAE9E,yEAAyE;AACzE,eAAO,MAAM,MAAM,qBAAsB,MAAM,sFACS,CAAC;AAEzD,sCAAsC;AACtC,eAAO,MAAM,IAAI,mFAEhB,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,UAAU,mFAA4B,CAAC;AAEpD,oFAAoF;AACpF,eAAO,MAAM,SAAS,mFAA2B,CAAC"}
|