@distilled.cloud/linkedin 0.0.0-stage → 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 +155 -2
- 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 +78 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +1 -0
- package/lib/errors.d.ts +53 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +1 -0
- package/lib/index.d.ts +37 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.lazy.js +6 -0
- package/lib/index.lazy.js.map +1 -0
- package/lib/protocol.d.ts +54 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +1 -0
- package/lib/retry.d.ts +52 -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/linkedin.d.ts +10183 -0
- package/lib/services/linkedin.d.ts.map +1 -0
- package/lib/services/linkedin.js +492 -0
- package/lib/services/linkedin.js.map +1 -0
- package/lib/services.lazy/index.js +3 -0
- package/lib/services.lazy/linkedin.js +3 -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 +82 -3
- package/src/credentials.ts +138 -0
- package/src/errors.ts +67 -0
- package/src/index.ts +39 -0
- package/src/protocol.ts +201 -0
- package/src/retry.ts +71 -0
- package/src/services/index.ts +2 -0
- package/src/services/linkedin.ts +30392 -0
- package/src/traits.ts +55 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ErrorOf, ProtocolOf } from "@distilled.cloud/core/protocol";
|
|
2
|
+
/**
|
|
3
|
+
* LinkedInProtocol -- hand-written: core's REST protocol, with Rest.li's
|
|
4
|
+
* query string and headers.
|
|
5
|
+
*
|
|
6
|
+
* LinkedIn's API is Rest.li 2.0 (https://linkedin.github.io/rest.li/) over
|
|
7
|
+
* JSON. Every request to `https://api.linkedin.com` carries the access
|
|
8
|
+
* token as `Authorization: Bearer`, `LinkedIn-Version: YYYYMM` (read by the
|
|
9
|
+
* versioned `/rest/` endpoints) and `X-Restli-Protocol-Version: 2.0.0`. A
|
|
10
|
+
* Rest.li method other than a plain get, get-all, create, update or delete
|
|
11
|
+
* also sends `X-RestLi-Method` (`PARTIAL_UPDATE`, `BATCH_GET`, ...), which
|
|
12
|
+
* the generated operations carry as `T.RestliMethod`.
|
|
13
|
+
*
|
|
14
|
+
* Query parameters are Rest.li 2.0 data: a list is `List(a,b)`, a record
|
|
15
|
+
* `(key:value,key2:List(x))`, and every scalar is percent-encoded, a URN's
|
|
16
|
+
* `:` included (`author=urn%3Ali%3Aorganization%3A123`). The parentheses,
|
|
17
|
+
* commas and colons of the syntax stay as they are, which core's query
|
|
18
|
+
* encoding would escape, so this protocol writes the query string itself.
|
|
19
|
+
* An operation's finder or action is already in its URI
|
|
20
|
+
* (`/rest/posts?q=author`). Path keys are percent-encoded the same way;
|
|
21
|
+
* a compound key's parts are labels of their own
|
|
22
|
+
* (`/rest/reactions/(actor:{actor},entity:{entity})`).
|
|
23
|
+
*
|
|
24
|
+
* The OAuth 2.0 token endpoint (`T.Http({ server: "oauth" })`) is on
|
|
25
|
+
* `https://www.linkedin.com` and takes a form: it gets none of these
|
|
26
|
+
* headers.
|
|
27
|
+
*
|
|
28
|
+
* Failures are Rest.li's error object, `{ status, serviceErrorCode, code,
|
|
29
|
+
* message }`, or OAuth's `{ error, error_description }`, mapped by status;
|
|
30
|
+
* `code` (or `error`) becomes the error's `code`.
|
|
31
|
+
*/
|
|
32
|
+
import * as Effect from "effect/Effect";
|
|
33
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
34
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
35
|
+
import { Credentials } from "./credentials.ts";
|
|
36
|
+
import { LinkedInParseError, UnknownLinkedInError, type LinkedInServiceError } from "./errors.ts";
|
|
37
|
+
/**
|
|
38
|
+
* What every generated LinkedIn operation fails with besides its own
|
|
39
|
+
* errors: the errors declared on the service, and the errors declared on the
|
|
40
|
+
* protocol. Nobody lists the protocol's: its type carries what its code fails
|
|
41
|
+
* with (a response that does not match its schema, a failed response nothing
|
|
42
|
+
* declares, core's REST errors, and what resolving the credentials fails
|
|
43
|
+
* with).
|
|
44
|
+
*/
|
|
45
|
+
export type LinkedInOpError = LinkedInServiceError | ErrorOf<typeof LinkedInProtocol>;
|
|
46
|
+
/** Context (requirements) shared by every generated LinkedIn operation. */
|
|
47
|
+
export type LinkedInOpContext = Credentials | HttpClient.HttpClient;
|
|
48
|
+
declare const methods: {
|
|
49
|
+
encode: (args: import("@distilled.cloud/core/protocol").EncodeArgs) => Effect.Effect<HttpClientRequest.HttpClientRequest, LinkedInParseError | UnknownLinkedInError | import("@distilled.cloud/core/protocol-rest").RestProtocolError, Credentials>;
|
|
50
|
+
decode: (args: import("@distilled.cloud/core/protocol").DecodeArgs) => Effect.Effect<unknown, import("@distilled.cloud/core/protocol").DeclaredError | LinkedInParseError | UnknownLinkedInError | import("@distilled.cloud/core/protocol-rest").RestProtocolError, Credentials>;
|
|
51
|
+
};
|
|
52
|
+
export declare const LinkedInProtocol: ProtocolOf<typeof methods>;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sources":["../src/protocol.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAY,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAQpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGlG;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,OAAO,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEtF,2EAA2E;AAC3E,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAmIpE,QAAA,MAAM,OAAO;;;CAQyB,CAAC;AAEvC,eAAO,MAAM,gBAAgB,EAAE,UAAU,CAAC,OAAO,OAAO,CAAW,CAAC"}
|
package/lib/protocol.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { protocol$LinkedInProtocol as LinkedInProtocol } from "./_bundle/sdk.js";
|
package/lib/retry.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as Retries from "@distilled.cloud/core/retry";
|
|
2
|
+
/**
|
|
3
|
+
* LinkedIn retry surface -- a veneer over `@distilled.cloud/core/retry`.
|
|
4
|
+
*
|
|
5
|
+
* `throttling` recovers a 429 Too Many Requests.
|
|
6
|
+
*
|
|
7
|
+
* The `Retry` service tag is threaded into every generated operation via
|
|
8
|
+
* `API.make({ retry: Retry })`, so a caller-installed policy applies to all
|
|
9
|
+
* LinkedIn calls below it and core's `makeDefault` is the fallback when none is
|
|
10
|
+
* provided.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import * as LinkedIn from "@distilled.cloud/meta-threads";
|
|
15
|
+
*
|
|
16
|
+
* myEffect.pipe(LinkedIn.Retry.throttling);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import * as Context from "effect/Context";
|
|
20
|
+
import * as Effect from "effect/Effect";
|
|
21
|
+
export type Options = Retries.Options;
|
|
22
|
+
export type Factory = Retries.Factory;
|
|
23
|
+
export type Policy = Retries.Policy;
|
|
24
|
+
declare const Retry_base: Context.ServiceClass<Retry, "LinkedInRetry", Retries.Policy>;
|
|
25
|
+
/** Context tag for configuring retry behavior of LinkedIn API calls. */
|
|
26
|
+
export declare class Retry extends /*@__PURE__*/ Retry_base {
|
|
27
|
+
}
|
|
28
|
+
/** Provides a custom retry policy to every LinkedIn API call below it. */
|
|
29
|
+
export declare const policy: {
|
|
30
|
+
(options: Options): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
31
|
+
(factory: Factory): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
32
|
+
};
|
|
33
|
+
/** Disables all automatic retries. */
|
|
34
|
+
export declare const none: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
35
|
+
/**
|
|
36
|
+
* The default retry policy (core's): transient/throttling/retryable errors,
|
|
37
|
+
* capped exponential backoff with jitter, server `retryAfter` hints honored
|
|
38
|
+
* with precedence.
|
|
39
|
+
*/
|
|
40
|
+
export declare const makeDefault: Factory;
|
|
41
|
+
export declare const jittered: <Error, Env>(self: import("effect/Schedule").Schedule<unknown, unknown, Error, Env>) => import("effect/Schedule").Schedule<unknown, unknown, Error, Env>;
|
|
42
|
+
export declare const capped: (max: import("effect/Duration").Duration) => <Error, Env>(self: import("effect/Schedule").Schedule<unknown, unknown, Error, Env>) => import("effect/Schedule").Schedule<unknown, unknown, Error, Env>;
|
|
43
|
+
/** Retry options that retry all throttling errors indefinitely. */
|
|
44
|
+
export declare const throttlingOptions: Options;
|
|
45
|
+
/** Retries all throttling errors indefinitely (honoring server hints). */
|
|
46
|
+
export declare const throttling: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
47
|
+
/** Retry options that retry all transient errors indefinitely. */
|
|
48
|
+
export declare const transientOptions: Options;
|
|
49
|
+
/** Retries all transient errors indefinitely. */
|
|
50
|
+
export declare const transient: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACtC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACtC,MAAM,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;;AAEpC,wEAAwE;AACxE,qBAAa,KAAM,SAAQ,aAAa,CAAC,UAAiD;CAAG;AAE7F,0EAA0E;AAC1E,eAAO,MAAM,MAAM,EAAE;IACnB,CACE,OAAO,EAAE,OAAO,GACf,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACvF,CACE,OAAO,EAAE,OAAO,GACf,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAA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ault as makeDefault, retry$none as none, retry$policy as policy, retry$throttling as throttling, retry$throttlingOptions as throttlingOptions, retry$transient as transient, retry$transientOptions as transientOptions } from "./_bundle/sdk.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../../src/services/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as linkedin from "./linkedin.js";
|