@distilled.cloud/linkedin 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.
Files changed (44) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +151 -4
  3. package/lib/.lazy.json +1 -0
  4. package/lib/_bundle/lazy.js +4 -0
  5. package/lib/_bundle/sdk.js +2 -0
  6. package/lib/_bundle/sdk.js.map +1 -0
  7. package/lib/credentials.d.ts +78 -0
  8. package/lib/credentials.d.ts.map +1 -0
  9. package/lib/credentials.js +1 -0
  10. package/lib/errors.d.ts +53 -0
  11. package/lib/errors.d.ts.map +1 -0
  12. package/lib/errors.js +1 -0
  13. package/lib/index.d.ts +37 -0
  14. package/lib/index.d.ts.map +1 -0
  15. package/lib/index.js +6 -0
  16. package/lib/index.lazy.js +6 -0
  17. package/lib/index.lazy.js.map +1 -0
  18. package/lib/protocol.d.ts +54 -0
  19. package/lib/protocol.d.ts.map +1 -0
  20. package/lib/protocol.js +1 -0
  21. package/lib/retry.d.ts +52 -0
  22. package/lib/retry.d.ts.map +1 -0
  23. package/lib/retry.js +1 -0
  24. package/lib/services/index.d.ts +2 -0
  25. package/lib/services/index.d.ts.map +1 -0
  26. package/lib/services/index.js +1 -0
  27. package/lib/services/linkedin.d.ts +10183 -0
  28. package/lib/services/linkedin.d.ts.map +1 -0
  29. package/lib/services/linkedin.js +492 -0
  30. package/lib/services/linkedin.js.map +1 -0
  31. package/lib/services.lazy/index.js +3 -0
  32. package/lib/services.lazy/linkedin.js +3 -0
  33. package/lib/traits.d.ts +11 -0
  34. package/lib/traits.d.ts.map +1 -0
  35. package/lib/traits.js +1 -0
  36. package/package.json +77 -2
  37. package/src/credentials.ts +138 -0
  38. package/src/errors.ts +67 -0
  39. package/src/index.ts +39 -0
  40. package/src/protocol.ts +201 -0
  41. package/src/retry.ts +71 -0
  42. package/src/services/index.ts +2 -0
  43. package/src/services/linkedin.ts +30392 -0
  44. package/src/traits.ts +55 -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.
package/README.md CHANGED
@@ -1,9 +1,156 @@
1
1
  # @distilled.cloud/linkedin
2
2
 
3
- 🐣 This package name has been claimed with [fledgling](https://github.com/dmno-dev/fledgling) for [https://github.com/alchemy-run/distilled](https://github.com/alchemy-run/distilled), and a real release will land here soon.
3
+ Effect-native SDK for LinkedIn's [REST API](https://learn.microsoft.com/en-us/linkedin/)
4
+ on `api.linkedin.com`, generated from the LinkedIn API documentation.
5
+ LinkedIn publishes no OpenAPI document; Microsoft Learn serves every page of
6
+ the documentation as Markdown, and the generator reads their sample requests
7
+ and responses (and the parameter tables under them) as Rest.li calls.
4
8
 
5
- This is a placeholder — there is nothing to install yet.
9
+ It has 333 operations across the Marketing and Consumer docs:
6
10
 
7
- ---
11
+ - Community Management: posts (create, get, find by author, update, delete,
12
+ batch get), images, videos and documents (initialize, finalize, get),
13
+ comments and reactions, social metadata, organizations and their access
14
+ control lists, page, share and follower statistics, member post analytics.
15
+ - Advertising: ad accounts and their users, campaign groups, campaigns,
16
+ creatives, targeting facets, budget pricing, conversions, ad analytics.
17
+ - Audiences, events, lead sync, and the other Marketing and Consumer
18
+ products the docs show samples for.
19
+ - Sign In with LinkedIn (`getUserinfo`, `getMe`) and the OAuth 2.0 token
20
+ endpoint (`createAccessToken`).
8
21
 
9
- Want to claim a name of your own? Run `npx fledgling add <name> --new --yes` — it reserves the name on npm and can set up token-less (OIDC trusted) publishing for when you are ready.
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install @distilled.cloud/linkedin effect
26
+ ```
27
+
28
+ ## Quick start
29
+
30
+ ```ts
31
+ import { Effect, Layer } from "effect";
32
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
33
+ import * as LinkedIn from "@distilled.cloud/linkedin";
34
+
35
+ const program = Effect.gen(function* () {
36
+ // The member the token belongs to (scopes `openid profile`).
37
+ const me = yield* LinkedIn.getUserinfo({});
38
+
39
+ // The organization pages the member administers (`rw_organization_admin`).
40
+ const acls = yield* LinkedIn.findOrganizationAclsByRoleAssignee({
41
+ role: "ADMINISTRATOR",
42
+ state: "APPROVED",
43
+ });
44
+ const organization = acls.elements?.[0]?.organization ?? `urn:li:person:${me.sub}`;
45
+
46
+ // A text post; the new post's URN comes back in the `x-restli-id` header.
47
+ const created = yield* LinkedIn.createPost({
48
+ author: organization,
49
+ commentary: "Posted with Effect",
50
+ visibility: "PUBLIC",
51
+ distribution: { feedDistribution: "MAIN_FEED" },
52
+ lifecycleState: "PUBLISHED",
53
+ isReshareDisabledByAuthor: false,
54
+ });
55
+ const postId = created.xRestliId!;
56
+
57
+ // A partial update sends `X-RestLi-Method: PARTIAL_UPDATE`; `_set` is
58
+ // Rest.li's `$set` on the wire.
59
+ yield* LinkedIn.updatePost({
60
+ postId,
61
+ patch: { _set: { commentary: "Edited with Effect" } },
62
+ });
63
+
64
+ // A finder: `GET /rest/posts?q=author&author=urn%3Ali%3Aorganization%3A...`.
65
+ const posts = yield* LinkedIn.findPostsByAuthor({ author: organization, count: 10 });
66
+
67
+ // Typed failures: a post that does not exist is a NotFound.
68
+ const missing = yield* LinkedIn.getPost({ postId: "urn:li:share:0" }).pipe(
69
+ Effect.map(() => false),
70
+ Effect.catchTag("NotFound", () => Effect.succeed(true)),
71
+ );
72
+
73
+ yield* LinkedIn.deletePost({ postId });
74
+
75
+ return { postId, recent: posts.elements?.length ?? 0, missing };
76
+ });
77
+
78
+ const LinkedInLive = Layer.mergeAll(FetchHttpClient.layer, LinkedIn.CredentialsFromEnv);
79
+
80
+ program.pipe(Effect.provide(LinkedInLive), Effect.runPromise);
81
+ ```
82
+
83
+ ## Auth
84
+
85
+ `LINKEDIN_ACCESS_TOKEN` is sent as `Authorization: Bearer`. Use a member
86
+ (three-legged) or application (two-legged) access token with the scopes the
87
+ call needs (`w_member_social`, `w_organization_social`,
88
+ `r_organization_social`, `rw_ads`, `r_ads_reporting`, ...). Optional
89
+ variables:
90
+
91
+ - `LINKEDIN_API_VERSION`: the `LinkedIn-Version` header, `YYYYMM`, that the
92
+ versioned `/rest/` endpoints read. The default is `202611`, the version the
93
+ SDK was generated from. LinkedIn supports each version for at least a year.
94
+ - `LINKEDIN_API_BASE_URL`: the default is `https://api.linkedin.com`.
95
+ - `LINKEDIN_OAUTH_BASE_URL`: where `createAccessToken` goes. The default is
96
+ `https://www.linkedin.com`.
97
+
98
+ `LinkedIn.fromAccessToken({ accessToken: Redacted.make(token) })` builds the
99
+ same layer from values, and `fromAccessToken({})` builds one with no token,
100
+ for the token endpoint alone.
101
+
102
+ Exchange an authorization code for a token, or refresh one, with
103
+ `createAccessToken`, which posts a form to `/oauth/v2/accessToken` without
104
+ the API's headers:
105
+
106
+ ```ts
107
+ const { access_token, expires_in, refresh_token } = yield* LinkedIn.createAccessToken({
108
+ grant_type: "authorization_code",
109
+ code: Redacted.make(code),
110
+ client_id: clientId,
111
+ client_secret: Redacted.make(clientSecret),
112
+ redirect_uri: redirectUri,
113
+ });
114
+ ```
115
+
116
+ `code`, `client_secret`, `refresh_token` and `access_token` are `Redacted`.
117
+
118
+ ## Rest.li
119
+
120
+ LinkedIn's API is [Rest.li 2.0](https://linkedin.github.io/rest.li/), and
121
+ the SDK speaks it for you:
122
+
123
+ - Every request carries `X-Restli-Protocol-Version: 2.0.0` and
124
+ `LinkedIn-Version`. A method other than a plain get, get-all, create,
125
+ update or delete (`PARTIAL_UPDATE`, `BATCH_GET`, `BATCH_CREATE`, ...) also
126
+ sends `X-RestLi-Method`.
127
+ - Query parameters are encoded as Rest.li data: an array is `List(a,b)`, an
128
+ object `(key:value)`, and every value is percent-encoded, a URN's colons
129
+ included (`author=urn%3Ali%3Aorganization%3A2414183`). Pass plain values,
130
+ arrays and objects.
131
+ - Path keys are percent-encoded the same way; a compound key's parts are
132
+ members of their own (`deleteReaction({ actor, entity })`).
133
+
134
+ Operations are named from the Rest.li method and the path's collections:
135
+
136
+ | Call | Operation |
137
+ | --- | --- |
138
+ | `GET /rest/posts/{id}` | `getPost` |
139
+ | `GET /rest/posts?ids=List(...)` | `batchGetPosts` |
140
+ | `GET /rest/posts?q=author` | `findPostsByAuthor` |
141
+ | `POST /rest/posts` | `createPost` |
142
+ | `POST /rest/posts/{id}` (`PARTIAL_UPDATE`) | `updatePost` |
143
+ | `DELETE /rest/posts/{id}` | `deletePost` |
144
+ | `POST /rest/images?action=initializeUpload` | `initializeUploadImage` |
145
+ | `GET /rest/socialActions/{id}/comments` | `listSocialActionComments` |
146
+
147
+ The documentation shows what one call sent or received, not what the API
148
+ requires, so every member is optional but path keys, and a field no sample
149
+ shows is `unknown`.
150
+
151
+ ## Errors
152
+
153
+ Failures carry Rest.li's `code` (or OAuth's `error`) as `code` and its
154
+ `message` (or `error_description`) as `message`, mapped by HTTP status onto
155
+ `BadRequest`, `Unauthorized`, `Forbidden`, `NotFound`, `Conflict`,
156
+ `UnprocessableEntity`, `TooManyRequests` and the 5xx classes.
package/lib/.lazy.json ADDED
@@ -0,0 +1 @@
1
+ {"serviceDirs":["services"],"twins":["index.js"]}
@@ -0,0 +1,4 @@
1
+ import*as $0 from"./sdk.js";
2
+ import{api$lazyService as L}from"@distilled.cloud/core/_bundle/base";
3
+ const u=import.meta.url,N=[$0];
4
+ export const $L=(s,k,a,l,x)=>L(u,s,k,a===void 0?void 0:x?N.concat(x):N,a,l);
@@ -0,0 +1,2 @@
1
+ import{api$D as e,api$call as t,api$named as n,api$op as r,category$withParseError as i,config$Redacted as a,config$String as o,config$all as ee,config$withDefault as s,retry$capped as te,retry$jittered as c,retry$makeDefault as l,retry$throttlingFactory as u,retry$throttlingOptions as d,retry$transientFactory as ne,retry$transientOptions as re,schema_lite_typed$TaggedError as f,schema_lite_typed$Unknown as p,trait$Body as ie,trait$Header as ae,trait$Http as oe,trait$HttpBody as se,trait$KeyDictionary as ce,trait$Label as le,trait$Query as ue,trait$ResponseCode as de,trait$UnionCases as fe,trait$applyErrorMatchers as pe,trait$bodySymbol as me,trait$errorMatchersSymbol as m,trait$getErrorMatchers as h,trait$headerSymbol as g,trait$httpBodySymbol as _,trait$httpSymbol as v,trait$keyDictionarySymbol as y,trait$labelSymbol as b,trait$makeAnnotation as x,trait$querySymbol as S,trait$responseCodeSymbol as C,trait$unionCasesSymbol as w}from"@distilled.cloud/core/_bundle/base";import{errors$API_ERRORS as T,errors$BadGateway as E,errors$BadRequest as D,errors$ConfigError as O,errors$Conflict as k,errors$DEFAULT_ERRORS as A,errors$Forbidden as j,errors$GatewayTimeout as M,errors$HTTP_STATUS_MAP as N,errors$InternalServerError as P,errors$Locked as F,errors$NotFound as I,errors$ServiceUnavailable as L,errors$TooManyRequests as R,errors$Unauthorized as z,errors$UnknownErrorFields as he,errors$UnprocessableEntity as ge,protocol_http$getAnn as B,protocol_http$getProps as _e,protocol_http$hasPropAnn as ve,protocol_http$nameOf as ye,protocol_http$originFromConfig as V,protocol_rest$RawResponse as be,protocol_rest$RawResponseRoot as xe,protocol_rest$SensitiveValue as Se,protocol_rest$rawResponseRootSymbol as Ce,protocol_rest$rawResponseSymbol as we,protocol_rest$restProtocolMethods as Te,protocol_rest$sensitiveValueSymbol as Ee,protocol_rest$unknownErrorProps as De,protocol_rest$unwrapRedactedDeep as Oe,schema_lite$Array as ke,schema_lite$Boolean as Ae,schema_lite$Number as je,schema_lite$Record as Me,schema_lite$String as Ne,schema_lite$Struct as Pe,schema_lite$Unknown as Fe,schema_lite$at as Ie,schema_lite$optional as Le,schema_lite$suspend as Re}from"@distilled.cloud/core/_bundle/rest";import*as H from"effect/Context";import*as U from"effect/Effect";import*as W from"effect/Layer";import*as G from"effect/http/HttpClientRequest";import*as ze from"effect/Redacted";const K=`https://api.linkedin.com`;const q=`https://www.linkedin.com`;const J=`202611`;var Credentials=class extends (/*@__PURE__*/ H.Service()(`LinkedInCredentials`)){};const check=e=>{if(!/^\d{6}$/.test(e.apiVersion))return U.fail(new O({message:`The configured LinkedIn API version ${JSON.stringify(e.apiVersion)} is not YYYYMM (202611)`}));const t=V(`LinkedIn API base URL`,e.apiBaseUrl);if(t instanceof O)return U.fail(t);const n=V(`LinkedIn OAuth base URL`,e.oauthBaseUrl);if(n instanceof O)return U.fail(n);return U.succeed({...e,apiBaseUrl:t,oauthBaseUrl:n})};const layer=e=>W.effect(Credentials,U.map(U.flatMap(e,check),e=>U.succeed(e)));const fromAccessToken=e=>layer(U.succeed({...e.accessToken===void 0?{}:{accessToken:e.accessToken},apiVersion:e.apiVersion??`202611`,apiBaseUrl:e.apiBaseUrl??`https://api.linkedin.com`,oauthBaseUrl:e.oauthBaseUrl??`https://www.linkedin.com`}));const Be=/*@__PURE__*/ ee({accessToken:/*@__PURE__*/ a(`LINKEDIN_ACCESS_TOKEN`),apiVersion:/*@__PURE__*/ o(`LINKEDIN_API_VERSION`).pipe(/*@__PURE__*/ s(J)),apiBaseUrl:/*@__PURE__*/ o(`LINKEDIN_API_BASE_URL`).pipe(/*@__PURE__*/ s(K)),oauthBaseUrl:/*@__PURE__*/ o(`LINKEDIN_OAUTH_BASE_URL`).pipe(/*@__PURE__*/ s(q))});const Ve=/*@__PURE__*/ layer(/*@__PURE__*/ Be.pipe(/*@__PURE__*/ U.mapError(e=>new O({message:`LinkedIn credentials require LINKEDIN_ACCESS_TOKEN: ${e.message}`}))));var UnknownLinkedInError=class extends (/*@__PURE__*/ f()(`UnknownLinkedInError`,he)){};var LinkedInParseError=class extends (/*@__PURE__*/ f()(`LinkedInParseError`,{body:p,cause:p}).pipe(i)){};const He=T;const Y=/*@__PURE__*/ Symbol.for(`@distilled.cloud/linkedin/restli-method`);const RestliMethod=e=>x(Y,e);const X=`oauth`;const isRecord=e=>typeof e===`object`&&e!==null&&!Array.isArray(e);const linkedInError=e=>{if(!isRecord(e))return void 0;const text=e=>typeof e===`string`&&e!==``?e:void 0;const t=text(e.code)??text(e.error)??(typeof e.serviceErrorCode===`number`?e.serviceErrorCode:void 0);const n=text(e.message)??text(e.error_description)??text(e.error);return t===void 0&&n===void 0?void 0:{code:t,message:n}};const encodeScalar=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`);const encodeRestli=e=>{if(Array.isArray(e))return`List(${e.map(encodeRestli).join(`,`)})`;if(e instanceof Date)return encodeScalar(e.toISOString());if(isRecord(e))return`(${Object.entries(e).filter(([,e])=>e!==void 0&&e!==null).map(([e,t])=>`${encodeScalar(e)}:${encodeRestli(t)}`).join(`,`)})`;return encodeScalar(String(e))};const Z=/*@__PURE__*/ new WeakMap;const queryMembersOf=e=>{let t=Z.get(e);if(t===void 0){t=_e(e).filter(e=>ve(e,S)).map(e=>({key:String(e.name),name:ye(e,S)}));Z.set(e,t)}return t};const splitQuery=(e,t)=>{const n=[];if(!isRecord(e))return{input:e,pairs:n};let r;for(const{key:i,name:a}of queryMembersOf(t)){const t=e[i];if(t===void 0)continue;r??={...e};delete r[i];if(t===null)continue;n.push(`${encodeScalar(a)}=${encodeRestli(Oe(t))}`)}return{input:r??e,pairs:n}};const Q=/*@__PURE__*/ Te({credentials:/*@__PURE__*/ U.flatten(Credentials),baseUrl:(e,{server:t})=>t===X?e.oauthBaseUrl:e.apiBaseUrl,headers:e=>({...e.accessToken===void 0?{}:{Authorization:`Bearer ${ze.value(e.accessToken)}`},"LinkedIn-Version":e.apiVersion,"X-Restli-Protocol-Version":`2.0.0`,Accept:`application/json`}),errorEnvelope:linkedInError,unknownError:e=>new UnknownLinkedInError(De(e)),parseError:({body:e,cause:t})=>new LinkedInParseError({body:e,cause:t})});const finish=(e,t,n)=>{let r=e;if(n.length>0){const e=r.url;r=G.setUrl(r,`${e}${e.includes(`?`)?`&`:`?`}${n.join(`&`)}`)}if(B(t,v)?.server===X)return r.pipe(G.removeHeader(`authorization`),G.removeHeader(`linkedin-version`),G.removeHeader(`x-restli-protocol-version`));const i=B(t,Y);return typeof i===`string`?G.setHeader(r,`X-RestLi-Method`,i):r};const Ue={encode:e=>{const{input:t,pairs:n}=splitQuery(e.input,e.inputAst);return Q.encode({...e,input:t}).pipe(U.map(t=>finish(t,e.inputAst,n)))},decode:Q.decode};const We=Ue;var Retry=class extends (/*@__PURE__*/ H.Service()(`LinkedInRetry`)){};const policy=e=>U.provide(W.succeed(Retry,e));const $=/*@__PURE__*/ U.provide(/*@__PURE__*/ W.succeed(Retry,{while:()=>false}));const Ge=l;const Ke=c;const qe=te;const Je=d;const Ye=/*@__PURE__*/ policy(u);const Xe=re;const Ze=/*@__PURE__*/ policy(ne);export{ke as Hc,Ae as Ic,je as Rc,Me as Sc,Ne as Uc,Pe as Vc,Fe as _c,e as a,t as b,Ie as bd,Credentials as credentials$Credentials,Ve as credentials$CredentialsFromEnv,K as credentials$DEFAULT_API_BASE_URL,J as credentials$DEFAULT_API_VERSION,q as credentials$DEFAULT_OAUTH_BASE_URL,check as credentials$check,fromAccessToken as credentials$fromAccessToken,T as errors$API_ERRORS,E as errors$BadGateway,D as errors$BadRequest,O as errors$ConfigError,k as errors$Conflict,A as errors$DEFAULT_ERRORS,j as errors$Forbidden,M as errors$GatewayTimeout,N as errors$HTTP_STATUS_MAP,P as errors$InternalServerError,LinkedInParseError as errors$LinkedInParseError,He as errors$LinkedInServiceErrors,F as errors$Locked,I as errors$NotFound,L as errors$ServiceUnavailable,R as errors$TooManyRequests,z as errors$Unauthorized,UnknownLinkedInError as errors$UnknownLinkedInError,ge as errors$UnprocessableEntity,Le as gd,Re as hd,n as l,r as n,We as protocol$LinkedInProtocol,Retry as retry$Retry,qe as retry$capped,Ke as retry$jittered,Ge as retry$makeDefault,$ as retry$none,policy as retry$policy,Ye as retry$throttling,Je as retry$throttlingOptions,Ze as retry$transient,Xe as retry$transientOptions,ie as traits$Body,ae as traits$Header,oe as traits$Http,se as traits$HttpBody,ce as traits$KeyDictionary,le as traits$Label,ue as traits$Query,be as traits$RawResponse,xe as traits$RawResponseRoot,de as traits$ResponseCode,RestliMethod as traits$RestliMethod,Se as traits$SensitiveValue,fe as traits$UnionCases,pe as traits$applyErrorMatchers,me as traits$bodySymbol,m as traits$errorMatchersSymbol,h as traits$getErrorMatchers,g as traits$headerSymbol,_ as traits$httpBodySymbol,v as traits$httpSymbol,y as traits$keyDictionarySymbol,b as traits$labelSymbol,S as traits$querySymbol,Ce as traits$rawResponseRootSymbol,we as traits$rawResponseSymbol,C as traits$responseCodeSymbol,Y as traits$restliMethodSymbol,Ee as traits$sensitiveValueSymbol,w as traits$unionCasesSymbol};
2
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","names":["Schema.Unknown","Category.withParseError","Retries.makeDefault","Retries.jittered","Retries.capped","Retries.throttlingOptions","Retries.throttlingFactory","Retries.transientOptions","Retries.transientFactory","D","call","named","op","withParseError","Redacted$3","String$3","all$1","withDefault","capped$1","jittered$1","makeDefault$1","throttlingFactory","throttlingOptions$1","transientFactory","transientOptions$1","TaggedError$1","Unknown$1","Body","Header","Http","HttpBody","KeyDictionary","Label","Query","ResponseCode","UnionCases","applyErrorMatchers","bodySymbol","errorMatchersSymbol","getErrorMatchers","headerSymbol","httpBodySymbol","httpSymbol","keyDictionarySymbol","labelSymbol","makeAnnotation","querySymbol","responseCodeSymbol","unionCasesSymbol","API_ERRORS","BadGateway","BadRequest","ConfigError","Conflict","DEFAULT_ERRORS","Forbidden","GatewayTimeout","HTTP_STATUS_MAP","InternalServerError","Locked","NotFound","ServiceUnavailable","TooManyRequests","Unauthorized","UnknownErrorFields","UnprocessableEntity","getAnn","getProps","hasPropAnn","nameOf","originFromConfig","RawResponse","RawResponseRoot","SensitiveValue","rawResponseRootSymbol","rawResponseSymbol","restProtocolMethods","sensitiveValueSymbol","unknownErrorProps","unwrapRedactedDeep","Array$1","Boolean","Number","Record","String$1","Struct","Unknown","at","optional","suspend","Context","Effect","Layer","HttpClientRequest","Redacted","DEFAULT_API_BASE_URL","DEFAULT_OAUTH_BASE_URL","DEFAULT_API_VERSION","config","apiBaseUrl","oauthBaseUrl","checked","envConfig","CredentialsFromEnv","LinkedInServiceErrors","restliMethodSymbol","method","OAUTH_SERVER","v","body","code","message","value","c","k","queryMembers","members","inputAst","prop","pairs","input","rest","key","name","server","creds","info","out","request","url","methods","args","LinkedInProtocol","optionsOrFactory","none","makeDefault","jittered","capped","throttlingOptions","throttling","transientOptions","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/traits.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"s1EAiCA,MAAa+F,EAAuB,2BAGpC,MAAaC,EAAyB,2BAMtC,MAAaC,EAAsB,SAYnC,IAAa,YAAb,eACwB,gBAAQ,QAAqD,CAAC,CAClF,qBACF,EAAA,AAAE,CAAC,EAQL,MAAa,MAAS,GAAgE,CACpF,GAAI,CAAC,UAAU,KAAKC,EAAO,UAAU,EACnC,OAAOP,EAAO,KACZ,IAAIvC,EAAY,CACd,QAAS,uCAAuC,KAAK,UAAU8C,EAAO,UAAU,EAAE,wBACpF,CAAC,CACH,EAEF,MAAMC,EAAa7B,EAAiB,wBAAyB4B,EAAO,UAAU,EAC9E,GAAIC,aAAsB/C,EAAa,OAAOuC,EAAO,KAAKQ,CAAU,EACpE,MAAMC,EAAe9B,EAAiB,0BAA2B4B,EAAO,YAAY,EACpF,GAAIE,aAAwBhD,EAAa,OAAOuC,EAAO,KAAKS,CAAY,EAExE,OAAOT,EAAO,QAAQ,CAAE,GAAGO,EAAQ,aAAY,cAAa,CAAoB,CAClF,EAGA,MAAM,MAAS,GACbN,EAAM,OACJ,YACAD,EAAO,IAAIA,EAAO,QAAQO,EAAQ,KAAK,EAAI,GAAYP,EAAO,QAAQU,CAAO,CAAC,CAChF,EAOF,MAAa,gBAAmB,GAM9B,MACEV,EAAO,QAAQ,CACb,GAAIO,EAAO,cAAgB,IAAA,GAAY,CAAC,EAAI,CAAE,YAAaA,EAAO,WAAY,EAC9E,WAAYA,EAAO,YAAA,SACnB,WAAYA,EAAO,YAAA,2BACnB,aAAcA,EAAO,cAA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AAW,SACrBb,EAAkB,UAAUkC,EAAK,kBAAmBrB,CAAM,EAC1DqB,CACN,EAEA,MAAMG,GAAU,CACd,OAAS,GAAS,CAChB,KAAM,CAAE,QAAO,SAAU,WAAWC,EAAK,MAAOA,EAAK,QAAQ,EAC7D,OAAOV,EACJ,OAAO,CAAE,GAAGU,EAAM,OAAM,CAAC,CAAC,CAC1B,KAAKxC,EAAO,IAAK,GAAY,OAAOqC,EAASG,EAAK,SAAUZ,CAAK,CAAC,CAAC,CACxE,EACA,OAAQE,EAAK,MACf,EAEA,MAAaW,GAA+CF,GC7K5D,IAAa,MAAb,eAAyC,gBAAQ,QAAuB,CAAC,CAAC,eAAe,EAAA,AAAE,CAAC,EAG5F,MAAa,OAOR,GAAwCvC,EAAO,QAAQC,EAAM,QAAQ,MAAOyC,CAAgB,CAAC,EAGlG,MAAaC,EAE+C,gBAAO,QACnD,gBAAM,QAAQ,MAAO,CAAE,UAAa,KAAM,CAAC,CAC3D,EAOA,MAAaC,GAAuBrI,EAEpC,MAAasI,GAAWrI,EACxB,MAAasI,GAASrI,GAGtB,MAAasI,GAA6BrI,EAG1C,MAAasI,GAE+C,qBAAOrI,CAAyB,EAG5F,MAAasI,GAA4BrI,GAGzC,MAAasI,GAE+C,qBAAOrI,EAAwB"}
@@ -0,0 +1,78 @@
1
+ import type { Checked } from "@distilled.cloud/core/config";
2
+ import { ConfigError } from "@distilled.cloud/core/errors";
3
+ /**
4
+ * LinkedIn credentials -- hand-written.
5
+ *
6
+ * The REST API (`https://api.linkedin.com`) takes a member's OAuth 2.0
7
+ * access token as `Authorization: Bearer` on every call. The versioned
8
+ * endpoints (`/rest/...`) also take the version they are called at as
9
+ * `LinkedIn-Version: YYYYMM`; LinkedIn releases one a month and retires each
10
+ * about a year later. The protocol sends {@link Config.apiVersion}, which
11
+ * defaults to {@link DEFAULT_API_VERSION}, the version the operations were
12
+ * generated from.
13
+ *
14
+ * The OAuth 2.0 token endpoint (`createAccessToken`, on
15
+ * `https://www.linkedin.com`) takes the app's client id and secret in its
16
+ * form instead: a layer for it alone needs no access token.
17
+ *
18
+ * Following the core convention the `Credentials` service holds an *effect*
19
+ * resolving the current config, which the protocol runs per request on
20
+ * the calling fiber.
21
+ *
22
+ * A layer here reads and checks its configuration when it is built
23
+ * ({@link check}): a version that is not `YYYYMM` or a base URL that is not
24
+ * an origin is a `ConfigError` at setup, and no call fails for it.
25
+ */
26
+ import * as Context from "effect/Context";
27
+ import * as Effect from "effect/Effect";
28
+ import * as Layer from "effect/Layer";
29
+ import type * as Redacted from "effect/Redacted";
30
+ /** The REST API's origin. */
31
+ export declare const DEFAULT_API_BASE_URL = "https://api.linkedin.com";
32
+ /** The OAuth 2.0 endpoints' origin. */
33
+ export declare const DEFAULT_OAUTH_BASE_URL = "https://www.linkedin.com";
34
+ /**
35
+ * The `LinkedIn-Version` the operations were generated from: the newest
36
+ * version of the Marketing API documentation in the spec mirror.
37
+ */
38
+ export declare const DEFAULT_API_VERSION = "202611";
39
+ export interface Config {
40
+ /** A member's access token. Only `createAccessToken` works without one. */
41
+ readonly accessToken?: Redacted.Redacted<string>;
42
+ /** `LinkedIn-Version`, `YYYYMM`. */
43
+ readonly apiVersion: string;
44
+ readonly apiBaseUrl: string;
45
+ readonly oauthBaseUrl: string;
46
+ }
47
+ declare const Credentials_base: Context.ServiceClass<Credentials, "LinkedInCredentials", Effect.Effect<Checked<Config>, never, never>>;
48
+ /** What the service resolves: a {@link Config} that passed {@link check}. */
49
+ export declare class Credentials extends /*@__PURE__*/ Credentials_base {
50
+ }
51
+ /**
52
+ * Check `config`: fails with `ConfigError` for a version that is not
53
+ * `YYYYMM` and for a base URL that is not an origin. Returns the config with
54
+ * each base URL as its origin. For a `Credentials` layer of your own, for
55
+ * example one that refreshes the access token.
56
+ */
57
+ export declare const check: (config: Config) => Effect.Effect<Checked<Config>, ConfigError>;
58
+ /**
59
+ * Layer from a redacted access token, with an optional version and base
60
+ * URLs. Leave the token out for a layer that only exchanges or refreshes
61
+ * one (`createAccessToken`).
62
+ */
63
+ export declare const fromAccessToken: (config: {
64
+ readonly accessToken?: Redacted.Redacted<string>;
65
+ readonly apiVersion?: string;
66
+ readonly apiBaseUrl?: string;
67
+ readonly oauthBaseUrl?: string;
68
+ }) => Layer.Layer<Credentials, ConfigError>;
69
+ /**
70
+ * Reads `LINKEDIN_ACCESS_TOKEN` (required), `LINKEDIN_API_VERSION`,
71
+ * `LINKEDIN_API_BASE_URL` and `LINKEDIN_OAUTH_BASE_URL` (optional) through
72
+ * Effect `Config` -- so it follows whatever `ConfigProvider` is installed
73
+ * (in a Worker, one built from `env`). The environment is read, and the
74
+ * values checked, once: when the layer is built.
75
+ */
76
+ export declare const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError>;
77
+ export {};
78
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sources":["../src/credentials.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAEjD,6BAA6B;AAC7B,eAAO,MAAM,oBAAoB,6BAA6B,CAAC;AAE/D,uCAAuC;AACvC,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C,MAAM,WAAW,MAAM;IACrB,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjD,oCAAoC;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;;AAED,6EAA6E;AAC7E,qBAAa,WACX,SAAQ,aAAa,CAAC,gBAErB;CAAG;AAEN;;;;;GAKG;AACH,eAAO,MAAM,KAAK,WAAY,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAchF,CAAC;AASF;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAAY;IACtC,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAQrC,CAAC;AAeJ;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CASpE,CAAC"}
@@ -0,0 +1 @@
1
+ export { credentials$Credentials as Credentials, credentials$CredentialsFromEnv as CredentialsFromEnv, credentials$DEFAULT_API_BASE_URL as DEFAULT_API_BASE_URL, credentials$DEFAULT_API_VERSION as DEFAULT_API_VERSION, credentials$DEFAULT_OAUTH_BASE_URL as DEFAULT_OAUTH_BASE_URL, credentials$check as check, credentials$fromAccessToken as fromAccessToken } from "./_bundle/sdk.js";
@@ -0,0 +1,53 @@
1
+ /**
2
+ * LinkedIn error types.
3
+ *
4
+ * The REST API answers a failure with Rest.li's error object
5
+ *
6
+ * { "status": 403, "serviceErrorCode": 100, "code": "ACCESS_DENIED",
7
+ * "message": "Not enough permissions to access: ..." }
8
+ *
9
+ * and the OAuth 2.0 token endpoint with
10
+ *
11
+ * { "error": "invalid_request", "error_description": "..." }
12
+ *
13
+ * Both map by status onto the core classes re-exported here: `BadRequest`,
14
+ * `Unauthorized`, `Forbidden`, `NotFound`, `TooManyRequests` and the 5xx
15
+ * family, the last two retryable. The documentation declares no errors per
16
+ * operation, so these are every operation's typed errors.
17
+ */
18
+ 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";
19
+ export type { DefaultErrors } from "@distilled.cloud/core/errors";
20
+ import * as Schema from "@distilled.cloud/core/schema-lite-typed";
21
+ declare const UnknownLinkedInError_base: Schema.TaggedErrorClass<"UnknownLinkedInError", {
22
+ status: import("effect/Schema").Number;
23
+ code: import("effect/Schema").optional<import("effect/Schema").String>;
24
+ message: import("effect/Schema").optional<import("effect/Schema").String>;
25
+ body: import("effect/Schema").Unknown;
26
+ }>;
27
+ /**
28
+ * A non-2xx, non-5xx status that neither the operation nor the core map
29
+ * covers. `code` is Rest.li's `code` (`ACCESS_DENIED`) or the OAuth
30
+ * endpoint's `error` (`invalid_request`) when the body carries one.
31
+ */
32
+ export declare class UnknownLinkedInError extends /*@__PURE__*/ UnknownLinkedInError_base {
33
+ }
34
+ declare const LinkedInParseError_base: Schema.TaggedErrorClass<"LinkedInParseError", {
35
+ readonly body: import("effect/Schema").Unknown;
36
+ readonly cause: import("effect/Schema").Unknown;
37
+ }> & (new (...args: any[]) => {
38
+ "@distilled.cloud/error/categories": {
39
+ ParseError: true;
40
+ };
41
+ });
42
+ /** A 2xx response that does not match the operation's output schema. */
43
+ export declare class LinkedInParseError extends /*@__PURE__*/ LinkedInParseError_base {
44
+ }
45
+ /**
46
+ * The errors declared on the LinkedIn service: any operation can return
47
+ * them, and every generated operation lists them as its `serviceErrors`.
48
+ * Today that is each of core's status classes (401, 403, 404, 429, the
49
+ * 5xx ...).
50
+ */
51
+ export declare const LinkedInServiceErrors: readonly [typeof import("@distilled.cloud/core/errors").Unauthorized, typeof import("@distilled.cloud/core/errors").Forbidden, typeof import("@distilled.cloud/core/errors").NotFound, typeof import("@distilled.cloud/core/errors").BadRequest, typeof import("@distilled.cloud/core/errors").Conflict, typeof import("@distilled.cloud/core/errors").UnprocessableEntity, typeof import("@distilled.cloud/core/errors").TooManyRequests, typeof import("@distilled.cloud/core/errors").Locked, typeof import("@distilled.cloud/core/errors").InternalServerError, typeof import("@distilled.cloud/core/errors").BadGateway, typeof import("@distilled.cloud/core/errors").ServiceUnavailable, typeof import("@distilled.cloud/core/errors").GatewayTimeout];
52
+ export type LinkedInServiceError = InstanceType<(typeof LinkedInServiceErrors)[number]>;
53
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;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;AAIlE,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;;;;;;;AAElE;;;;GAIG;AACH,qBAAa,oBACX,SAAQ,aAAa,CAAC,yBAGrB;CAAG;;;;;;;;;AAEN,wEAAwE;AACxE,qBAAa,kBACX,SAAQ,aAAa,CAAC,uBAGU;CAAG;AAErC;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,+tBAAa,CAAC;AAChD,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
package/lib/errors.js ADDED
@@ -0,0 +1 @@
1
+ export { errors$API_ERRORS as API_ERRORS, errors$BadGateway as BadGateway, errors$BadRequest as BadRequest, errors$ConfigError as ConfigError, errors$Conflict as Conflict, errors$DEFAULT_ERRORS as DEFAULT_ERRORS, errors$Forbidden as Forbidden, errors$GatewayTimeout as GatewayTimeout, errors$HTTP_STATUS_MAP as HTTP_STATUS_MAP, errors$InternalServerError as InternalServerError, errors$LinkedInParseError as LinkedInParseError, errors$LinkedInServiceErrors as LinkedInServiceErrors, errors$Locked as Locked, errors$NotFound as NotFound, errors$ServiceUnavailable as ServiceUnavailable, errors$TooManyRequests as TooManyRequests, errors$Unauthorized as Unauthorized, errors$UnknownLinkedInError as UnknownLinkedInError, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/sdk.js";
package/lib/index.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @distilled.cloud/linkedin -- LinkedIn's REST API (api.linkedin.com) SDK
3
+ * for Effect: posts and their media, comments and reactions, organization
4
+ * pages and their statistics, ads, reporting, audiences, events and lead
5
+ * sync, and the OAuth 2.0 token endpoint.
6
+ *
7
+ * `./services` is generated by `scripts/generate.ts` from the Smithy model
8
+ * that `scripts/convert.ts` reads from the LinkedIn API documentation
9
+ * (https://learn.microsoft.com/en-us/linkedin/), mirrored as Markdown at
10
+ * `specs/spec-mirror-linkedin/specs`. Everything else in this folder is
11
+ * hand-written.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import * as Effect from "effect/Effect";
16
+ * import * as Layer from "effect/Layer";
17
+ * import * as FetchHttpClient from "effect/http/FetchHttpClient";
18
+ * import * as LinkedIn from "@distilled.cloud/linkedin";
19
+ *
20
+ * const program = LinkedIn.findPostsByAuthor({
21
+ * author: "urn:li:organization:2414183",
22
+ * count: 10,
23
+ * });
24
+ *
25
+ * program.pipe(
26
+ * Effect.provide(Layer.mergeAll(FetchHttpClient.layer, LinkedIn.CredentialsFromEnv)),
27
+ * Effect.runPromise,
28
+ * );
29
+ * ```
30
+ */
31
+ export * from "./credentials.ts";
32
+ export * from "./errors.ts";
33
+ export * as T from "./traits.ts";
34
+ export { LinkedInProtocol, type LinkedInOpError, type LinkedInOpContext } from "./protocol.ts";
35
+ export * as Retry from "./retry.ts";
36
+ export * from "./services/linkedin.ts";
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAIpC,cAAc,wBAAwB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./credentials.js";
2
+ export * from "./errors.js";
3
+ export * as T from "./traits.js";
4
+ export { LinkedInProtocol } from "./protocol.js";
5
+ export * as Retry from "./retry.js";
6
+ export * from "./services/linkedin.js";
@@ -0,0 +1,6 @@
1
+ export * from "./credentials.js";
2
+ export * from "./errors.js";
3
+ export * as T from "./traits.js";
4
+ export { LinkedInProtocol } from "./protocol.js";
5
+ export * as Retry from "./retry.js";
6
+ export * from "./services.lazy/linkedin.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAgD,MAAM,eAAe,CAAC;AAC/F,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,0EAA0E;AAC1E,oEAAoE;AACpE,eAAe;AACf,cAAc,wBAAwB,CAAC"}