@ossy/consultancy 3.22.0 → 3.24.0

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/consultancy",
3
3
  "description": "Consultancy feature package — schemas, forecasts UI, and assignment margins",
4
- "version": "3.22.0",
4
+ "version": "3.24.0",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "module": "./src/index.js",
@@ -25,14 +25,16 @@
25
25
  "README.md"
26
26
  ],
27
27
  "dependencies": {
28
+ "@ossy/email": "^3.24.0",
28
29
  "@ossy/event-store": "^3.20.1",
29
- "@ossy/schema": "^3.20.1"
30
+ "@ossy/schema": "^3.24.0"
30
31
  },
31
32
  "peerDependencies": {
32
33
  "@ossy/calendar": "*",
33
34
  "@ossy/dashboard": "*",
34
35
  "@ossy/design-system": "*",
35
36
  "@ossy/resources": "*",
37
+ "@ossy/resumes": "*",
36
38
  "@ossy/router-react": "*",
37
39
  "@ossy/sdk-react": "*",
38
40
  "react": "*"
@@ -40,5 +42,5 @@
40
42
  "devDependencies": {
41
43
  "jest": "^30.2.0"
42
44
  },
43
- "gitHead": "29de300fd5e2c36f9d6d00f09eb9f1508997a904"
45
+ "gitHead": "bd8186b5123999b338ce09aa04cd75d7deb0427a"
44
46
  }
@@ -24,6 +24,10 @@ const TABS = [
24
24
  id: 'consultancy/reports',
25
25
  label: 'consultancy.nav.reports',
26
26
  },
27
+ {
28
+ id: 'consultancy/resumes',
29
+ label: 'consultancy.nav.resumes',
30
+ },
27
31
  {
28
32
  id: 'consultancy/employees',
29
33
  label: 'consultancy.nav.employees',
@@ -68,7 +68,7 @@ function recordMeta (resource, byId, language) {
68
68
  /**
69
69
  * Storage-style list of one consultancy schema, with the resource panel beside it.
70
70
  */
71
- export function ConsultancyRecordList ({ schemaId, icon, listHeader, emptyText }) {
71
+ export function ConsultancyRecordList ({ schemaId, icon, listHeader, emptyText, extraPanels }) {
72
72
  const sdk = useSdk()
73
73
  const { language } = useLocale()
74
74
  const { selectedResourceId, setSelectedResourceId, clearSelectedResourceId } = useSelectedResourceId()
@@ -131,7 +131,14 @@ export function ConsultancyRecordList ({ schemaId, icon, listHeader, emptyText }
131
131
  </List>
132
132
  )}
133
133
  panel={selectedResourceId
134
- ? <ResourcePanel width="100%" resourceId={selectedResourceId} onClose={clearSelectedResourceId} />
134
+ ? (
135
+ <ResourcePanel
136
+ width="100%"
137
+ resourceId={selectedResourceId}
138
+ onClose={clearSelectedResourceId}
139
+ extraPanels={extraPanels}
140
+ />
141
+ )
135
142
  : null}
136
143
  />
137
144
  )
@@ -145,6 +152,7 @@ export function ConsultancyRecordPage ({
145
152
  icon,
146
153
  listHeader,
147
154
  emptyText,
155
+ extraPanels,
148
156
  }) {
149
157
  const statusTags = (Definition.status ?? [])
150
158
  .map((status) => ({ beta: 'Beta', 'coming-soon': 'Coming Soon' }[status]))
@@ -165,6 +173,7 @@ export function ConsultancyRecordPage ({
165
173
  icon={icon}
166
174
  listHeader={listHeader}
167
175
  emptyText={emptyText}
176
+ extraPanels={extraPanels}
168
177
  />
169
178
  </View>
170
179
  </Page>
@@ -48,9 +48,9 @@ function createHref (router, schemaId) {
48
48
  * Add CTA for consultancy schemas.
49
49
  * Without `schemaId`, opens a dropdown of document types instead of the type-picker page.
50
50
  * With `schemaId`, links straight to that type's create form.
51
- * @param {{ schemaId?: string }} [props]
51
+ * @param {{ schemaId?: string, before?: import('react').ReactNode }} [props]
52
52
  */
53
- export function CreateConsultancyButton ({ schemaId, ...props }) {
53
+ export function CreateConsultancyButton ({ schemaId, before, ...props }) {
54
54
  const { t } = useLocale()
55
55
  const router = useRouter()
56
56
 
@@ -77,6 +77,7 @@ export function CreateConsultancyButton ({ schemaId, ...props }) {
77
77
  >
78
78
  <View inset="xs" surface="primary" roundness="s">
79
79
  <ContextMenu roundness="s" surface="primary">
80
+ {before}
80
81
  {ADD_TYPES.map(({ schema, label }) => (
81
82
  <ContextMenu.Item
82
83
  key={schema.id}
package/src/Forecast.jsx CHANGED
@@ -1,33 +1,9 @@
1
1
  import React from 'react'
2
2
  import { DashboardLayout, Panel, View, Text, useLocale } from '@ossy/design-system'
3
- import { CalendarDaySurfaceStyles, useForecast } from '@ossy/calendar'
3
+ import { useForecast } from '@ossy/calendar'
4
4
  import { CurrentMonthForecastPanel } from './current-month.component.jsx'
5
5
  import { KpiTrendPanel, UtilizationPanel, YearTotalsPanel } from './forecast-panels.jsx'
6
-
7
- const calendarGrid = {
8
- display: 'grid',
9
- width: '100%',
10
- minWidth: 0,
11
- gridTemplateColumns: 'repeat(7, minmax(0, 1fr))',
12
- gap: '4px',
13
- justifyItems: 'center',
14
- alignItems: 'center',
15
- }
16
-
17
- const calendarDayLayout = {
18
- boxSizing: 'border-box',
19
- display: 'flex',
20
- justifyContent: 'center',
21
- alignItems: 'center',
22
- width: '100%',
23
- maxWidth: 32,
24
- aspectRatio: '1',
25
- minWidth: 0,
26
- borderRadius: '50%',
27
- padding: 0,
28
- fontSize: '.6rem',
29
- margin: 0,
30
- }
6
+ import { MonthDayGrid } from './MonthDayGrid.jsx'
31
7
 
32
8
  export const Forecast = () => {
33
9
  const months = useForecast()
@@ -37,7 +13,6 @@ export const Forecast = () => {
37
13
 
38
14
  return (
39
15
  <>
40
- <CalendarDaySurfaceStyles />
41
16
  <DashboardLayout gap="xs">
42
17
  <DashboardLayout.Widget span={4}>
43
18
  <CurrentMonthForecastPanel />
@@ -52,9 +27,6 @@ export const Forecast = () => {
52
27
  <KpiTrendPanel />
53
28
  </DashboardLayout.Widget>
54
29
  {months.map(month => {
55
- const startPad = month.days[0].isoWeekday - 1
56
- const totalCells = startPad + month.days.length
57
- const endPad = (7 - (totalCells % 7)) % 7
58
30
  const monthKey = `${month.year}-${month.month}`
59
31
 
60
32
  return (
@@ -100,29 +72,7 @@ export const Forecast = () => {
100
72
 
101
73
  </View>
102
74
 
103
- <div style={{ ...calendarGrid, padding: '0 var(--space-m) var(--space-m)' }}>
104
-
105
- {Array.from({ length: startPad }, (_, i) => (
106
- <div key={`${monthKey}-pad-s-${i}`} />
107
- ))}
108
-
109
- {month.days.map(day => (
110
- <Text
111
- key={`${monthKey}-${day.monthDay}`}
112
- variant="small"
113
- data-ossy-calendar-day
114
- data-day-off={!day.isWorkday}
115
- style={calendarDayLayout}
116
- >
117
- {day.monthDay}
118
- </Text>
119
- ))}
120
-
121
- {Array.from({ length: endPad }, (_, i) => (
122
- <div key={`${monthKey}-pad-e-${i}`} />
123
- ))}
124
-
125
- </div>
75
+ <MonthDayGrid month={month} />
126
76
  </Panel>
127
77
  </DashboardLayout.Widget>
128
78
  )
@@ -0,0 +1,68 @@
1
+ import React from 'react'
2
+ import { Text } from '@ossy/design-system'
3
+ import { CalendarDaySurfaceStyles } from '@ossy/calendar'
4
+
5
+ const calendarGrid = {
6
+ display: 'grid',
7
+ width: '100%',
8
+ minWidth: 0,
9
+ gridTemplateColumns: 'repeat(7, minmax(0, 1fr))',
10
+ gap: '4px',
11
+ justifyItems: 'center',
12
+ alignItems: 'center',
13
+ }
14
+
15
+ const calendarDayLayout = {
16
+ boxSizing: 'border-box',
17
+ display: 'flex',
18
+ justifyContent: 'center',
19
+ alignItems: 'center',
20
+ width: '100%',
21
+ maxWidth: 32,
22
+ aspectRatio: '1',
23
+ minWidth: 0,
24
+ borderRadius: '50%',
25
+ padding: 0,
26
+ fontSize: '.6rem',
27
+ margin: 0,
28
+ }
29
+
30
+ /**
31
+ * Day numbers for one forecast month, Monday first.
32
+ * Days off use the shared calendar day surface.
33
+ *
34
+ * @param {{ month?: { year?: number|string, month?: string, days?: Array<{ monthDay?: number|string, isoWeekday?: number, isWorkday?: boolean }> } }} props
35
+ */
36
+ export function MonthDayGrid ({ month }) {
37
+ const days = Array.isArray(month?.days) ? month.days : []
38
+ if (!days.length) return null
39
+
40
+ const startPad = Math.max(0, (Number(days[0].isoWeekday) || 1) - 1)
41
+ const endPad = (7 - ((startPad + days.length) % 7)) % 7
42
+ const monthKey = `${month.year}-${month.month}`
43
+
44
+ return (
45
+ <>
46
+ <CalendarDaySurfaceStyles />
47
+ <div style={{ ...calendarGrid, padding: '0 var(--space-m) var(--space-m)' }}>
48
+ {Array.from({ length: startPad }, (_, index) => (
49
+ <div key={`${monthKey}-pad-s-${index}`} />
50
+ ))}
51
+ {days.map((day) => (
52
+ <Text
53
+ key={`${monthKey}-${day.monthDay}`}
54
+ variant="small"
55
+ data-ossy-calendar-day
56
+ data-day-off={!day.isWorkday}
57
+ style={calendarDayLayout}
58
+ >
59
+ {day.monthDay}
60
+ </Text>
61
+ ))}
62
+ {Array.from({ length: endPad }, (_, index) => (
63
+ <div key={`${monthKey}-pad-e-${index}`} />
64
+ ))}
65
+ </div>
66
+ </>
67
+ )
68
+ }
@@ -0,0 +1,52 @@
1
+ import React from 'react'
2
+ import { List, Text, View } from '@ossy/design-system'
3
+ import { useRouter } from '@ossy/router-react'
4
+ import { AsyncStatus, useSdk } from '@ossy/sdk-react'
5
+ import { ListResources } from '@ossy/resources'
6
+ import { referenceId } from '@ossy/resumes/resume-links'
7
+ import { ConsultancySchema } from './schema-ids.js'
8
+ import { matchesLocation } from './locations.js'
9
+
10
+ /**
11
+ * Saved matches for one request. Embedding and ranking happen when the
12
+ * request or a resume changes, not when this panel opens.
13
+ */
14
+ export function RequestMatches ({ requestId, resourceId }) {
15
+ const id = requestId || resourceId
16
+ const sdk = useSdk()
17
+ const router = useRouter()
18
+ const { data: resources = [], status } = sdk.read(ListResources, { location: matchesLocation })
19
+ const loading = status === AsyncStatus.Loading || status === AsyncStatus.NotInitialized
20
+ const match = (Array.isArray(resources) ? resources : []).find((resource) => (
21
+ resource?.type === ConsultancySchema.requestMatches
22
+ && referenceId(resource?.content?.request) === id
23
+ ))
24
+ const matches = Array.isArray(match?.content?.matches) ? match.content.matches : []
25
+
26
+ return (
27
+ <View gap="s" inset="m" data-request-matches={loading ? 'loading' : match ? 'ready' : 'pending'}>
28
+ {loading ? <Text color="secondary" text="consultancy.matches.loading" /> : null}
29
+ {!loading && !match ? <Text color="secondary" text="consultancy.matches.pending" /> : null}
30
+ {!loading && match && matches.length === 0 ? (
31
+ <Text color="secondary" text="consultancy.matches.empty" />
32
+ ) : null}
33
+ {!loading && matches.length > 0 ? (
34
+ <List>
35
+ {matches.map((item) => (
36
+ <List.Item
37
+ key={item.resourceId}
38
+ href={router.getHref({
39
+ id: '@resume',
40
+ params: { resumeId: item.resourceId, workspaceId: router.params.workspaceId },
41
+ })}
42
+ data-resource-name={item.name || undefined}
43
+ meta={item.shared?.length ? <Text variant="small">{item.shared.join(', ')}</Text> : null}
44
+ >
45
+ {item.name || item.resourceId}
46
+ </List.Item>
47
+ ))}
48
+ </List>
49
+ ) : null}
50
+ </View>
51
+ )
52
+ }
@@ -2,6 +2,7 @@ import React from 'react'
2
2
  import { Panel, Text, View, useLocale } from '@ossy/design-system'
3
3
  import { DataLoader, useForecast } from '@ossy/calendar'
4
4
  import { ForecastWidgetMenu } from './forecast-widget-menu.jsx'
5
+ import { MonthDayGrid } from './MonthDayGrid.jsx'
5
6
 
6
7
  export const CURRENT_MONTH_WIDGET_ID = '@ossy/consultancy/view/current-month'
7
8
 
@@ -58,12 +59,15 @@ export function CurrentMonthForecastPanel ({ dashboardId, pinnedWidgetId }) {
58
59
  <Text color="secondary" text="consultancy.forecasts.widget.empty" />
59
60
  </View>
60
61
  ) : (
61
- <View gap="s" inset="m">
62
- <MetricRow label="consultancy.forecasts.income" value={money(current.projectedIncome)} />
63
- <MetricRow label="consultancy.forecasts.salaryCost" value={money(current.monthlyCostOfEmployees)} />
64
- <MetricRow label="consultancy.forecasts.revenue" value={money(current.revenue)} />
65
- <MetricRow label="consultancy.forecasts.hoursWorked" value={hours(current.hoursWorked)} />
66
- </View>
62
+ <>
63
+ <View gap="s" inset="m">
64
+ <MetricRow label="consultancy.forecasts.income" value={money(current.projectedIncome)} />
65
+ <MetricRow label="consultancy.forecasts.salaryCost" value={money(current.monthlyCostOfEmployees)} />
66
+ <MetricRow label="consultancy.forecasts.revenue" value={money(current.revenue)} />
67
+ <MetricRow label="consultancy.forecasts.hoursWorked" value={hours(current.hoursWorked)} />
68
+ </View>
69
+ <MonthDayGrid month={current} />
70
+ </>
67
71
  )}
68
72
  </Panel>
69
73
  )
@@ -7,6 +7,7 @@
7
7
  "consultancy/contracts.documentTitle": "Contracts",
8
8
  "consultancy/opportunities.documentTitle": "Opportunities",
9
9
  "consultancy/requests.documentTitle": "Requests",
10
+ "consultancy/resumes.documentTitle": "Resumes",
10
11
  "consultancy/proposals.documentTitle": "Proposals",
11
12
  "consultancy/reports.documentTitle": "Reports",
12
13
  "consultancy.home.title": "Overview",
@@ -20,6 +21,7 @@
20
21
  "consultancy.nav.vacations": "Vacations",
21
22
  "consultancy.nav.contracts": "Contracts",
22
23
  "consultancy.nav.requests": "Requests",
24
+ "consultancy.nav.resumes": "Resumes",
23
25
  "consultancy.nav.opportunities": "Opportunities",
24
26
  "consultancy.nav.proposals": "Proposals",
25
27
  "consultancy.nav.reports": "Reports",
@@ -75,6 +77,19 @@
75
77
  "consultancy.requests.title": "Requests",
76
78
  "consultancy.requests.description": "Assignments parsed from inbound email",
77
79
  "consultancy.requests.empty": "No requests yet.",
80
+ "consultancy.matches.title": "Matching resumes",
81
+ "consultancy.matches.loading": "Matching resumes…",
82
+ "consultancy.matches.empty": "No resumes to match.",
83
+ "consultancy.matches.error": "Could not match resumes.",
84
+ "consultancy.matches.embeddingsUnavailable": "Showing tag overlap. Similarity is unavailable.",
85
+ "consultancy.matches.pending": "Matches are prepared when a request or resume changes.",
86
+ "@ossy/consultancy/actions/refresh-matches.label": "Refresh matches",
87
+ "@ossy/consultancy/actions/refresh-matches.description": "Embed changed requests and resumes, then save their matches",
88
+ "@ossy/consultancy/actions/match-resumes.label": "Match resumes",
89
+ "@ossy/consultancy/actions/match-resumes.description": "Rank resumes in this workspace against a request by shared tags and similarity",
90
+ "consultancy.resumes.title": "Resumes",
91
+ "consultancy.resumes.description": "Resumes in this workspace, linked to a profile and experiences",
92
+ "consultancy.resumes.empty": "No resumes yet.",
78
93
  "consultancy.requests.statsTitle": "Incoming requests",
79
94
  "consultancy.requests.statsSeries": "Requests",
80
95
  "consultancy.requests.statsUnit": "requests",
@@ -165,6 +180,32 @@
165
180
  "@ossy/consultancy/schema/vacation.start.description": "First day of vacation (inclusive). These days are not billed.",
166
181
  "@ossy/consultancy/schema/vacation.end.label": "Last day off",
167
182
  "@ossy/consultancy/schema/vacation.end.description": "Last day of vacation (inclusive).",
183
+ "@ossy/consultancy/schema/request.title.label": "Title",
184
+ "@ossy/consultancy/schema/request.title.description": "Title of the assignment.",
185
+ "@ossy/consultancy/schema/request.summary.label": "Summary",
186
+ "@ossy/consultancy/schema/request.summary.description": "What the client is asking for.",
187
+ "@ossy/consultancy/schema/request.role.label": "Role",
188
+ "@ossy/consultancy/schema/request.role.description": "The profile they are looking for.",
189
+ "@ossy/consultancy/schema/request.tags.label": "Skills",
190
+ "@ossy/consultancy/schema/request.tags.description": "Skills or technologies named in the request.",
191
+ "@ossy/consultancy/schema/request.location.label": "Location",
192
+ "@ossy/consultancy/schema/request.location.description": "Where the work happens.",
193
+ "@ossy/consultancy/schema/request.duration.label": "Duration",
194
+ "@ossy/consultancy/schema/request.duration.description": "How long the assignment lasts.",
195
+ "@ossy/consultancy/schema/request.start.label": "Start",
196
+ "@ossy/consultancy/schema/request.start.description": "When the assignment starts.",
197
+ "@ossy/consultancy/schema/request.rate.label": "Rate",
198
+ "@ossy/consultancy/schema/request.rate.description": "Amount without a currency symbol.",
199
+ "@ossy/consultancy/schema/request.currency.label": "Currency",
200
+ "@ossy/consultancy/schema/request.currency.description": "Currency of the rate.",
201
+ "@ossy/consultancy/schema/request.contactName.label": "Contact",
202
+ "@ossy/consultancy/schema/request.contactName.description": "The person who sent the request.",
203
+ "@ossy/consultancy/schema/request.contactEmail.label": "Contact email",
204
+ "@ossy/consultancy/schema/request.contactEmail.description": "That person's email address.",
205
+ "@ossy/consultancy/schema/request.messageId.label": "Message id",
206
+ "@ossy/consultancy/schema/request.messageId.description": "Id of the inbound email.",
207
+ "@ossy/consultancy/schema/request.receivedAt.label": "Received",
208
+ "@ossy/consultancy/schema/request.receivedAt.description": "When the email was sent.",
168
209
  "@ossy/consultancy/schema/opportunity.title.label": "Title",
169
210
  "@ossy/consultancy/schema/opportunity.title.description": "Short name for this lead or opportunity.",
170
211
  "@ossy/consultancy/schema/opportunity.source.label": "Source",
@@ -1,7 +1,9 @@
1
+ import { forwardedOriginal } from '@ossy/email/forwarded-original'
1
2
  import { ConsultancySchema } from './schema-ids.js'
2
3
  import { location } from './locations.js'
3
4
 
4
5
  const GetResource = { id: '@ossy/resources/actions/get' }
6
+ const ListResources = { id: '@ossy/resources/actions/list' }
5
7
  const CreateResource = { id: '@ossy/resources/actions/create' }
6
8
  const ExtractStructuredData = { id: '@ossy/media-tasks/actions/extract-structured-data' }
7
9
  const INBOUND_MESSAGE = '@ossy/email/schema/inbound-message'
@@ -43,14 +45,23 @@ function workspaceIdFrom ({ event, payload, req }) {
43
45
  */
44
46
  export function requestSourceText (resource) {
45
47
  const content = resource?.content && typeof resource.content === 'object' ? resource.content : {}
48
+ const forward = forwardedOriginal(typeof content.text === 'string' ? content.text : '')
49
+ const subject = forward?.subject || content.subject
50
+ const from = forward?.from || content.from
51
+ const body = (forward?.body || (typeof content.text === 'string' ? content.text : '')).trim()
46
52
  const lines = []
47
- if (content.subject) lines.push(`Subject: ${content.subject}`)
48
- if (content.from) lines.push(`From: ${content.from}`)
49
- const body = typeof content.text === 'string' ? content.text.trim() : ''
53
+ if (subject) lines.push(`Subject: ${subject}`)
54
+ if (from) lines.push(`From: ${from}`)
50
55
  if (body) lines.push('', body)
51
56
  return lines.join('\n').trim()
52
57
  }
53
58
 
59
+ function asResourceList (result) {
60
+ if (Array.isArray(result)) return result
61
+ if (Array.isArray(result?.items)) return result.items
62
+ return []
63
+ }
64
+
54
65
  /**
55
66
  * Inbound assignment → extract-structured-data → a consultancy request resource.
56
67
  * Screening decides whether this runs. It does not listen to every inbound message.
@@ -70,6 +81,13 @@ export async function run ({ event, payload, req, sdk }) {
70
81
  const text = requestSourceText(resource)
71
82
  if (!text) fail('text is required', 400)
72
83
 
84
+ const messageId = typeof resource.content?.messageId === 'string' ? resource.content.messageId : ''
85
+ if (messageId) {
86
+ const listed = await sdk.invoke(ListResources, { location, workspaceId })
87
+ const existing = asResourceList(listed).find((item) => item?.content?.messageId === messageId)
88
+ if (existing?.id) return { id: existing.id, workspaceId, content: existing.content }
89
+ }
90
+
73
91
  const extracted = await sdk.invoke(ExtractStructuredData, {
74
92
  schemaId: ConsultancySchema.request,
75
93
  text,
@@ -78,7 +96,6 @@ export async function run ({ event, payload, req, sdk }) {
78
96
  const data = extracted?.data
79
97
  if (!data || typeof data !== 'object') fail('extraction is required', 422)
80
98
 
81
- const messageId = typeof resource.content?.messageId === 'string' ? resource.content.messageId : ''
82
99
  const receivedAt = typeof resource.content?.receivedAt === 'string' ? resource.content.receivedAt.trim() : ''
83
100
  const content = {
84
101
  ...data,
@@ -4,6 +4,7 @@ import requestSchema from './request.schema.js'
4
4
  import { metadata, requestSourceText, run } from './extract-request.task.js'
5
5
 
6
6
  const GetResource = { id: '@ossy/resources/actions/get' }
7
+ const ListResources = { id: '@ossy/resources/actions/list' }
7
8
  const CreateResource = { id: '@ossy/resources/actions/create' }
8
9
  const ExtractStructuredData = { id: '@ossy/media-tasks/actions/extract-structured-data' }
9
10
 
@@ -12,7 +13,7 @@ const inbound = {
12
13
  type: '@ossy/email/schema/inbound-message',
13
14
  content: {
14
15
  from: 'Anna Berg <anna@client.se>',
15
- to: 'requests+ws-1@inbound.ossy.se',
16
+ to: 'inbox+ws-1@inbound.ossy.se',
16
17
  subject: 'Senior React, 6 manader',
17
18
  text: 'Vi soker en senior React-utvecklare i Stockholm. Uppdraget ar 6 manader med start i januari. Anna Berg, anna@client.se.',
18
19
  messageId: 'assignment-1@client.se',
@@ -24,7 +25,7 @@ const extracted = {
24
25
  title: 'Senior React, 6 manader',
25
26
  summary: 'Senior React developer in Stockholm for 6 months, starting in January.',
26
27
  role: 'Senior React developer',
27
- skills: 'React',
28
+ tags: ['React'],
28
29
  location: 'Stockholm',
29
30
  duration: '6 months',
30
31
  start: 'January',
@@ -49,6 +50,7 @@ describe('extract-request task', () => {
49
50
  async invoke (action, payload) {
50
51
  calls.push({ id: action.id, payload })
51
52
  if (action.id === GetResource.id) return inbound
53
+ if (action.id === ListResources.id) return []
52
54
  if (action.id === ExtractStructuredData.id) return { data: extracted }
53
55
  if (action.id === CreateResource.id) return { id: 'request-1' }
54
56
  throw new Error(`unexpected ${action.id}`)
@@ -86,4 +88,44 @@ describe('extract-request task', () => {
86
88
  content: created.content,
87
89
  })
88
90
  })
91
+
92
+ it('reads the original sender from a forwarded body', () => {
93
+ const text = requestSourceText({
94
+ content: {
95
+ from: 'oskars.sylwan@ossy.se',
96
+ subject: 'Fwd: Teknisk specialist SDK, Stockholm',
97
+ text: [
98
+ '---------- Forwarded message ---------',
99
+ 'From: Client <client@studio.se>',
100
+ 'Subject: Teknisk specialist SDK, Stockholm',
101
+ '',
102
+ 'Vi behöver en specialist i Stockholm.',
103
+ ].join('\n'),
104
+ },
105
+ })
106
+ expect(text).toContain('From: client@studio.se')
107
+ expect(text).toContain('Subject: Teknisk specialist SDK, Stockholm')
108
+ expect(text).not.toContain('oskars.sylwan@ossy.se')
109
+ })
110
+
111
+ it('returns the request already filed for this message', async () => {
112
+ const calls = []
113
+ const sdk = {
114
+ async invoke (action) {
115
+ calls.push(action.id)
116
+ if (action.id === GetResource.id) return inbound
117
+ if (action.id === ListResources.id) return [{ id: 'request-existing', content: { messageId: inbound.content.messageId } }]
118
+ throw new Error(`unexpected ${action.id}`)
119
+ },
120
+ }
121
+
122
+ const result = await run({
123
+ payload: { resourceId: inbound.id, workspaceId: 'ws-1' },
124
+ sdk,
125
+ })
126
+
127
+ expect(result.id).toBe('request-existing')
128
+ expect(calls).not.toContain(ExtractStructuredData.id)
129
+ expect(calls).not.toContain(CreateResource.id)
130
+ })
89
131
  })
package/src/locations.js CHANGED
@@ -1,2 +1,5 @@
1
1
  /** Workspace-scoped consultancy company, employee, and contract resources. */
2
2
  export const location = '/@ossy/consultancy/'
3
+
4
+ /** Saved match results. Kept out of the consultancy folder list. */
5
+ export const matchesLocation = '/@ossy/consultancy/matches/'
@@ -0,0 +1,5 @@
1
+ export const metadata = {
2
+ id: '@ossy/consultancy/actions/match-resumes',
3
+ access: 'workspace',
4
+ label: '@ossy/consultancy/actions/match-resumes.label',
5
+ }