@ossy/consultancy 3.24.1 → 3.26.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.
Files changed (54) hide show
  1. package/README.md +7 -7
  2. package/package.json +7 -5
  3. package/src/ConsultancyNav.jsx +6 -6
  4. package/src/CreateConsultancyButton.jsx +21 -7
  5. package/src/Forecast.jsx +38 -37
  6. package/src/MonthDayGrid.jsx +18 -50
  7. package/src/RequestMatches.jsx +29 -19
  8. package/src/RequestStatsPanel.jsx +1 -1
  9. package/src/ResumeMatches.jsx +51 -0
  10. package/src/calendar-quarter-months.js +36 -0
  11. package/src/calendar-quarter-months.spec.js +22 -0
  12. package/src/create-company.flow.js +9 -9
  13. package/src/current-month.component.jsx +14 -25
  14. package/src/delete-company.flow.js +5 -5
  15. package/src/en.translations.json +17 -32
  16. package/src/extract-request.task.js +20 -13
  17. package/src/extract-request.task.spec.js +7 -3
  18. package/src/file-inbound-request.task.js +93 -0
  19. package/src/file-inbound-request.task.spec.js +118 -0
  20. package/src/forecast-figures.jsx +42 -0
  21. package/src/forecast-panels.jsx +29 -42
  22. package/src/index.js +0 -1
  23. package/src/intake-categories.js +6 -22
  24. package/src/kpi-trend.component.jsx +1 -1
  25. package/src/match-reasons.js +85 -0
  26. package/src/match-reasons.spec.js +73 -0
  27. package/src/match-resumes.js +12 -7
  28. package/src/match-resumes.spec.js +13 -8
  29. package/src/match-resumes.task.js +1 -22
  30. package/src/match-resumes.task.spec.js +19 -14
  31. package/src/{consultancy.page.jsx → overview.page.jsx} +7 -7
  32. package/src/refresh-matches.js +38 -0
  33. package/src/refresh-matches.spec.js +31 -1
  34. package/src/refresh-matches.task.js +322 -72
  35. package/src/refresh-matches.task.spec.js +229 -27
  36. package/src/request.schema.js +0 -1
  37. package/src/{resume-inbound-screening.task.js → resume-inbound-requests.task.js} +12 -14
  38. package/src/{resume-inbound-screening.task.spec.js → resume-inbound-requests.task.spec.js} +32 -18
  39. package/src/resumes.page.jsx +43 -12
  40. package/src/schema-ids.js +0 -1
  41. package/src/spend-for-month.js +67 -0
  42. package/src/spend-for-month.spec.js +41 -0
  43. package/src/spend-year.jsx +91 -0
  44. package/src/{org.page.jsx → spend.page.jsx} +14 -13
  45. package/src/sv.translations.json +17 -32
  46. package/src/use-chart-months.js +5 -2
  47. package/src/use-spend-by-month.js +52 -0
  48. package/src/utilization.component.jsx +1 -1
  49. package/src/view-forecasts.flow.js +3 -3
  50. package/src/year-totals.component.jsx +1 -1
  51. package/src/Overview.jsx +0 -91
  52. package/src/company-basic-info.schema.js +0 -25
  53. package/src/screen-inbound.task.js +0 -133
  54. package/src/screen-inbound.task.spec.js +0 -154
@@ -1,6 +1,7 @@
1
1
  import React, { useMemo } from 'react'
2
- import { LineChart, Panel, Text, View, useLocale } from '@ossy/design-system'
2
+ import { LineChart, Panel, View } from '@ossy/design-system'
3
3
  import { sumFiscalYearTotals } from '@ossy/calendar'
4
+ import { ForecastFigures } from './forecast-figures.jsx'
4
5
  import { ForecastWidgetMenu } from './forecast-widget-menu.jsx'
5
6
  import { useChartMonths } from './use-chart-months.js'
6
7
 
@@ -8,34 +9,27 @@ export const KPI_TREND_WIDGET_ID = '@ossy/consultancy/view/kpi-trend'
8
9
  export const YEAR_TOTALS_WIDGET_ID = '@ossy/consultancy/view/year-totals'
9
10
  export const UTILIZATION_WIDGET_ID = '@ossy/consultancy/view/utilization'
10
11
 
12
+ const LEGEND_STYLE = {
13
+ forecast: 'consultancy.forecasts.forecast',
14
+ actual: 'consultancy.forecasts.actual',
15
+ }
16
+
11
17
  const KPI_SERIES = [
12
- { key: 'projectedIncome', label: 'consultancy.forecasts.forecastIncome', color: 'var(--color-info, hsl(199, 89%, 43%))', dashed: true },
13
- { key: 'actualIncome', label: 'consultancy.forecasts.actualIncome', color: 'var(--color-info, hsl(199, 89%, 43%))' },
14
- { key: 'monthlyCostOfEmployees', label: 'consultancy.forecasts.salaryCost', color: 'var(--color-warning, hsl(38, 92%, 50%))', dashed: true },
15
- { key: 'revenue', label: 'consultancy.forecasts.forecastRevenue', color: 'var(--color-accent, hsl(167, 89%, 43%))', dashed: true },
16
- { key: 'actualRevenue', label: 'consultancy.forecasts.actualRevenue', color: 'var(--color-accent, hsl(167, 89%, 43%))' },
18
+ { key: 'projectedIncome', label: 'consultancy.forecasts.forecastIncome', legendLabel: 'consultancy.forecasts.income', color: 'var(--surface-info, hsl(199, 89%, 43%))', dashed: true },
19
+ { key: 'actualIncome', label: 'consultancy.forecasts.actualIncome', legendLabel: 'consultancy.forecasts.income', color: 'var(--surface-info, hsl(199, 89%, 43%))' },
20
+ { key: 'monthlyCostOfEmployees', label: 'consultancy.forecasts.salaryCost', color: 'var(--surface-warning, hsl(38, 92%, 50%))' },
21
+ { key: 'moneyOut', label: 'consultancy.forecasts.costs', color: 'var(--surface-danger, hsl(0, 89%, 43%))' },
17
22
  ]
18
23
 
24
+ const HOURS_COLOR = 'var(--surface-accent, hsl(167, 89%, 43%))'
25
+
19
26
  const UTILIZATION_SERIES = [
20
- { key: 'forecastHours', label: 'consultancy.forecasts.forecastHours', color: 'var(--color-info, hsl(199, 89%, 43%))', scale: 'hours', dashed: true },
21
- { key: 'actualHours', label: 'consultancy.forecasts.actualHours', color: 'var(--color-accent, hsl(167, 89%, 43%))', scale: 'hours' },
27
+ { key: 'forecastHours', label: 'consultancy.forecasts.forecastHours', legendLabel: 'consultancy.forecasts.hours', color: HOURS_COLOR, scale: 'hours', dashed: true },
28
+ { key: 'actualHours', label: 'consultancy.forecasts.actualHours', legendLabel: 'consultancy.forecasts.hours', color: HOURS_COLOR, scale: 'hours' },
22
29
  ]
23
30
 
24
31
  const panelStyle = { height: '100%', flex: '1 1 auto', minWidth: 0 }
25
32
 
26
- function useMoneyAndHours () {
27
- const { language } = useLocale()
28
- const money = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-SE', {
29
- style: 'currency',
30
- currency: 'SEK',
31
- }).format(value)
32
- const hours = (value) => new Intl.NumberFormat(language === 'sv' ? 'sv-SE' : 'en-GB', {
33
- style: 'unit',
34
- unit: 'hour',
35
- }).format(value)
36
- return { money, hours }
37
- }
38
-
39
33
  export function KpiTrendPanel ({ dashboardId, pinnedWidgetId }) {
40
34
  const months = useChartMonths()
41
35
  return (
@@ -53,7 +47,7 @@ export function KpiTrendPanel ({ dashboardId, pinnedWidgetId }) {
53
47
  <LineChart
54
48
  months={months}
55
49
  series={KPI_SERIES}
56
- unit="consultancy.forecasts.unitMoney"
50
+ legendStyle={LEGEND_STYLE}
57
51
  empty="consultancy.forecasts.yearChartEmpty"
58
52
  />
59
53
  </Panel>
@@ -62,8 +56,11 @@ export function KpiTrendPanel ({ dashboardId, pinnedWidgetId }) {
62
56
 
63
57
  export function YearTotalsPanel ({ dashboardId, pinnedWidgetId }) {
64
58
  const months = useChartMonths()
65
- const { money, hours } = useMoneyAndHours()
66
- const totals = useMemo(() => sumFiscalYearTotals(months), [months])
59
+ const totals = useMemo(() => {
60
+ const summed = sumFiscalYearTotals(months)
61
+ const spend = months.reduce((sum, month) => sum + (Number(month.spend) || 0), 0)
62
+ return { ...summed, spend }
63
+ }, [months])
67
64
 
68
65
  return (
69
66
  <Panel
@@ -78,23 +75,13 @@ export function YearTotalsPanel ({ dashboardId, pinnedWidgetId }) {
78
75
  />
79
76
  )}
80
77
  >
81
- <View gap="s" inset="m">
82
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
83
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.income" />
84
- <Text variant="m" style={{ marginBottom: 0 }}>{money(totals.projectedIncome)}</Text>
85
- </View>
86
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
87
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.salaryCost" />
88
- <Text variant="m" style={{ marginBottom: 0 }}>{money(totals.monthlyCostOfEmployees)}</Text>
89
- </View>
90
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
91
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.revenue" />
92
- <Text variant="m" style={{ marginBottom: 0 }}>{money(totals.revenue)}</Text>
93
- </View>
94
- <View layout="row" gap="s" style={{ justifyContent: 'space-between' }}>
95
- <Text variant="m" style={{ marginBottom: 0 }} text="consultancy.forecasts.hoursWorked" />
96
- <Text variant="m" style={{ marginBottom: 0 }}>{hours(totals.hoursWorked)}</Text>
97
- </View>
78
+ <View inset="m">
79
+ <ForecastFigures
80
+ income={totals.projectedIncome}
81
+ salary={totals.monthlyCostOfEmployees}
82
+ spend={totals.spend}
83
+ hours={totals.hoursWorked}
84
+ />
98
85
  </View>
99
86
  </Panel>
100
87
  )
@@ -117,7 +104,7 @@ export function UtilizationPanel ({ dashboardId, pinnedWidgetId }) {
117
104
  <LineChart
118
105
  months={months}
119
106
  series={UTILIZATION_SERIES}
120
- unit="consultancy.forecasts.unitHours"
107
+ legendStyle={LEGEND_STYLE}
121
108
  empty="consultancy.forecasts.yearChartEmpty"
122
109
  />
123
110
  </Panel>
package/src/index.js CHANGED
@@ -2,7 +2,6 @@ export { location } from './locations.js'
2
2
  export { ConsultancySchema } from './schema-ids.js'
3
3
  export { default as employeeSchema } from './employee.schema.js'
4
4
  export { default as contractSchema } from './contract.schema.js'
5
- export { default as companyBasicInfoSchema } from './company-basic-info.schema.js'
6
5
  export { default as vacationSchema } from './vacation.schema.js'
7
6
  export { default as opportunitySchema } from './opportunity.schema.js'
8
7
  export { default as requestSchema } from './request.schema.js'
@@ -1,3 +1,5 @@
1
+ import { registerIntakeCategory } from '@ossy/email/intake-categories'
2
+
1
3
  /** Category the intake pipeline files as a consultancy request. */
2
4
  export const REQUEST_CATEGORY = 'consultancy-request'
3
5
 
@@ -7,28 +9,10 @@ export const REQUEST_CATEGORY = 'consultancy-request'
7
9
  */
8
10
  export const MIN_REQUEST_CONFIDENCE = 0.8
9
11
 
10
- /**
11
- * Contrasting options so a contact, invoice, or receipt is not forced
12
- * into a consultancy request. The chosen category is the only route.
13
- */
14
- export const INTAKE_CATEGORIES = Object.freeze([
15
- {
16
- name: REQUEST_CATEGORY,
17
- description: 'Someone is offering or asking for a consulting assignment, role, or engagement.',
18
- },
19
- {
20
- name: 'invoice',
21
- description: 'A bill asking to be paid, with an amount due.',
22
- },
23
- {
24
- name: 'receipt',
25
- description: 'Proof that a payment was already made.',
26
- },
27
- {
28
- name: 'contact',
29
- description: 'A general message, question, or introduction that is none of the above.',
30
- },
31
- ])
12
+ registerIntakeCategory({
13
+ name: REQUEST_CATEGORY,
14
+ description: 'Someone is offering or asking for a consulting assignment, role, or engagement.',
15
+ })
32
16
 
33
17
  /**
34
18
  * @param {{ category?: string | null, confidence?: number | null } | null | undefined} result
@@ -13,5 +13,5 @@ export const metadata = {
13
13
 
14
14
  /** Slot widget — fiscal-year KPI trend for dashboards. */
15
15
  export default function KpiTrendWidget (props) {
16
- return <DataLoader content={<KpiTrendPanel {...props} />} />
16
+ return <DataLoader emptyGuide={false} content={<KpiTrendPanel {...props} />} />
17
17
  }
@@ -0,0 +1,85 @@
1
+ import { referenceId } from '@ossy/resumes/resume-links'
2
+ import { ConsultancySchema } from './schema-ids.js'
3
+ import { matchesLocation } from './locations.js'
4
+
5
+ /**
6
+ * True when a ranked match has something to show: shared tags or a
7
+ * positive similarity score.
8
+ */
9
+ export function hasMatchSignal (item) {
10
+ if (Array.isArray(item?.shared) && item.shared.length > 0) return true
11
+ return typeof item?.similarity === 'number' && item.similarity > 0
12
+ }
13
+
14
+ /**
15
+ * Shared tags to render as match reasons (deduped, trimmed).
16
+ */
17
+ export function sharedTagsOf (item) {
18
+ if (!Array.isArray(item?.shared)) return []
19
+ return item.shared.filter((tag) => typeof tag === 'string' && tag.trim())
20
+ }
21
+
22
+ /** List payload for the one match document of a request. */
23
+ export function requestMatchesRead (requestId) {
24
+ return {
25
+ location: matchesLocation,
26
+ query: {
27
+ type: ConsultancySchema.requestMatches,
28
+ 'content.request.resourceId': requestId,
29
+ },
30
+ }
31
+ }
32
+
33
+ /** List payload for the match documents that include this resume. */
34
+ export function resumeMatchesRead (resumeId) {
35
+ return {
36
+ location: matchesLocation,
37
+ query: {
38
+ type: ConsultancySchema.requestMatches,
39
+ 'content.matches.resourceId': resumeId,
40
+ },
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Invert saved request-matches docs into the requests that hit one resume.
46
+ * Only rows with a match signal are kept, strongest score first.
47
+ *
48
+ * @param {object[]} resources list from matchesLocation
49
+ * @param {string} resumeId
50
+ * @returns {Array<{
51
+ * requestId: string,
52
+ * name: string,
53
+ * shared: string[],
54
+ * tagScore: number,
55
+ * similarity: number | null,
56
+ * score: number,
57
+ * }>}
58
+ */
59
+ export function matchesForResume (resources, resumeId) {
60
+ if (!resumeId) return []
61
+ const out = []
62
+ for (const resource of Array.isArray(resources) ? resources : []) {
63
+ if (resource?.type !== ConsultancySchema.requestMatches) continue
64
+ const requestId = referenceId(resource?.content?.request)
65
+ if (!requestId) continue
66
+ const matches = Array.isArray(resource?.content?.matches) ? resource.content.matches : []
67
+ const hit = matches.find((item) => item?.resourceId === resumeId)
68
+ if (!hit || !hasMatchSignal(hit)) continue
69
+ out.push({
70
+ requestId,
71
+ name: typeof resource.name === 'string' && resource.name.trim()
72
+ ? resource.name.trim()
73
+ : requestId,
74
+ shared: sharedTagsOf(hit),
75
+ tagScore: hit.tagScore,
76
+ similarity: hit.similarity ?? null,
77
+ score: Number.isFinite(hit.score) ? hit.score : 0,
78
+ })
79
+ }
80
+ return out.sort((a, b) => (
81
+ b.score - a.score
82
+ || b.shared.length - a.shared.length
83
+ || a.name.localeCompare(b.name)
84
+ ))
85
+ }
@@ -0,0 +1,73 @@
1
+ import { ConsultancySchema } from './schema-ids.js'
2
+ import { hasMatchSignal, matchesForResume, requestMatchesRead, resumeMatchesRead, sharedTagsOf } from './match-reasons.js'
3
+
4
+ describe('match reasons', () => {
5
+ it('treats shared tags or positive similarity as a signal', () => {
6
+ expect(hasMatchSignal({ shared: ['React'] })).toBe(true)
7
+ expect(hasMatchSignal({ shared: [], similarity: 0.4 })).toBe(true)
8
+ expect(hasMatchSignal({ shared: [], similarity: 0 })).toBe(false)
9
+ expect(hasMatchSignal({ shared: [], similarity: null })).toBe(false)
10
+ })
11
+
12
+ it('keeps non-empty shared tags', () => {
13
+ expect(sharedTagsOf({ shared: [' React ', '', 'Node.js'] })).toEqual([' React ', 'Node.js'])
14
+ expect(sharedTagsOf({})).toEqual([])
15
+ })
16
+
17
+ it('reads one request match document, and the match documents that include a resume', () => {
18
+ expect(requestMatchesRead('req-1')).toEqual({
19
+ location: '/@ossy/consultancy/matches/',
20
+ query: {
21
+ type: '@ossy/consultancy/schema/request-matches',
22
+ 'content.request.resourceId': 'req-1',
23
+ },
24
+ })
25
+ expect(resumeMatchesRead('resume-a').query['content.matches.resourceId']).toBe('resume-a')
26
+ })
27
+
28
+ it('inverts request-matches docs onto one resume', () => {
29
+ const resources = [
30
+ {
31
+ type: ConsultancySchema.requestMatches,
32
+ name: 'React role',
33
+ content: {
34
+ request: { resourceId: 'req-1' },
35
+ matches: [
36
+ { resourceId: 'resume-a', shared: ['React'], score: 1.2, similarity: 0.7 },
37
+ { resourceId: 'resume-b', shared: [], score: 0, similarity: null },
38
+ ],
39
+ },
40
+ },
41
+ {
42
+ type: ConsultancySchema.requestMatches,
43
+ name: 'Design role',
44
+ content: {
45
+ request: { resourceId: 'req-2' },
46
+ matches: [
47
+ { resourceId: 'resume-a', shared: [], score: 0.5, similarity: 0.5 },
48
+ ],
49
+ },
50
+ },
51
+ {
52
+ type: ConsultancySchema.requestMatches,
53
+ name: 'Noise',
54
+ content: {
55
+ request: { resourceId: 'req-3' },
56
+ matches: [
57
+ { resourceId: 'resume-a', shared: [], score: 0, similarity: 0 },
58
+ ],
59
+ },
60
+ },
61
+ ]
62
+
63
+ expect(matchesForResume(resources, 'resume-a').map((item) => item.requestId))
64
+ .toEqual(['req-1', 'req-2'])
65
+ expect(matchesForResume(resources, 'resume-a')[0]).toMatchObject({
66
+ name: 'React role',
67
+ shared: ['React'],
68
+ score: 1.2,
69
+ })
70
+ expect(matchesForResume(resources, 'resume-b')).toEqual([])
71
+ expect(matchesForResume(resources, '')).toEqual([])
72
+ })
73
+ })
@@ -21,6 +21,10 @@ export function tagsOf (value) {
21
21
  return tags
22
22
  }
23
23
 
24
+ export function resourceTags (resource) {
25
+ return tagsOf(resource?.tags)
26
+ }
27
+
24
28
  export function tagOverlap (requestTags, resumeTags) {
25
29
  const resumeByKey = new Map(resumeTags.map((tag) => [tag.toLowerCase(), tag]))
26
30
  const shared = []
@@ -50,7 +54,7 @@ export function requestMatchText (resource) {
50
54
  line('Title', content.title || resource?.name),
51
55
  line('Summary', content.summary),
52
56
  line('Role', content.role),
53
- line('Tags', tagsOf(content.tags).join(', ')),
57
+ line('Tags', resourceTags(resource).join(', ')),
54
58
  line('Location', content.location),
55
59
  line('Duration', content.duration),
56
60
  line('Start', content.start),
@@ -61,7 +65,7 @@ export function resumeMatchText (resume, { profile, experiences } = {}) {
61
65
  const content = resume?.content && typeof resume.content === 'object' ? resume.content : {}
62
66
  const lines = [
63
67
  line('Resume', resume?.name),
64
- line('Tags', tagsOf(content.tags).join(', ')),
68
+ line('Tags', resourceTags(resume).join(', ')),
65
69
  ]
66
70
  const profileContent = profile?.content && typeof profile.content === 'object' ? profile.content : null
67
71
  if (profileContent) {
@@ -69,7 +73,7 @@ export function resumeMatchText (resume, { profile, experiences } = {}) {
69
73
  line('Name', profileContent.name),
70
74
  line('Role', profileContent.role),
71
75
  line('Summary', profileContent.summary),
72
- line('Profile tags', tagsOf(profileContent.tags).join(', ')),
76
+ line('Profile tags', resourceTags(profile).join(', ')),
73
77
  )
74
78
  }
75
79
  for (const experience of experiences || []) {
@@ -81,7 +85,7 @@ export function resumeMatchText (resume, { profile, experiences } = {}) {
81
85
  line('Subtitle', textField(experienceContent, 'subtitle', 'Sub Title')),
82
86
  line('Kind', textField(experienceContent, 'kind', 'Type of experience')),
83
87
  line('Description', textField(experienceContent, 'description', 'Description')),
84
- line('Experience tags', tagsOf(experienceContent.tags ?? experienceContent.Tags).join(', ')),
88
+ line('Experience tags', resourceTags(experience).join(', ')),
85
89
  )
86
90
  }
87
91
  return lines.filter(Boolean).join('\n')
@@ -95,7 +99,7 @@ export function resumeMatchText (resume, { profile, experiences } = {}) {
95
99
  * }} input
96
100
  */
97
101
  export function rankMatches ({ request, resumes, similarities = [] } = {}) {
98
- const requestTags = tagsOf(request?.content?.tags)
102
+ const requestTags = resourceTags(request)
99
103
  const similarityById = new Map()
100
104
  for (const item of similarities || []) {
101
105
  if (!item?.resourceId || !Number.isFinite(item.score)) continue
@@ -105,12 +109,13 @@ export function rankMatches ({ request, resumes, similarities = [] } = {}) {
105
109
  return (resumes || [])
106
110
  .filter((resume) => resume?.id && resume.id !== request?.id)
107
111
  .map((resume) => {
108
- const overlap = tagOverlap(requestTags, tagsOf(resume?.content?.tags))
112
+ const resumeTags = resourceTags(resume)
113
+ const overlap = tagOverlap(requestTags, resumeTags)
109
114
  const similarity = similarityById.has(resume.id) ? similarityById.get(resume.id) : null
110
115
  return {
111
116
  resourceId: resume.id,
112
117
  name: typeof resume.name === 'string' ? resume.name : '',
113
- tags: tagsOf(resume?.content?.tags),
118
+ tags: resumeTags,
114
119
  shared: overlap.shared,
115
120
  tagScore: overlap.score,
116
121
  similarity,
@@ -1,13 +1,13 @@
1
- import { rankMatches, requestMatchText, resumeMatchText, tagOverlap, tagsOf } from './match-resumes.js'
1
+ import { rankMatches, requestMatchText, resourceTags, resumeMatchText, tagOverlap, tagsOf } from './match-resumes.js'
2
2
 
3
3
  const request = {
4
4
  id: 'request-1',
5
5
  name: 'Senior React consultant',
6
+ tags: ['React', 'Node.js'],
6
7
  content: {
7
8
  title: 'Senior React consultant',
8
9
  summary: 'A product team wants a React and Node.js consultant.',
9
10
  role: 'Senior frontend',
10
- tags: ['React', 'Node.js'],
11
11
  location: 'Stockholm',
12
12
  },
13
13
  }
@@ -18,6 +18,11 @@ describe('match resumes', () => {
18
18
  expect(tagsOf('React, Node.js')).toEqual(['React', 'Node.js'])
19
19
  })
20
20
 
21
+ it('reads tags from the resource', () => {
22
+ expect(resourceTags({ tags: [' React ', 'react', 'Node.js'] })).toEqual(['React', 'Node.js'])
23
+ expect(resourceTags({ tags: [], content: { tags: ['React'] } })).toEqual([])
24
+ })
25
+
21
26
  it('scores tag overlap as the share of the request tags that the resume has', () => {
22
27
  expect(tagOverlap(['React', 'Node.js'], ['react', 'TypeScript'])).toEqual({
23
28
  shared: ['react'],
@@ -30,18 +35,18 @@ describe('match resumes', () => {
30
35
  expect(requestMatchText(request)).toContain('Tags: React, Node.js')
31
36
  expect(resumeMatchText({
32
37
  name: 'React consultant',
33
- content: { tags: ['React', 'Node.js'] },
38
+ tags: ['React', 'Node.js'],
34
39
  }, {
35
- profile: { content: { name: 'Ada Consultant', role: 'Senior React consultant' } },
36
- experiences: [{ content: { Title: 'Platform engineer', Tags: 'React, Node.js' } }],
40
+ profile: { tags: ['React'], content: { name: 'Ada Consultant', role: 'Senior React consultant' } },
41
+ experiences: [{ tags: ['React', 'Node.js'], content: { Title: 'Platform engineer' } }],
37
42
  })).toContain('Experience: Platform engineer')
38
43
  })
39
44
 
40
45
  it('orders resumes by tag overlap plus similarity', () => {
41
46
  const resumes = [
42
- { id: 'low', name: 'Design', content: { tags: ['Figma'] } },
43
- { id: 'tags-only', name: 'React', content: { tags: ['React', 'Node.js'] } },
44
- { id: 'both', name: 'Full stack', content: { tags: ['React'] } },
47
+ { id: 'low', name: 'Design', tags: ['Figma'] },
48
+ { id: 'tags-only', name: 'React', tags: ['React', 'Node.js'] },
49
+ { id: 'both', name: 'Full stack', tags: ['React'] },
45
50
  ]
46
51
  const ranked = rankMatches({
47
52
  request,
@@ -1,12 +1,7 @@
1
1
  import { scoreRequests } from './refresh-matches.task.js'
2
- import { location as resumeLocation } from '@ossy/resumes/locations'
3
- import { ResumesSchema } from '@ossy/resumes/schema-ids'
4
2
  import { ConsultancySchema } from './schema-ids.js'
5
- import { location, matchesLocation } from './locations.js'
6
- import { referenceId } from '@ossy/resumes/resume-links'
7
3
 
8
4
  const GetResource = { id: '@ossy/resources/actions/get' }
9
- const ListResources = { id: '@ossy/resources/actions/list' }
10
5
 
11
6
  export const metadata = {
12
7
  id: '@ossy/consultancy/tasks/match-resumes',
@@ -22,15 +17,10 @@ function fail (message, status) {
22
17
  throw Object.assign(new Error(message), { status })
23
18
  }
24
19
 
25
- function asResourceList (result) {
26
- if (Array.isArray(result)) return result
27
- if (Array.isArray(result?.items)) return result.items
28
- return []
29
- }
30
-
31
20
  /**
32
21
  * Re-rank one request from embeddings that already exist. Does not embed.
33
22
  * New and changed documents are embedded by the refresh-matches task.
23
+ * The candidate resumes come from a vector search plus a tag query.
34
24
  */
35
25
  export async function run ({ payload, req, sdk }) {
36
26
  if (!sdk?.invoke) fail('sdk is required', 500)
@@ -44,20 +34,9 @@ export async function run ({ payload, req, sdk }) {
44
34
  if (request?.type !== ConsultancySchema.request) fail('request is required', 400)
45
35
  if (request.belongsTo && request.belongsTo !== workspaceId) fail('request is required', 404)
46
36
 
47
- const listed = async (listLocation) => asResourceList(await sdk.invoke(ListResources, {
48
- location: listLocation,
49
- workspaceId,
50
- }))
51
- const resumes = (await listed(resumeLocation)).filter((item) => item?.type === ResumesSchema.resume)
52
- const existing = (await listed(matchesLocation)).filter((item) => (
53
- item?.type === ConsultancySchema.requestMatches && referenceId(item?.content?.request) === request.id
54
- ))
55
-
56
37
  const saved = await scoreRequests(sdk, {
57
38
  workspaceId,
58
39
  requests: [request],
59
- resumes,
60
- existing,
61
40
  })
62
41
  const match = saved[0]
63
42
  return {
@@ -1,11 +1,13 @@
1
1
  import { beforeEach, describe, expect, it, jest } from '@jest/globals'
2
2
 
3
- const loadWorkspaceEmbeddings = jest.fn()
3
+ const getEmbedding = jest.fn()
4
+ const searchEmbeddings = jest.fn()
4
5
 
5
6
  jest.unstable_mockModule('@ossy/platform/vector/vector-store', () => ({
6
- getEmbedding: jest.fn(),
7
- loadWorkspaceEmbeddings,
8
- cosineSimilarity: () => 0.8,
7
+ getEmbedding,
8
+ searchEmbeddings,
9
+ setEmbeddingKind: jest.fn(),
10
+ cosineSimilarity: () => 0.2,
9
11
  }))
10
12
 
11
13
  const { run } = await import('./match-resumes.task.js')
@@ -20,33 +22,35 @@ const request = {
20
22
  type: '@ossy/consultancy/schema/request',
21
23
  belongsTo: 'ws-1',
22
24
  name: 'Senior React consultant',
23
- content: { title: 'Senior React consultant', tags: ['React'] },
25
+ tags: ['React'],
26
+ content: { title: 'Senior React consultant' },
24
27
  }
25
28
 
26
29
  const resume = {
27
30
  id: 'resume-1',
28
31
  type: '@ossy/resumes/schema/resume',
29
32
  name: 'React consultant',
30
- content: { tags: ['React'] },
33
+ tags: ['React'],
34
+ content: {},
31
35
  }
32
36
 
33
37
  describe('match-resumes task', () => {
34
38
  beforeEach(() => {
35
- loadWorkspaceEmbeddings.mockReset()
36
- loadWorkspaceEmbeddings.mockResolvedValue([
37
- { resourceId: 'request-1', vector: [1] },
38
- { resourceId: 'resume-1', vector: [1] },
39
- ])
39
+ getEmbedding.mockReset()
40
+ searchEmbeddings.mockReset()
41
+ getEmbedding.mockResolvedValue({ vector: [1], kind: 'request' })
42
+ searchEmbeddings.mockResolvedValue([{ resourceId: 'resume-1', score: 0.8 }])
40
43
  })
41
44
 
42
- it('ranks from stored embeddings and does not embed', async () => {
45
+ it('ranks from a vector search and does not embed', async () => {
43
46
  const created = []
44
47
  const sdk = {
45
48
  invoke: jest.fn(async (action, payload) => {
46
49
  if (action.id === GetResource.id) return request
47
50
  if (action.id === ListResources.id) {
48
- if (payload.location === '/@ossy/resumes/') return [resume]
49
- return []
51
+ if (payload.query?.id?.$in) return [resume]
52
+ if (payload.location === '/@ossy/consultancy/matches/') return []
53
+ return [resume]
50
54
  }
51
55
  if (action.id === CreateResource.id) {
52
56
  created.push(payload)
@@ -62,6 +66,7 @@ describe('match-resumes task', () => {
62
66
  sdk,
63
67
  })
64
68
 
69
+ expect(searchEmbeddings).toHaveBeenCalledWith(expect.objectContaining({ kind: 'resume', limit: 20 }))
65
70
  expect(created[0].content.matches[0].resourceId).toBe('resume-1')
66
71
  expect(result.matches[0]).toMatchObject({ resourceId: 'resume-1', similarity: 0.8 })
67
72
  })
@@ -1,20 +1,20 @@
1
1
  import React from 'react'
2
2
  import { View, Page, Tags } from '@ossy/design-system'
3
- import { Forecast } from './Forecast.jsx'
4
3
  import { DataLoader } from '@ossy/calendar'
4
+ import { Forecast } from './Forecast.jsx'
5
5
  import { Definition } from './Definition.js'
6
6
  import { CreateConsultancyButton } from './CreateConsultancyButton.jsx'
7
7
  import { ConsultancyNav } from './ConsultancyNav.jsx'
8
8
 
9
9
  export const metadata = {
10
- id: 'consultancy/home',
10
+ id: 'consultancy/overview',
11
11
  path: {
12
12
  sv: '/konsultverksamhet',
13
13
  en: '/consultancy',
14
14
  },
15
15
  }
16
16
 
17
- export const ConsultancyPage = () => {
17
+ export const OverviewPage = () => {
18
18
  const statusTags = (Definition.status ?? [])
19
19
  .map((s) => ({ beta: 'Beta', 'coming-soon': 'Coming Soon' }[s]))
20
20
  .filter(Boolean)
@@ -22,17 +22,17 @@ export const ConsultancyPage = () => {
22
22
  return (
23
23
  <Page
24
24
  data-forecasts-status="on"
25
- title="consultancy.home.title"
25
+ title="consultancy.overview.title"
26
26
  near={statusTags.length > 0 ? <Tags tags={statusTags} size="s" /> : undefined}
27
- description="consultancy.home.description"
27
+ description="consultancy.overview.description"
28
28
  far={<CreateConsultancyButton />}
29
29
  >
30
30
  <View gap="m">
31
- <ConsultancyNav active="consultancy/home" />
31
+ <ConsultancyNav active="consultancy/overview" />
32
32
  <DataLoader content={<Forecast />} />
33
33
  </View>
34
34
  </Page>
35
35
  )
36
36
  }
37
37
 
38
- export default ConsultancyPage
38
+ export default OverviewPage