@ossy/integration-linkedin 0.0.0-stage → 3.27.1

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/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@ossy/integration-linkedin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "description": "LinkedIn integration for a workspace",
4
+ "version": "3.27.1",
5
+ "type": "module",
6
+ "main": "./src/index.js",
7
+ "module": "./src/index.js",
8
+ "exports": {
9
+ ".": "./src/index.js"
10
+ },
11
+ "author": "Ossy <yourfriends@ossy.se> (https://ossy.se)",
12
+ "license": "MIT",
13
+ "ossy": {
14
+ "src": "./src"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org"
19
+ },
20
+ "files": [
21
+ "/src",
22
+ "README.md"
23
+ ],
24
+ "dependencies": {
25
+ "@ossy/platform": "^3.27.1"
26
+ },
27
+ "gitHead": "9bb5448febefff6cdd8fc94380c7c65218d1a6e6"
28
+ }
@@ -0,0 +1,7 @@
1
+ export const Definition = {
2
+ id: 'integration-linkedin',
3
+ title: 'LinkedIn',
4
+ description: 'Publish a workspace file to LinkedIn.',
5
+ icon: 'share',
6
+ status: ['beta'],
7
+ }
@@ -0,0 +1,4 @@
1
+ export const metadata = {
2
+ id: '@ossy/linkedin/actions/connect',
3
+ access: 'workspace',
4
+ }
@@ -0,0 +1,30 @@
1
+ import { IntegrationService, putWorkspaceSecret } from '@ossy/platform/integrations'
2
+
3
+ export const metadata = {
4
+ id: '@ossy/linkedin/tasks/connect',
5
+ }
6
+
7
+ /**
8
+ * Store this workspace's LinkedIn secret. The values are written to the secret
9
+ * store and are not returned.
10
+ */
11
+ export async function run ({ req, payload }) {
12
+ const workspaceId = payload?.workspaceId || req?.workspaceId
13
+ if (!workspaceId) {
14
+ throw Object.assign(new Error('workspaceId is required'), { status: 400 })
15
+ }
16
+
17
+ const stored = await putWorkspaceSecret({
18
+ workspaceId,
19
+ integrationId: 'linkedin',
20
+ payload: {
21
+ type: payload?.type || 'oauth2',
22
+ values: payload?.values,
23
+ },
24
+ })
25
+ IntegrationService.invalidateWorkspaceClient({ workspaceId, integrationId: 'linkedin' })
26
+ return {
27
+ integrationId: 'linkedin',
28
+ credentialKeys: stored.credentialKeys,
29
+ }
30
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "integration-linkedin.home.title": "LinkedIn",
3
+ "integration-linkedin.home.description": "Publish a workspace file to LinkedIn.",
4
+ "integration-linkedin.catalog.pitch": "Publish a workspace file to LinkedIn.",
5
+ "@ossy/linkedin/actions/publish.label": "Publish to LinkedIn",
6
+ "@ossy/linkedin/actions/publish.description": "Publish this file to the connected LinkedIn account",
7
+ "@ossy/linkedin/actions/connect.label": "Connect LinkedIn",
8
+ "@ossy/linkedin/actions/connect.description": "Store the LinkedIn access token for this workspace"
9
+ }
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Definition } from './Definition.js'
2
+ export { id, secrets, connect } from './linkedin.integration.js'
@@ -0,0 +1,48 @@
1
+ export const id = 'linkedin'
2
+
3
+ /** Secret keys stored for the workspace. They never go in platform env. */
4
+ export const secrets = ['ACCESS_TOKEN', 'AUTHOR_URN']
5
+
6
+ const LINKEDIN_VERSION = '202511'
7
+
8
+ /**
9
+ * Build a LinkedIn client from a workspace secret.
10
+ *
11
+ * @param {{ type?: string, values: Record<string, string> }} secret
12
+ */
13
+ export function connect (secret) {
14
+ const accessToken = secret.values.ACCESS_TOKEN
15
+ const authorUrn = secret.values.AUTHOR_URN
16
+
17
+ return {
18
+ /**
19
+ * @param {{ text: string, author?: string }} post
20
+ */
21
+ async publish ({ text, author = authorUrn }) {
22
+ const response = await fetch('https://api.linkedin.com/rest/posts', {
23
+ method: 'POST',
24
+ headers: {
25
+ Authorization: `Bearer ${accessToken}`,
26
+ 'Content-Type': 'application/json',
27
+ 'LinkedIn-Version': LINKEDIN_VERSION,
28
+ 'X-Restli-Protocol-Version': '2.0.0',
29
+ },
30
+ body: JSON.stringify({
31
+ author,
32
+ commentary: text,
33
+ visibility: 'PUBLIC',
34
+ distribution: { feedDistribution: 'MAIN_FEED' },
35
+ lifecycleState: 'PUBLISHED',
36
+ }),
37
+ })
38
+ if (!response.ok) {
39
+ throw Object.assign(new Error(`LinkedIn publish failed (${response.status})`), {
40
+ status: response.status,
41
+ code: 'LINKEDIN_PUBLISH_FAILED',
42
+ })
43
+ }
44
+ const posted = await response.json().catch(() => ({}))
45
+ return posted
46
+ },
47
+ }
48
+ }
@@ -0,0 +1,4 @@
1
+ export const metadata = {
2
+ id: '@ossy/linkedin/actions/publish',
3
+ access: 'workspace',
4
+ }
@@ -0,0 +1,39 @@
1
+ export const metadata = {
2
+ id: '@ossy/linkedin/tasks/publish',
3
+ integration: 'linkedin',
4
+ configurable: true,
5
+ triggers: [
6
+ {
7
+ type: '@ossy/platform/schema/file',
8
+ event: 'Created',
9
+ },
10
+ {
11
+ kind: 'on_action',
12
+ action: '@ossy/linkedin/actions/publish',
13
+ },
14
+ ],
15
+ }
16
+
17
+ function textFromResource (resource) {
18
+ const content = resource?.content
19
+ if (typeof content === 'string' && content.trim()) return content.trim()
20
+ if (typeof content?.text === 'string' && content.text.trim()) return content.text.trim()
21
+ if (typeof content?.body === 'string' && content.body.trim()) return content.body.trim()
22
+ return ''
23
+ }
24
+
25
+ export async function run ({ integrations, payload, event, sdk }) {
26
+ const workspaceId = payload?.workspaceId || event?.payload?.belongsTo || event?.belongsTo
27
+ const linkedin = await integrations.get('linkedin', { workspaceId })
28
+ let text = typeof payload?.text === 'string' ? payload.text.trim() : ''
29
+ const resourceId = event?.resourceId || payload?.resourceId
30
+ if (!text && resourceId && sdk?.invoke) {
31
+ const resource = await sdk.invoke(
32
+ { id: '@ossy/resources/actions/get' },
33
+ { resourceId, workspaceId },
34
+ )
35
+ text = textFromResource(resource)
36
+ }
37
+ if (!text) return { skipped: true }
38
+ return linkedin.publish({ text })
39
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "integration-linkedin.home.title": "LinkedIn",
3
+ "integration-linkedin.home.description": "Publicera en fil från arbetsytan på LinkedIn.",
4
+ "integration-linkedin.catalog.pitch": "Publicera en fil från arbetsytan på LinkedIn.",
5
+ "@ossy/linkedin/actions/publish.label": "Publicera på LinkedIn",
6
+ "@ossy/linkedin/actions/publish.description": "Publicera den här filen på det kopplade LinkedIn-kontot",
7
+ "@ossy/linkedin/actions/connect.label": "Koppla LinkedIn",
8
+ "@ossy/linkedin/actions/connect.description": "Spara LinkedIn-nyckeln för den här arbetsytan"
9
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.