@distilled.cloud/pinterest 0.0.0 → 1.0.0-rc.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +102 -4
- package/lib/.lazy.json +1 -0
- package/lib/_bundle/lazy.js +4 -0
- package/lib/_bundle/sdk.js +2 -0
- package/lib/_bundle/sdk.js.map +1 -0
- package/lib/credentials.d.ts +31 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +1 -0
- package/lib/errors.d.ts +49 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +1 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.lazy.js +8 -0
- package/lib/index.lazy.js.map +1 -0
- package/lib/pagination.d.ts +11 -0
- package/lib/pagination.d.ts.map +1 -0
- package/lib/pagination.js +1 -0
- package/lib/protocol.d.ts +20 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +1 -0
- package/lib/retry.d.ts +50 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +1 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +1 -0
- package/lib/services/pinterest.d.ts +17070 -0
- package/lib/services/pinterest.d.ts.map +1 -0
- package/lib/services/pinterest.js +451 -0
- package/lib/services/pinterest.js.map +1 -0
- package/lib/services.lazy/index.js +3 -0
- package/lib/services.lazy/pinterest.js +4 -0
- package/lib/traits.d.ts +11 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +1 -0
- package/package.json +83 -2
- package/src/credentials.ts +79 -0
- package/src/errors.ts +62 -0
- package/src/index.ts +34 -0
- package/src/pagination.ts +10 -0
- package/src/protocol.ts +52 -0
- package/src/retry.ts +69 -0
- package/src/services/index.ts +2 -0
- package/src/services/pinterest.ts +43548 -0
- package/src/traits.ts +47 -0
package/src/retry.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as Retries from "@distilled.cloud/core/retry";
|
|
2
|
+
/**
|
|
3
|
+
* Pinterest retry surface -- a veneer over `@distilled.cloud/core/retry`.
|
|
4
|
+
*
|
|
5
|
+
* The `Retry` service tag is threaded into every generated operation via
|
|
6
|
+
* `API.make({ retry: Retry })`, so a caller-installed policy applies to all
|
|
7
|
+
* Pinterest calls below it and core's `makeDefault` is the fallback when none is
|
|
8
|
+
* provided.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import * as Pinterest from "@distilled.cloud/pinterest";
|
|
13
|
+
*
|
|
14
|
+
* myEffect.pipe(Pinterest.Retry.transient);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import * as Context from "effect/Context";
|
|
18
|
+
import * as Effect from "effect/Effect";
|
|
19
|
+
import * as Layer from "effect/Layer";
|
|
20
|
+
|
|
21
|
+
export type Options = Retries.Options;
|
|
22
|
+
export type Factory = Retries.Factory;
|
|
23
|
+
export type Policy = Retries.Policy;
|
|
24
|
+
|
|
25
|
+
/** Context tag for configuring retry behavior of Pinterest API calls. */
|
|
26
|
+
export class Retry extends /*@__PURE__*/ Context.Service<Retry, Policy>()("PinterestRetry") {}
|
|
27
|
+
|
|
28
|
+
/** Provides a custom retry policy to every Pinterest API call below it. */
|
|
29
|
+
export const policy: {
|
|
30
|
+
(
|
|
31
|
+
options: Options,
|
|
32
|
+
): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
33
|
+
(
|
|
34
|
+
factory: Factory,
|
|
35
|
+
): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
36
|
+
} = (optionsOrFactory: Options | Factory) => Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
37
|
+
|
|
38
|
+
/** Disables all automatic retries. */
|
|
39
|
+
export const none: <A, E, R>(
|
|
40
|
+
effect: Effect.Effect<A, E, R>,
|
|
41
|
+
) => Effect.Effect<A, E, Exclude<R, Retry>> = /*@__PURE__*/ Effect.provide(
|
|
42
|
+
/*@__PURE__*/ Layer.succeed(Retry, { while: () => false }),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The default retry policy (core's): transient/throttling/retryable errors,
|
|
47
|
+
* capped exponential backoff with jitter, server `retryAfter` hints honored
|
|
48
|
+
* with precedence.
|
|
49
|
+
*/
|
|
50
|
+
export const makeDefault: Factory = Retries.makeDefault;
|
|
51
|
+
|
|
52
|
+
export const jittered = Retries.jittered;
|
|
53
|
+
export const capped = Retries.capped;
|
|
54
|
+
|
|
55
|
+
/** Retry options that retry all throttling errors indefinitely. */
|
|
56
|
+
export const throttlingOptions: Options = Retries.throttlingOptions;
|
|
57
|
+
|
|
58
|
+
/** Retries all throttling errors indefinitely (honoring server hints). */
|
|
59
|
+
export const throttling: <A, E, R>(
|
|
60
|
+
effect: Effect.Effect<A, E, R>,
|
|
61
|
+
) => Effect.Effect<A, E, Exclude<R, Retry>> = /*@__PURE__*/ policy(Retries.throttlingFactory);
|
|
62
|
+
|
|
63
|
+
/** Retry options that retry all transient errors indefinitely. */
|
|
64
|
+
export const transientOptions: Options = Retries.transientOptions;
|
|
65
|
+
|
|
66
|
+
/** Retries all transient errors indefinitely. */
|
|
67
|
+
export const transient: <A, E, R>(
|
|
68
|
+
effect: Effect.Effect<A, E, R>,
|
|
69
|
+
) => Effect.Effect<A, E, Exclude<R, Retry>> = /*@__PURE__*/ policy(Retries.transientFactory);
|