@mastra/factory 0.30.0-alpha.3 → 0.30.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 (71) hide show
  1. package/README.md +1 -1
  2. package/dist/boards/phase-runner.d.ts +2 -0
  3. package/dist/boards/phase-runner.d.ts.map +1 -1
  4. package/dist/boards/phase-runner.js +1 -1
  5. package/dist/boards/phase-runner.js.map +1 -1
  6. package/dist/factory.js.map +1 -1
  7. package/dist/integrations/slack/chat-tools.d.ts.map +1 -1
  8. package/dist/integrations/slack/chat-tools.js +62 -0
  9. package/dist/integrations/slack/chat-tools.js.map +1 -1
  10. package/dist/mcp/routes.d.ts.map +1 -1
  11. package/dist/mcp/routes.js +6 -5
  12. package/dist/mcp/routes.js.map +1 -1
  13. package/dist/routes/contracts.d.ts +1 -1
  14. package/dist/routes/contracts.d.ts.map +1 -1
  15. package/dist/routes/contracts.js +9 -3
  16. package/dist/routes/contracts.js.map +1 -1
  17. package/dist/routes/work-item-selection.d.ts +2 -2
  18. package/dist/routes/work-item-selection.js +7 -7
  19. package/dist/routes/work-item-selection.js.map +1 -1
  20. package/dist/rules/dispatcher.d.ts.map +1 -1
  21. package/dist/rules/dispatcher.js +2 -1
  22. package/dist/rules/dispatcher.js.map +1 -1
  23. package/dist/rules/phase-goal.d.ts +4 -0
  24. package/dist/rules/phase-goal.d.ts.map +1 -1
  25. package/dist/rules/phase-goal.js +6 -3
  26. package/dist/rules/phase-goal.js.map +1 -1
  27. package/dist/rules/transition-service.d.ts +2 -0
  28. package/dist/rules/transition-service.d.ts.map +1 -1
  29. package/dist/rules/transition-service.js +44 -14
  30. package/dist/rules/transition-service.js.map +1 -1
  31. package/dist/storage/domains/work-items/base.d.ts.map +1 -1
  32. package/dist/storage/domains/work-items/base.js +28 -0
  33. package/dist/storage/domains/work-items/base.js.map +1 -1
  34. package/dist/tools/read-tools.d.ts.map +1 -1
  35. package/dist/tools/read-tools.js +6 -10
  36. package/dist/tools/read-tools.js.map +1 -1
  37. package/dist/tools/reports.d.ts +3 -0
  38. package/dist/tools/reports.d.ts.map +1 -1
  39. package/dist/tools/reports.js +7 -2
  40. package/dist/tools/reports.js.map +1 -1
  41. package/dist/work-items/board-phases.js +4 -4
  42. package/dist/work-items/board-phases.js.map +1 -1
  43. package/dist/work-items/card-facts.d.ts +3 -2
  44. package/dist/work-items/card-facts.d.ts.map +1 -1
  45. package/dist/work-items/card-facts.js +2 -2
  46. package/dist/work-items/card-facts.js.map +1 -1
  47. package/dist/work-items/card-number.d.ts +11 -2
  48. package/dist/work-items/card-number.d.ts.map +1 -1
  49. package/dist/work-items/card-number.js +2 -1
  50. package/dist/work-items/card-number.js.map +1 -1
  51. package/dist/work-items/card-reference.d.ts +2 -0
  52. package/dist/work-items/card-reference.d.ts.map +1 -1
  53. package/dist/work-items/card-reference.js +2 -1
  54. package/dist/work-items/card-reference.js.map +1 -1
  55. package/dist/work-items/card-search.d.ts +5 -0
  56. package/dist/work-items/card-search.d.ts.map +1 -0
  57. package/dist/work-items/card-search.js +19 -0
  58. package/dist/work-items/card-search.js.map +1 -0
  59. package/dist/work-items/search-terms.d.ts +75 -0
  60. package/dist/work-items/search-terms.d.ts.map +1 -0
  61. package/dist/work-items/search-terms.js +93 -0
  62. package/dist/work-items/search-terms.js.map +1 -0
  63. package/dist/work-items/search-words.d.ts +5 -2
  64. package/dist/work-items/search-words.d.ts.map +1 -1
  65. package/dist/work-items/search-words.js +7 -4
  66. package/dist/work-items/search-words.js.map +1 -1
  67. package/package.json +10 -10
  68. package/dist/work-items/card-search-text.d.ts +0 -4
  69. package/dist/work-items/card-search-text.d.ts.map +0 -1
  70. package/dist/work-items/card-search-text.js +0 -15
  71. package/dist/work-items/card-search-text.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"card-facts.js","names":[],"sources":["../../src/work-items/card-facts.ts"],"sourcesContent":["import { hasPullRequest } from '../boards/semantics.js';\nimport { isHumanActorId } from '../storage/domains/audit/actors.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\nimport { workItemBranchSource } from '../work-item-branch.js';\nimport type { WorkItemBranchSource } from '../work-item-branch.js';\nimport { metadataLabels } from './card-labels.js';\nimport { factoryParticipantId, providerPeople } from './card-people.js';\nimport type { BoardRelations, ProviderPerson, ProviderPersonRole } from './card-people.js';\nimport { cardSearchText } from './card-search-text.js';\nimport type { SourceFacts } from './card-source-filters.js';\n\n/** What a board view's search and filters read of a card. */\nexport interface CardFacts extends SourceFacts {\n hasPullRequest: boolean;\n labels: ReadonlySet<string>;\n /** The people the card's source names. */\n people: Record<ProviderPersonRole, ProviderPerson[]>;\n /** Participant ids by role: the source's people, and the Factory users who worked on the card. */\n relations: BoardRelations;\n /** The Factory users who created the card, moved it or started a session on it. */\n humanActorIds: readonly string[];\n /** Lowercased, so a search lowercases only its own words. */\n text: string;\n}\n\n// A card object never changes: `listShared` gives a changed card a new object.\nconst factsByCard = new WeakMap<Card, CardFacts>();\n\n/**\n * What the card's source says of it. A card no provider filed has no source: its facts are its\n * work item's with the card's own on top, as clients read them.\n */\nexport function sourceMetadata({ workItem, metadata }: Card): Record<string, unknown> {\n if (workItem.provider === 'factory') return { ...workItem.metadata, ...metadata };\n return {\n ...workItem.metadata,\n labels: workItem.labels,\n author: workItem.author,\n state: workItem.state,\n identifier: workItem.key,\n };\n}\n\nfunction humanActorIds(card: Card): string[] {\n const ids = new Set<string>();\n const add = (actorId: string | undefined) => {\n if (isHumanActorId(actorId)) ids.add(actorId);\n };\n add(card.createdBy);\n for (const entry of card.stageHistory) {\n add(entry.by);\n add(entry.exitedBy);\n }\n for (const session of Object.values(card.sessions)) add(session.startedBy);\n return [...ids];\n}\n\n/** The card's facts, computed once for every view that reads the card. */\nexport function cardFacts(card: Card): CardFacts {\n let facts = factsByCard.get(card);\n if (facts) return facts;\n // A Slack thread is its own source on the board, not a card filed by hand.\n const source: WorkItemBranchSource =\n card.externalSource?.integrationId === 'slack' ? 'slack-thread' : workItemBranchSource(card.externalSource);\n const metadata = sourceMetadata(card);\n const people = providerPeople({ source, metadata });\n const actorIds = humanActorIds(card);\n const authored = new Set(people.authored.map(person => person.id));\n // A card filed by hand has no source to name its author: the person who filed it is.\n if (source === 'manual' && isHumanActorId(card.createdBy)) authored.add(factoryParticipantId(card.createdBy));\n facts = {\n source,\n metadata,\n hasPullRequest: hasPullRequest({ source, workItem: card.workItem }),\n labels: new Set(metadataLabels(metadata)),\n people,\n relations: {\n worked: new Set(actorIds.map(factoryParticipantId)),\n authored,\n assigned: new Set(people.assigned.map(person => person.id)),\n 'review-requested': new Set(people['review-requested'].map(person => person.id)),\n },\n humanActorIds: actorIds,\n text: cardSearchText(card),\n };\n factsByCard.set(card, facts);\n return facts;\n}\n"],"mappings":";;;;;;;AA0BA,MAAM,8BAAc,IAAI,QAAyB;;;;;AAMjD,SAAgB,eAAe,EAAE,UAAU,YAA2C;CACpF,IAAI,SAAS,aAAa,WAAW,OAAO;EAAE,GAAG,SAAS;EAAU,GAAG;CAAS;CAChF,OAAO;EACL,GAAG,SAAS;EACZ,QAAQ,SAAS;EACjB,QAAQ,SAAS;EACjB,OAAO,SAAS;EAChB,YAAY,SAAS;CACvB;AACF;AAEA,SAAS,cAAc,MAAsB;CAC3C,MAAM,sBAAM,IAAI,IAAY;CAC5B,MAAM,OAAO,YAAgC;EAC3C,IAAI,eAAe,OAAO,GAAG,IAAI,IAAI,OAAO;CAC9C;CACA,IAAI,KAAK,SAAS;CAClB,KAAK,MAAM,SAAS,KAAK,cAAc;EACrC,IAAI,MAAM,EAAE;EACZ,IAAI,MAAM,QAAQ;CACpB;CACA,KAAK,MAAM,WAAW,OAAO,OAAO,KAAK,QAAQ,GAAG,IAAI,QAAQ,SAAS;CACzE,OAAO,CAAC,GAAG,GAAG;AAChB;;AAGA,SAAgB,UAAU,MAAuB;CAC/C,IAAI,QAAQ,YAAY,IAAI,IAAI;CAChC,IAAI,OAAO,OAAO;CAElB,MAAM,SACJ,KAAK,gBAAgB,kBAAkB,UAAU,iBAAiB,qBAAqB,KAAK,cAAc;CAC5G,MAAM,WAAW,eAAe,IAAI;CACpC,MAAM,SAAS,eAAe;EAAE;EAAQ;CAAS,CAAC;CAClD,MAAM,WAAW,cAAc,IAAI;CACnC,MAAM,WAAW,IAAI,IAAI,OAAO,SAAS,KAAI,WAAU,OAAO,EAAE,CAAC;CAEjE,IAAI,WAAW,YAAY,eAAe,KAAK,SAAS,GAAG,SAAS,IAAI,qBAAqB,KAAK,SAAS,CAAC;CAC5G,QAAQ;EACN;EACA;EACA,gBAAgB,eAAe;GAAE;GAAQ,UAAU,KAAK;EAAS,CAAC;EAClE,QAAQ,IAAI,IAAI,eAAe,QAAQ,CAAC;EACxC;EACA,WAAW;GACT,QAAQ,IAAI,IAAI,SAAS,IAAI,oBAAoB,CAAC;GAClD;GACA,UAAU,IAAI,IAAI,OAAO,SAAS,KAAI,WAAU,OAAO,EAAE,CAAC;GAC1D,oBAAoB,IAAI,IAAI,OAAO,mBAAmB,CAAC,KAAI,WAAU,OAAO,EAAE,CAAC;EACjF;EACA,eAAe;EACf,MAAM,eAAe,IAAI;CAC3B;CACA,YAAY,IAAI,MAAM,KAAK;CAC3B,OAAO;AACT"}
1
+ {"version":3,"file":"card-facts.js","names":[],"sources":["../../src/work-items/card-facts.ts"],"sourcesContent":["import { hasPullRequest } from '../boards/semantics.js';\nimport { isHumanActorId } from '../storage/domains/audit/actors.js';\nimport type { Card } from '../storage/domains/work-items/base.js';\nimport { workItemBranchSource } from '../work-item-branch.js';\nimport type { WorkItemBranchSource } from '../work-item-branch.js';\nimport { metadataLabels } from './card-labels.js';\nimport { factoryParticipantId, providerPeople } from './card-people.js';\nimport type { BoardRelations, ProviderPerson, ProviderPersonRole } from './card-people.js';\nimport { cardSearch } from './card-search.js';\nimport type { SourceFacts } from './card-source-filters.js';\nimport type { SearchableCard } from './search-terms.js';\n\n/** What a board view's search and filters read of a card. */\nexport interface CardFacts extends SourceFacts {\n hasPullRequest: boolean;\n labels: ReadonlySet<string>;\n /** The people the card's source names. */\n people: Record<ProviderPersonRole, ProviderPerson[]>;\n /** Participant ids by role: the source's people, and the Factory users who worked on the card. */\n relations: BoardRelations;\n /** The Factory users who created the card, moved it or started a session on it. */\n humanActorIds: readonly string[];\n /** What a search reads of the card, lowercased, so a search lowercases only its own words. */\n search: SearchableCard;\n}\n\n// A card object never changes: `listShared` gives a changed card a new object.\nconst factsByCard = new WeakMap<Card, CardFacts>();\n\n/**\n * What the card's source says of it. A card no provider filed has no source: its facts are its\n * work item's with the card's own on top, as clients read them.\n */\nexport function sourceMetadata({ workItem, metadata }: Card): Record<string, unknown> {\n if (workItem.provider === 'factory') return { ...workItem.metadata, ...metadata };\n return {\n ...workItem.metadata,\n labels: workItem.labels,\n author: workItem.author,\n state: workItem.state,\n identifier: workItem.key,\n };\n}\n\nfunction humanActorIds(card: Card): string[] {\n const ids = new Set<string>();\n const add = (actorId: string | undefined) => {\n if (isHumanActorId(actorId)) ids.add(actorId);\n };\n add(card.createdBy);\n for (const entry of card.stageHistory) {\n add(entry.by);\n add(entry.exitedBy);\n }\n for (const session of Object.values(card.sessions)) add(session.startedBy);\n return [...ids];\n}\n\n/** The card's facts, computed once for every view that reads the card. */\nexport function cardFacts(card: Card): CardFacts {\n let facts = factsByCard.get(card);\n if (facts) return facts;\n // A Slack thread is its own source on the board, not a card filed by hand.\n const source: WorkItemBranchSource =\n card.externalSource?.integrationId === 'slack' ? 'slack-thread' : workItemBranchSource(card.externalSource);\n const metadata = sourceMetadata(card);\n const people = providerPeople({ source, metadata });\n const actorIds = humanActorIds(card);\n const authored = new Set(people.authored.map(person => person.id));\n // A card filed by hand has no source to name its author: the person who filed it is.\n if (source === 'manual' && isHumanActorId(card.createdBy)) authored.add(factoryParticipantId(card.createdBy));\n facts = {\n source,\n metadata,\n hasPullRequest: hasPullRequest({ source, workItem: card.workItem }),\n labels: new Set(metadataLabels(metadata)),\n people,\n relations: {\n worked: new Set(actorIds.map(factoryParticipantId)),\n authored,\n assigned: new Set(people.assigned.map(person => person.id)),\n 'review-requested': new Set(people['review-requested'].map(person => person.id)),\n },\n humanActorIds: actorIds,\n search: cardSearch(card),\n };\n factsByCard.set(card, facts);\n return facts;\n}\n"],"mappings":";;;;;;;AA2BA,MAAM,8BAAc,IAAI,QAAyB;;;;;AAMjD,SAAgB,eAAe,EAAE,UAAU,YAA2C;CACpF,IAAI,SAAS,aAAa,WAAW,OAAO;EAAE,GAAG,SAAS;EAAU,GAAG;CAAS;CAChF,OAAO;EACL,GAAG,SAAS;EACZ,QAAQ,SAAS;EACjB,QAAQ,SAAS;EACjB,OAAO,SAAS;EAChB,YAAY,SAAS;CACvB;AACF;AAEA,SAAS,cAAc,MAAsB;CAC3C,MAAM,sBAAM,IAAI,IAAY;CAC5B,MAAM,OAAO,YAAgC;EAC3C,IAAI,eAAe,OAAO,GAAG,IAAI,IAAI,OAAO;CAC9C;CACA,IAAI,KAAK,SAAS;CAClB,KAAK,MAAM,SAAS,KAAK,cAAc;EACrC,IAAI,MAAM,EAAE;EACZ,IAAI,MAAM,QAAQ;CACpB;CACA,KAAK,MAAM,WAAW,OAAO,OAAO,KAAK,QAAQ,GAAG,IAAI,QAAQ,SAAS;CACzE,OAAO,CAAC,GAAG,GAAG;AAChB;;AAGA,SAAgB,UAAU,MAAuB;CAC/C,IAAI,QAAQ,YAAY,IAAI,IAAI;CAChC,IAAI,OAAO,OAAO;CAElB,MAAM,SACJ,KAAK,gBAAgB,kBAAkB,UAAU,iBAAiB,qBAAqB,KAAK,cAAc;CAC5G,MAAM,WAAW,eAAe,IAAI;CACpC,MAAM,SAAS,eAAe;EAAE;EAAQ;CAAS,CAAC;CAClD,MAAM,WAAW,cAAc,IAAI;CACnC,MAAM,WAAW,IAAI,IAAI,OAAO,SAAS,KAAI,WAAU,OAAO,EAAE,CAAC;CAEjE,IAAI,WAAW,YAAY,eAAe,KAAK,SAAS,GAAG,SAAS,IAAI,qBAAqB,KAAK,SAAS,CAAC;CAC5G,QAAQ;EACN;EACA;EACA,gBAAgB,eAAe;GAAE;GAAQ,UAAU,KAAK;EAAS,CAAC;EAClE,QAAQ,IAAI,IAAI,eAAe,QAAQ,CAAC;EACxC;EACA,WAAW;GACT,QAAQ,IAAI,IAAI,SAAS,IAAI,oBAAoB,CAAC;GAClD;GACA,UAAU,IAAI,IAAI,OAAO,SAAS,KAAI,WAAU,OAAO,EAAE,CAAC;GAC1D,oBAAoB,IAAI,IAAI,OAAO,mBAAmB,CAAC,KAAI,WAAU,OAAO,EAAE,CAAC;EACjF;EACA,eAAe;EACf,QAAQ,WAAW,IAAI;CACzB;CACA,YAAY,IAAI,MAAM,KAAK;CAC3B,OAAO;AACT"}
@@ -1,10 +1,19 @@
1
- import type { Card } from '../storage/domains/work-items/base.js';
2
1
  /**
3
2
  * Board metadata key holding the `#number` of a card filed without an issue
4
3
  * behind it. Kept apart from `number`, which integrations read as the source
5
4
  * issue's number.
6
5
  */
7
6
  export declare const CARD_NUMBER_METADATA_KEY = "cardNumber";
7
+ /**
8
+ * What the number is read from, as the server's card and the browser's both hold it: the facts of
9
+ * its source, and the card's own metadata. The browser's card may lack its source's facts.
10
+ */
11
+ export interface NumberedCard {
12
+ workItem?: {
13
+ metadata?: Record<string, unknown> | null;
14
+ } | null;
15
+ metadata?: Record<string, unknown> | null;
16
+ }
8
17
  /** The number a person sees on the card: the issue or PR number the item was filed from, or the project's own number for a card filed by hand. */
9
- export declare function workItemNumber(item: Pick<Card, 'workItem' | 'metadata'>): number | null;
18
+ export declare function workItemNumber(item: NumberedCard): number | null;
10
19
  //# sourceMappingURL=card-number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"card-number.d.ts","sourceRoot":"","sources":["../../src/work-items/card-number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,eAAe,CAAC;AAErD,kJAAkJ;AAClJ,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC,GAAG,MAAM,GAAG,IAAI,CAOvF"}
1
+ {"version":3,"file":"card-number.d.ts","sourceRoot":"","sources":["../../src/work-items/card-number.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,eAAe,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC3C;AAED,kJAAkJ;AAClJ,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAQhE"}
@@ -7,7 +7,8 @@
7
7
  const CARD_NUMBER_METADATA_KEY = "cardNumber";
8
8
  /** The number a person sees on the card: the issue or PR number the item was filed from, or the project's own number for a card filed by hand. */
9
9
  function workItemNumber(item) {
10
- const number = item.workItem.metadata?.number ?? item.workItem.metadata?.githubIssueNumber ?? item.workItem.metadata?.githubPullRequestNumber ?? item.metadata?.["cardNumber"];
10
+ const facts = item.workItem?.metadata;
11
+ const number = facts?.number ?? facts?.githubIssueNumber ?? facts?.githubPullRequestNumber ?? item.metadata?.["cardNumber"];
11
12
  return typeof number === "number" ? number : null;
12
13
  }
13
14
  export { CARD_NUMBER_METADATA_KEY, workItemNumber };
@@ -1 +1 @@
1
- {"version":3,"file":"card-number.js","names":[],"sources":["../../src/work-items/card-number.ts"],"sourcesContent":["import type { Card } from '../storage/domains/work-items/base.js';\n\n/**\n * Board metadata key holding the `#number` of a card filed without an issue\n * behind it. Kept apart from `number`, which integrations read as the source\n * issue's number.\n */\nexport const CARD_NUMBER_METADATA_KEY = 'cardNumber';\n\n/** The number a person sees on the card: the issue or PR number the item was filed from, or the project's own number for a card filed by hand. */\nexport function workItemNumber(item: Pick<Card, 'workItem' | 'metadata'>): number | null {\n const number =\n item.workItem.metadata?.number ??\n item.workItem.metadata?.githubIssueNumber ??\n item.workItem.metadata?.githubPullRequestNumber ??\n item.metadata?.[CARD_NUMBER_METADATA_KEY];\n return typeof number === 'number' ? number : null;\n}\n"],"mappings":";;;;;;AAOA,MAAa,2BAA2B;;AAGxC,SAAgB,eAAe,MAA0D;CACvF,MAAM,SACJ,KAAK,SAAS,UAAU,UACxB,KAAK,SAAS,UAAU,qBACxB,KAAK,SAAS,UAAU,2BACxB,KAAK,WAAA;CACP,OAAO,OAAO,WAAW,WAAW,SAAS;AAC/C"}
1
+ {"version":3,"file":"card-number.js","names":[],"sources":["../../src/work-items/card-number.ts"],"sourcesContent":["/**\n * Board metadata key holding the `#number` of a card filed without an issue\n * behind it. Kept apart from `number`, which integrations read as the source\n * issue's number.\n */\nexport const CARD_NUMBER_METADATA_KEY = 'cardNumber';\n\n/**\n * What the number is read from, as the server's card and the browser's both hold it: the facts of\n * its source, and the card's own metadata. The browser's card may lack its source's facts.\n */\nexport interface NumberedCard {\n workItem?: { metadata?: Record<string, unknown> | null } | null;\n metadata?: Record<string, unknown> | null;\n}\n\n/** The number a person sees on the card: the issue or PR number the item was filed from, or the project's own number for a card filed by hand. */\nexport function workItemNumber(item: NumberedCard): number | null {\n const facts = item.workItem?.metadata;\n const number =\n facts?.number ??\n facts?.githubIssueNumber ??\n facts?.githubPullRequestNumber ??\n item.metadata?.[CARD_NUMBER_METADATA_KEY];\n return typeof number === 'number' ? number : null;\n}\n"],"mappings":";;;;;;AAKA,MAAa,2BAA2B;;AAYxC,SAAgB,eAAe,MAAmC;CAChE,MAAM,QAAQ,KAAK,UAAU;CAC7B,MAAM,SACJ,OAAO,UACP,OAAO,qBACP,OAAO,2BACP,KAAK,WAAA;CACP,OAAO,OAAO,WAAW,WAAW,SAAS;AAC/C"}
@@ -3,6 +3,8 @@ import type { WorkItemSourceRow } from '../storage/domains/work-items/work-item-
3
3
  export declare function sourceKeyFromReference(reference: string): string | null;
4
4
  /** Whether `reference` is a link or shorthand a card can be found by: a source key, or any other http(s) link. */
5
5
  export declare function isSourceReference(reference: string): boolean;
6
+ /** A link without its query, its anchor, its trailing slashes or its case, which name no other issue or pull request. */
7
+ export declare function normalizedUrl(url: string): string;
6
8
  type SourcedCard = {
7
9
  workItem: {
8
10
  sources?: readonly Pick<WorkItemSourceRow, 'key' | 'url'>[];
@@ -1 +1 @@
1
- {"version":3,"file":"card-reference.d.ts","sourceRoot":"","sources":["../../src/work-items/card-reference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAkB3F,gGAAgG;AAChG,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYvE;AAED,kHAAkH;AAClH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE5D;AAUD,KAAK,WAAW,GAAG;IAAE,QAAQ,EAAE;QAAE,OAAO,CAAC,EAAE,SAAS,IAAI,CAAC,iBAAiB,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAA;KAAE,CAAA;CAAE,CAAC;AAEjG;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAIjH;AAED,4FAA4F;AAC5F,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAGvE;AAED,0GAA0G;AAC1G,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAEzE"}
1
+ {"version":3,"file":"card-reference.d.ts","sourceRoot":"","sources":["../../src/work-items/card-reference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAkB3F,gGAAgG;AAChG,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYvE;AAED,kHAAkH;AAClH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED,yHAAyH;AACzH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED,KAAK,WAAW,GAAG;IAAE,QAAQ,EAAE;QAAE,OAAO,CAAC,EAAE,SAAS,IAAI,CAAC,iBAAiB,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAA;KAAE,CAAA;CAAE,CAAC;AAEjG;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAIjH;AAED,4FAA4F;AAC5F,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAGvE;AAED,0GAA0G;AAC1G,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAEzE"}
@@ -32,6 +32,7 @@ function sourceKeyFromReference(reference) {
32
32
  function isSourceReference(reference) {
33
33
  return sourceKeyFromReference(reference) !== null || URL.test(reference.trim());
34
34
  }
35
+ /** A link without its query, its anchor, its trailing slashes or its case, which name no other issue or pull request. */
35
36
  function normalizedUrl(url) {
36
37
  return url.trim().replace(/[?#].*$/, "").replace(/\/+$/, "").toLowerCase();
37
38
  }
@@ -53,6 +54,6 @@ function isCardFor(card, reference) {
53
54
  function cardCarries(card, reference) {
54
55
  return (card.workItem.sources ?? []).some((source) => sourceMatchesReference(source, reference));
55
56
  }
56
- export { cardCarries, isCardFor, isSourceReference, sourceKeyFromReference, sourceMatchesReference };
57
+ export { cardCarries, isCardFor, isSourceReference, normalizedUrl, sourceKeyFromReference, sourceMatchesReference };
57
58
 
58
59
  //# sourceMappingURL=card-reference.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"card-reference.js","names":[],"sources":["../../src/work-items/card-reference.ts"],"sourcesContent":["import type { WorkItemSourceRow } from '../storage/domains/work-items/work-item-schema.js';\n\n/**\n * What people paste to name an issue or pull request, turned into the key its card's source\n * stores (see the provider adapters in `./providers`): `owner/repo#12` for a GitHub issue or pull\n * request, `group/project#3` and `group/project!7` for a GitLab issue and merge request, and the\n * tracker identifier (`ENG-42`) for Linear, Jira and incident.io.\n */\nconst GITLAB_MERGE_REQUEST_URL = /^https?:\\/\\/[^/\\s]+\\/(.+?)\\/-\\/merge_requests\\/(\\d+)(?:[/?#]|$)/i;\nconst GITLAB_ISSUE_URL = /^https?:\\/\\/[^/\\s]+\\/(.+?)\\/-\\/(?:issues|work_items)\\/(\\d+)(?:[/?#]|$)/i;\nconst GITHUB_URL = /^https?:\\/\\/[^/\\s]+\\/([^/\\s]+\\/[^/\\s]+)\\/(?:issues|pull)\\/(\\d+)(?:[/?#]|$)/i;\n/** Linear (`/<workspace>/issue/ENG-42/<slug>`) and Jira (`/browse/OPS-3`) issue links. */\nconst TRACKER_URL = /^https?:\\/\\/[^/\\s]+\\/(?:[^\\s]*\\/)?(?:issue|browse)\\/([a-z][a-z0-9]*-\\d+)(?:[/?#]|$)/i;\n/** `owner/repo#12`, `group/sub/project!7`. */\nconst REPOSITORY_SHORTHAND = /^[\\w.-]+(?:\\/[\\w.-]+)+[#!]\\d+$/;\nconst TRACKER_IDENTIFIER = /^[a-z][a-z0-9]*-\\d+$/i;\nconst URL = /^https?:\\/\\/\\S+$/i;\n\n/** The source key a link or shorthand names, or null when it names no issue or pull request. */\nexport function sourceKeyFromReference(reference: string): string | null {\n const ref = reference.trim();\n const mergeRequest = GITLAB_MERGE_REQUEST_URL.exec(ref);\n if (mergeRequest) return `${mergeRequest[1]}!${mergeRequest[2]}`;\n const gitlabIssue = GITLAB_ISSUE_URL.exec(ref);\n if (gitlabIssue) return `${gitlabIssue[1]}#${gitlabIssue[2]}`;\n const github = GITHUB_URL.exec(ref);\n if (github) return `${github[1]}#${github[2]}`;\n const tracker = TRACKER_URL.exec(ref);\n if (tracker) return tracker[1]!;\n if (REPOSITORY_SHORTHAND.test(ref) || TRACKER_IDENTIFIER.test(ref)) return ref;\n return null;\n}\n\n/** Whether `reference` is a link or shorthand a card can be found by: a source key, or any other http(s) link. */\nexport function isSourceReference(reference: string): boolean {\n return sourceKeyFromReference(reference) !== null || URL.test(reference.trim());\n}\n\nfunction normalizedUrl(url: string): string {\n return url\n .trim()\n .replace(/[?#].*$/, '')\n .replace(/\\/+$/, '')\n .toLowerCase();\n}\n\ntype SourcedCard = { workItem: { sources?: readonly Pick<WorkItemSourceRow, 'key' | 'url'>[] } };\n\n/**\n * Whether `source` is the issue or pull request `reference` names: by source key, which ignores\n * the rest of a link (`/files`, a comment anchor), or for other links by the link itself.\n */\nexport function sourceMatchesReference(source: Pick<WorkItemSourceRow, 'key' | 'url'>, reference: string): boolean {\n const key = sourceKeyFromReference(reference);\n if (key !== null) return source.key !== null && source.key.toLowerCase() === key.toLowerCase();\n return URL.test(reference.trim()) && source.url !== null && normalizedUrl(source.url) === normalizedUrl(reference);\n}\n\n/** The card's own issue or pull request (its first source) is the one `reference` names. */\nexport function isCardFor(card: SourcedCard, reference: string): boolean {\n const own = card.workItem.sources?.[0];\n return own !== undefined && sourceMatchesReference(own, reference);\n}\n\n/** The card carries the issue or pull request `reference` names, as its own source or an attached one. */\nexport function cardCarries(card: SourcedCard, reference: string): boolean {\n return (card.workItem.sources ?? []).some(source => sourceMatchesReference(source, reference));\n}\n"],"mappings":";;;;;;;AAQA,MAAM,2BAA2B;AACjC,MAAM,mBAAmB;AACzB,MAAM,aAAa;;AAEnB,MAAM,cAAc;;AAEpB,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;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,CAAC,EAAA,CAAG,MAAK,WAAU,uBAAuB,QAAQ,SAAS,CAAC;AAC/F"}
1
+ {"version":3,"file":"card-reference.js","names":[],"sources":["../../src/work-items/card-reference.ts"],"sourcesContent":["import type { WorkItemSourceRow } from '../storage/domains/work-items/work-item-schema.js';\n\n/**\n * What people paste to name an issue or pull request, turned into the key its card's source\n * stores (see the provider adapters in `./providers`): `owner/repo#12` for a GitHub issue or pull\n * request, `group/project#3` and `group/project!7` for a GitLab issue and merge request, and the\n * tracker identifier (`ENG-42`) for Linear, Jira and incident.io.\n */\nconst GITLAB_MERGE_REQUEST_URL = /^https?:\\/\\/[^/\\s]+\\/(.+?)\\/-\\/merge_requests\\/(\\d+)(?:[/?#]|$)/i;\nconst GITLAB_ISSUE_URL = /^https?:\\/\\/[^/\\s]+\\/(.+?)\\/-\\/(?:issues|work_items)\\/(\\d+)(?:[/?#]|$)/i;\nconst GITHUB_URL = /^https?:\\/\\/[^/\\s]+\\/([^/\\s]+\\/[^/\\s]+)\\/(?:issues|pull)\\/(\\d+)(?:[/?#]|$)/i;\n/** Linear (`/<workspace>/issue/ENG-42/<slug>`) and Jira (`/browse/OPS-3`) issue links. */\nconst TRACKER_URL = /^https?:\\/\\/[^/\\s]+\\/(?:[^\\s]*\\/)?(?:issue|browse)\\/([a-z][a-z0-9]*-\\d+)(?:[/?#]|$)/i;\n/** `owner/repo#12`, `group/sub/project!7`. */\nconst REPOSITORY_SHORTHAND = /^[\\w.-]+(?:\\/[\\w.-]+)+[#!]\\d+$/;\nconst TRACKER_IDENTIFIER = /^[a-z][a-z0-9]*-\\d+$/i;\nconst URL = /^https?:\\/\\/\\S+$/i;\n\n/** The source key a link or shorthand names, or null when it names no issue or pull request. */\nexport function sourceKeyFromReference(reference: string): string | null {\n const ref = reference.trim();\n const mergeRequest = GITLAB_MERGE_REQUEST_URL.exec(ref);\n if (mergeRequest) return `${mergeRequest[1]}!${mergeRequest[2]}`;\n const gitlabIssue = GITLAB_ISSUE_URL.exec(ref);\n if (gitlabIssue) return `${gitlabIssue[1]}#${gitlabIssue[2]}`;\n const github = GITHUB_URL.exec(ref);\n if (github) return `${github[1]}#${github[2]}`;\n const tracker = TRACKER_URL.exec(ref);\n if (tracker) return tracker[1]!;\n if (REPOSITORY_SHORTHAND.test(ref) || TRACKER_IDENTIFIER.test(ref)) return ref;\n return null;\n}\n\n/** Whether `reference` is a link or shorthand a card can be found by: a source key, or any other http(s) link. */\nexport function isSourceReference(reference: string): boolean {\n return sourceKeyFromReference(reference) !== null || URL.test(reference.trim());\n}\n\n/** A link without its query, its anchor, its trailing slashes or its case, which name no other issue or pull request. */\nexport function normalizedUrl(url: string): string {\n return url\n .trim()\n .replace(/[?#].*$/, '')\n .replace(/\\/+$/, '')\n .toLowerCase();\n}\n\ntype SourcedCard = { workItem: { sources?: readonly Pick<WorkItemSourceRow, 'key' | 'url'>[] } };\n\n/**\n * Whether `source` is the issue or pull request `reference` names: by source key, which ignores\n * the rest of a link (`/files`, a comment anchor), or for other links by the link itself.\n */\nexport function sourceMatchesReference(source: Pick<WorkItemSourceRow, 'key' | 'url'>, reference: string): boolean {\n const key = sourceKeyFromReference(reference);\n if (key !== null) return source.key !== null && source.key.toLowerCase() === key.toLowerCase();\n return URL.test(reference.trim()) && source.url !== null && normalizedUrl(source.url) === normalizedUrl(reference);\n}\n\n/** The card's own issue or pull request (its first source) is the one `reference` names. */\nexport function isCardFor(card: SourcedCard, reference: string): boolean {\n const own = card.workItem.sources?.[0];\n return own !== undefined && sourceMatchesReference(own, reference);\n}\n\n/** The card carries the issue or pull request `reference` names, as its own source or an attached one. */\nexport function cardCarries(card: SourcedCard, reference: string): boolean {\n return (card.workItem.sources ?? []).some(source => sourceMatchesReference(source, reference));\n}\n"],"mappings":";;;;;;;AAQA,MAAM,2BAA2B;AACjC,MAAM,mBAAmB;AACzB,MAAM,aAAa;;AAEnB,MAAM,cAAc;;AAEpB,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AAC3B,MAAM,M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CAAG,MAAK,WAAU,uBAAuB,QAAQ,SAAS,CAAC;AAC/F"}
@@ -0,0 +1,5 @@
1
+ import type { Card } from '../storage/domains/work-items/base.js';
2
+ import type { SearchableCard } from './search-terms.js';
3
+ /** What a search reads of a card the server holds; see {@link searchableCard}. */
4
+ export declare function cardSearch(card: Card): SearchableCard;
5
+ //# sourceMappingURL=card-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card-search.d.ts","sourceRoot":"","sources":["../../src/work-items/card-search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAGlE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,cAAc,CAWrD"}
@@ -0,0 +1,19 @@
1
+ import { workItemNumber } from "./card-number.js";
2
+ import { searchableCard } from "./search-terms.js";
3
+ // src/work-items/card-search.ts
4
+ /** What a search reads of a card the server holds; see {@link searchableCard}. */
5
+ function cardSearch(card) {
6
+ return searchableCard({
7
+ id: card.id,
8
+ title: card.title,
9
+ number: workItemNumber(card),
10
+ sourceId: card.externalSource?.externalId,
11
+ key: card.workItem.key,
12
+ urls: [card.externalSource?.url, card.workItem.url],
13
+ sources: card.workItem.sources,
14
+ sessions: card.sessions
15
+ });
16
+ }
17
+ export { cardSearch };
18
+
19
+ //# sourceMappingURL=card-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card-search.js","names":[],"sources":["../../src/work-items/card-search.ts"],"sourcesContent":["import type { Card } from '../storage/domains/work-items/base.js';\nimport { workItemNumber } from './card-number.js';\nimport { searchableCard } from './search-terms.js';\nimport type { SearchableCard } from './search-terms.js';\n\n/** What a search reads of a card the server holds; see {@link searchableCard}. */\nexport function cardSearch(card: Card): SearchableCard {\n return searchableCard({\n id: card.id,\n title: card.title,\n number: workItemNumber(card),\n sourceId: card.externalSource?.externalId,\n key: card.workItem.key,\n urls: [card.externalSource?.url, card.workItem.url],\n sources: card.workItem.sources,\n sessions: card.sessions,\n });\n}\n"],"mappings":";;;;AAMA,SAAgB,WAAW,MAA4B;CACrD,OAAO,eAAe;EACpB,IAAI,KAAK;EACT,OAAO,KAAK;EACZ,QAAQ,eAAe,IAAI;EAC3B,UAAU,KAAK,gBAAgB;EAC/B,KAAK,KAAK,SAAS;EACnB,MAAM,CAAC,KAAK,gBAAgB,KAAK,KAAK,SAAS,GAAG;EAClD,SAAS,KAAK,SAAS;EACvB,UAAU,KAAK;CACjB,CAAC;AACH"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * What a card offers a search, lowercased. Built once per card version by the caller, so a search
3
+ * only reads it.
4
+ */
5
+ export interface SearchableCard {
6
+ /** What reads as words: its title, its keys and numbers, its source ids. Never its links: `issues` or `github.com` would find every card. */
7
+ text: string;
8
+ /** What is only ever pasted whole: the card's id, its branches. */
9
+ ids: readonly string[];
10
+ /** The keys of every issue or pull request the card carries, its own and the attached ones (`acme/app#12`, `eng-42`). */
11
+ sourceKeys: readonly string[];
12
+ /** The links of those issues and pull requests, as {@link normalizedUrl} writes them. */
13
+ links: readonly string[];
14
+ }
15
+ /**
16
+ * A card as a search reads it, from whichever side holds it: the server's card or the browser's.
17
+ * Both build their search from it, so the board, the palette and the server agree on what a card answers.
18
+ */
19
+ export interface SearchedCard {
20
+ id: string;
21
+ title: string;
22
+ /** The issue or pull request number the card shows, or the one given to a card filed by hand. */
23
+ number: number | null;
24
+ /** The id its source gave it. */
25
+ sourceId: string | null | undefined;
26
+ /** Its own source's key (`ENG-42`). */
27
+ key: string | null | undefined;
28
+ /** Its own source's links. */
29
+ urls: readonly (string | null | undefined)[];
30
+ /** Every issue and pull request the card carries, its own first. */
31
+ sources: readonly {
32
+ key: string | null;
33
+ url: string | null;
34
+ metadata: Record<string, unknown> | null;
35
+ }[];
36
+ sessions: Readonly<Record<string, {
37
+ branch: string;
38
+ }>>;
39
+ }
40
+ /**
41
+ * What a search reads of a card: its title, its number, its source id and the key of every issue
42
+ * and pull request it carries as words, so a pull request attached to its issue's card finds that
43
+ * card; those keys and links for a pasted link; and its id and branches, pasted whole.
44
+ */
45
+ export declare function searchableCard(card: SearchedCard): SearchableCard;
46
+ /** One word of a typed search, and what else than the card's text finds a card for it. */
47
+ export type SearchTerm =
48
+ /** Anywhere in the card's text: `log` finds `login`, `34` finds `#345`. */
49
+ {
50
+ kind: 'word';
51
+ word: string;
52
+ }
53
+ /** A whole number or key (`#12`, `acme/app#12`, `group/project!7`): never the start of a longer one. */
54
+ | {
55
+ kind: 'reference';
56
+ word: string;
57
+ }
58
+ /** A link to a Factory card. */
59
+ | {
60
+ kind: 'card';
61
+ word: string;
62
+ id: string;
63
+ }
64
+ /** Any other link; `sourceKey` when it names an issue or pull request. */
65
+ | {
66
+ kind: 'link';
67
+ word: string;
68
+ url: string;
69
+ sourceKey: string | null;
70
+ };
71
+ /** The terms of a typed search: one per word, lowercased. Parse once per search, not per card. */
72
+ export declare function searchTerms(query: string): SearchTerm[];
73
+ /** Whether the card answers every term. No terms keep every card. */
74
+ export declare function matchesSearch(card: SearchableCard, terms: readonly SearchTerm[]): boolean;
75
+ //# sourceMappingURL=search-terms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-terms.d.ts","sourceRoot":"","sources":["../../src/work-items/search-terms.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,6IAA6I;IAC7I,IAAI,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IACvB,yHAAyH;IACzH,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,yFAAyF;IACzF,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IAC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AC,KAAK,EAAE,MAAM,GAAG,UAAU,EAAE,CAEvD;AAyCD,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAEzF"}
@@ -0,0 +1,93 @@
1
+ import { normalizedUrl, sourceKeyFromReference } from "./card-reference.js";
2
+ import { searchWords } from "./search-words.js";
3
+ // src/work-items/search-terms.ts
4
+ function lowercased(values) {
5
+ return values.filter((value) => typeof value === "string" && value !== "").map((value) => value.toLowerCase());
6
+ }
7
+ /**
8
+ * What a search reads of a card: its title, its number, its source id and the key of every issue
9
+ * and pull request it carries as words, so a pull request attached to its issue's card finds that
10
+ * card; those keys and links for a pasted link; and its id and branches, pasted whole.
11
+ */
12
+ function searchableCard(card) {
13
+ const keys = lowercased([card.key, ...card.sources.map((source) => source.key)]);
14
+ return {
15
+ text: [...lowercased([
16
+ card.title,
17
+ card.number === null ? null : `#${card.number}`,
18
+ card.sourceId
19
+ ]), ...keys].join(" "),
20
+ ids: lowercased([
21
+ card.id,
22
+ ...Object.values(card.sessions).map((session) => session.branch),
23
+ ...card.sources.map((source) => source.metadata?.headBranch)
24
+ ]),
25
+ sourceKeys: keys,
26
+ links: lowercased([...card.urls, ...card.sources.map((source) => source.url)]).map(normalizedUrl)
27
+ };
28
+ }
29
+ const LINK = /^https?:\/\//i;
30
+ /**
31
+ * `#12`, `owner/repo#12`, `group/project!7`: what names an issue or pull request by its number.
32
+ * Tracker keys (`ENG-42`) stay words: they read like `gpt-4` and `utf-8`, which should find `gpt-4o`.
33
+ */
34
+ const NUMBERED_REFERENCE = /^(?:[\w.-]+(?:\/[\w.-]+)+)?[#!]\d+$/;
35
+ /** A link pasted without its scheme: `github.com/acme/app/pull/3`. */
36
+ const BARE_LINK = /^(?:[a-z0-9-]+\.)+[a-z]{2,}\//i;
37
+ /** A Factory card's page, `/factories/<project>/cards/<card id>`: not any link with a `/cards/<uuid>` in it. */
38
+ const CARD_LINK = /^https?:\/\/[^/]+\/factories\/[^/?#]+\/cards\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:[/?#]|$)/i;
39
+ function searchTerm(word) {
40
+ const link = LINK.test(word) ? word : BARE_LINK.test(word) ? `https://${word}` : void 0;
41
+ if (link === void 0) return {
42
+ kind: NUMBERED_REFERENCE.test(word) ? "reference" : "word",
43
+ word
44
+ };
45
+ const card = CARD_LINK.exec(link)?.[1];
46
+ if (card !== void 0) return {
47
+ kind: "card",
48
+ word,
49
+ id: card
50
+ };
51
+ return {
52
+ kind: "link",
53
+ word,
54
+ url: normalizedUrl(link),
55
+ sourceKey: sourceKeyFromReference(link)?.toLowerCase() ?? null
56
+ };
57
+ }
58
+ /** The terms of a typed search: one per word, lowercased. Parse once per search, not per card. */
59
+ function searchTerms(query) {
60
+ return searchWords(query).map(searchTerm);
61
+ }
62
+ const SLASH = "/".charCodeAt(0);
63
+ function isAlphanumeric(code) {
64
+ return code >= 48 && code <= 57 || code >= 97 && code <= 122;
65
+ }
66
+ /** `word` is in `text` with no letter or digit right after it: `#12` in `#12 ` or `#12.`, not in `#123`. */
67
+ function hasWhole(text, word) {
68
+ for (let at = text.indexOf(word); at !== -1; at = text.indexOf(word, at + 1)) {
69
+ const next = at + word.length;
70
+ if (next === text.length || !isAlphanumeric(text.charCodeAt(next))) return true;
71
+ }
72
+ return false;
73
+ }
74
+ /** `inner` is `outer` or a page under it: `…/pull/3/files` under `…/pull/3`, never `…/pull/30`. */
75
+ function isAtOrUnder(inner, outer) {
76
+ if (inner.length === outer.length) return inner === outer;
77
+ return inner.length > outer.length && inner.charCodeAt(outer.length) === SLASH && inner.startsWith(outer);
78
+ }
79
+ function matchesTerm(card, term) {
80
+ if (card.ids.includes(term.word)) return true;
81
+ if (term.kind === "word") return card.text.includes(term.word);
82
+ if (term.kind === "reference") return hasWhole(card.text, term.word);
83
+ if (card.text.includes(term.word)) return true;
84
+ if (term.kind === "card") return card.ids.includes(term.id);
85
+ return term.sourceKey !== null && card.sourceKeys.includes(term.sourceKey) || card.links.some((link) => isAtOrUnder(term.url, link) || isAtOrUnder(link, term.url));
86
+ }
87
+ /** Whether the card answers every term. No terms keep every card. */
88
+ function matchesSearch(card, terms) {
89
+ return terms.every((term) => matchesTerm(card, term));
90
+ }
91
+ export { matchesSearch, searchTerms, searchableCard };
92
+
93
+ //# sourceMappingURL=search-terms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-terms.js","names":[],"sources":["../../src/work-items/search-terms.ts"],"sourcesContent":["import { normalizedUrl, sourceKeyFromReference } from './card-reference.js';\nimport { searchWords } from './search-words.js';\n\n/**\n * What a card offers a search, lowercased. Built once per card version by the caller, so a search\n * only reads it.\n */\nexport interface SearchableCard {\n /** What reads as words: its title, its keys and numbers, its source ids. Never its links: `issues` or `github.com` would find every card. */\n text: string;\n /** What is only ever pasted whole: the card's id, its branches. */\n ids: readonly string[];\n /** The keys of every issue or pull request the card carries, its own and the attached ones (`acme/app#12`, `eng-42`). */\n sourceKeys: readonly string[];\n /** The links of those issues and pull requests, as {@link normalizedUrl} writes them. */\n links: readonly string[];\n}\n\n/**\n * A card as a search reads it, from whichever side holds it: the server's card or the browser's.\n * Both build their search from it, so the board, the palette and the server agree on what a card answers.\n */\nexport interface SearchedCard {\n id: string;\n title: string;\n /** The issue or pull request number the card shows, or the one given to a card filed by hand. */\n number: number | null;\n /** The id its source gave it. */\n sourceId: string | null | undefined;\n /** Its own source's key (`ENG-42`). */\n key: string | null | undefined;\n /** Its own source's links. */\n urls: readonly (string | null | undefined)[];\n /** Every issue and pull request the card carries, its own first. */\n sources: readonly { key: string | null; url: string | null; metadata: Record<string, unknown> | null }[];\n sessions: Readonly<Record<string, { branch: string }>>;\n}\n\n// A card has a handful of each, so arrays: cheaper to build than sets, as quick to read.\nfunction lowercased(values: readonly unknown[]): string[] {\n return values\n .filter((value): value is string => typeof value === 'string' && value !== '')\n .map(value => value.toLowerCase());\n}\n\n/**\n * What a search reads of a card: its title, its number, its source id and the key of every issue\n * and pull request it carries as words, so a pull request attached to its issue's card finds that\n * card; those keys and links for a pasted link; and its id and branches, pasted whole.\n */\nexport function searchableCard(card: SearchedCard): SearchableCard {\n const keys = lowercased([card.key, ...card.sources.map(source => source.key)]);\n return {\n // `#12` also answers a search for `12`. Attached keys bring their numbers: `acme/app#30772`.\n text: [...lowercased([card.title, card.number === null ? null : `#${card.number}`, card.sourceId]), ...keys].join(\n ' ',\n ),\n ids: lowercased([\n card.id,\n ...Object.values(card.sessions).map(session => session.branch),\n // An outside contributor's pull request is worked on its own branch.\n ...card.sources.map(source => source.metadata?.headBranch),\n ]),\n sourceKeys: keys,\n links: lowercased([...card.urls, ...card.sources.map(source => source.url)]).map(normalizedUrl),\n };\n}\n\n/** One word of a typed search, and what else than the card's text finds a card for it. */\nexport type SearchTerm =\n /** Anywhere in the card's text: `log` finds `login`, `34` finds `#345`. */\n | { kind: 'word'; word: string }\n /** A whole number or key (`#12`, `acme/app#12`, `group/project!7`): never the start of a longer one. */\n | { kind: 'reference'; word: string }\n /** A link to a Factory card. */\n | { kind: 'card'; word: string; id: string }\n /** Any other link; `sourceKey` when it names an issue or pull request. */\n | { kind: 'link'; word: string; url: string; sourceKey: string | null };\n\nconst LINK = /^https?:\\/\\//i;\n/**\n * `#12`, `owner/repo#12`, `group/project!7`: what names an issue or pull request by its number.\n * Tracker keys (`ENG-42`) stay words: they read like `gpt-4` and `utf-8`, which should find `gpt-4o`.\n */\nconst NUMBERED_REFERENCE = /^(?:[\\w.-]+(?:\\/[\\w.-]+)+)?[#!]\\d+$/;\n/** A link pasted without its scheme: `github.com/acme/app/pull/3`. */\nconst BARE_LINK = /^(?:[a-z0-9-]+\\.)+[a-z]{2,}\\//i;\n/** A Factory card's page, `/factories/<project>/cards/<card id>`: not any link with a `/cards/<uuid>` in it. */\nconst CARD_LINK =\n /^https?:\\/\\/[^/]+\\/factories\\/[^/?#]+\\/cards\\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:[/?#]|$)/i;\n\nfunction searchTerm(word: string): SearchTerm {\n const link = LINK.test(word) ? word : BARE_LINK.test(word) ? `https://${word}` : undefined;\n if (link === undefined) return { kind: NUMBERED_REFERENCE.test(word) ? 'reference' : 'word', word };\n const card = CARD_LINK.exec(link)?.[1];\n if (card !== undefined) return { kind: 'card', word, id: card };\n return {\n kind: 'link',\n word,\n url: normalizedUrl(link),\n sourceKey: sourceKeyFromReference(link)?.toLowerCase() ?? null,\n };\n}\n\n/** The terms of a typed search: one per word, lowercased. Parse once per search, not per card. */\nexport function searchTerms(query: string): SearchTerm[] {\n return searchWords(query).map(searchTerm);\n}\n\nconst SLASH = '/'.charCodeAt(0);\n\nfunction isAlphanumeric(code: number): boolean {\n return (code >= 48 && code <= 57) || (code >= 97 && code <= 122);\n}\n\n/** `word` is in `text` with no letter or digit right after it: `#12` in `#12 ` or `#12.`, not in `#123`. */\nfunction hasWhole(text: string, word: string): boolean {\n for (let at = text.indexOf(word); at !== -1; at = text.indexOf(word, at + 1)) {\n const next = at + word.length;\n if (next === text.length || !isAlphanumeric(text.charCodeAt(next))) return true;\n }\n return false;\n}\n\n/** `inner` is `outer` or a page under it: `…/pull/3/files` under `…/pull/3`, never `…/pull/30`. */\nfunction isAtOrUnder(inner: string, outer: string): boolean {\n if (inner.length === outer.length) return inner === outer;\n // Read for every card on every search: compares in place rather than building `${outer}/`.\n return inner.length > outer.length && inner.charCodeAt(outer.length) === SLASH && inner.startsWith(outer);\n}\n\nfunction matchesTerm(card: SearchableCard, term: SearchTerm): boolean {\n // A whole id or branch finds the card, whatever else the word could name: `user.name/fix-login`\n // reads as a link, and is a branch too.\n if (card.ids.includes(term.word)) return true;\n if (term.kind === 'word') return card.text.includes(term.word);\n // Its own number or key, an attached one, or the same named in its title: `Follow-up to #12`.\n if (term.kind === 'reference') return hasWhole(card.text, term.word);\n // A title holding the pasted link.\n if (card.text.includes(term.word)) return true;\n if (term.kind === 'card') return card.ids.includes(term.id);\n // A link to the issue or pull request, to a page of it, or to a repository or project holding it.\n return (\n (term.sourceKey !== null && card.sourceKeys.includes(term.sourceKey)) ||\n card.links.some(link => isAtOrUnder(term.url, link) || isAtOrUnder(link, term.url))\n );\n}\n\n/** Whether the card answers every term. No terms keep every card. */\nexport function matchesSearch(card: SearchableCard, terms: readonly SearchTerm[]): boolean {\n return terms.every(term => matchesTerm(card, term));\n}\n"],"mappings":";;;AAuCA,SAAS,WAAW,QAAsC;CACxD,OAAO,OACJ,QAAQ,UAA2B,OAAO,UAAU,YAAY,UAAU,EAAE,CAAC,CAC7E,KAAI,UAAS,MAAM,YAAY,CAAC;AACrC;;;;;;AAOA,SAAgB,eAAe,MAAoC;CACjE,MAAM,OAAO,WAAW,CAAC,KAAK,KAAK,GAAG,KAAK,QAAQ,KAAI,WAAU,OAAO,GAAG,CAAC,CAAC;CAC7E,OAAO;EAEL,MAAM,CAAC,GAAG,WAAW;GAAC,KAAK;GAAO,KAAK,WAAW,OAAO,OAAO,IAAI,KAAK;GAAU,KAAK;EAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,KAC3G,GACF;EACA,KAAK,WAAW;GACd,KAAK;GACL,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,KAAI,YAAW,QAAQ,MAAM;GAE7D,GAAG,KAAK,QAAQ,KAAI,WAAU,OAAO,UAAU,UAAU;EAC3D,CAAC;EACD,YAAY;EACZ,OAAO,WAAW,CAAC,GAAG,KAAK,MAAM,GAAG,KAAK,QAAQ,KAAI,WAAU,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,aAAa;CAChG;AACF;AAaA,MAAM,OAAO;;;;;AAKb,MAAM,qBAAqB;;AAE3B,MAAM,YAAY;;AAElB,MAAM,YACJ;AAEF,SAAS,WAAW,MAA0B;CAC5C,MAAM,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,UAA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S,KAAK,MAAM,KAAK,IAAI;CAEnE,IAAI,KAAK,KAAK,SAAS,KAAK,IAAI,GAAG,OAAO;CAC1C,IAAI,KAAK,SAAS,QAAQ,OAAO,KAAK,IAAI,SAAS,KAAK,EAAE;CAE1D,OACG,KAAK,cAAc,QAAQ,KAAK,WAAW,SAAS,KAAK,SAAS,KACnE,KAAK,MAAM,MAAK,SAAQ,YAAY,KAAK,KAAK,IAAI,KAAK,YAAY,MAAM,KAAK,GAAG,CAAC;AAEtF;;AAGA,SAAgB,cAAc,MAAsB,OAAuC;CACzF,OAAO,MAAM,OAAM,SAAQ,YAAY,MAAM,IAAI,CAAC;AACpD"}
@@ -1,5 +1,8 @@
1
1
  /** The words of a typed search, lowercased. */
2
2
  export declare function searchWords(query: string): string[];
3
- /** Whether every word is somewhere in `text`, which the caller has lowercased. */
4
- export declare function hasEveryWord(text: string, words: readonly string[]): boolean;
3
+ /**
4
+ * A typed search as the server is asked it: its words, lowercased, one space apart. Searches that
5
+ * differ only in case or spacing find the same cards, so they share one request and one cached answer.
6
+ */
7
+ export declare function searchQuery(query: string): string;
5
8
  //# sourceMappingURL=search-words.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search-words.d.ts","sourceRoot":"","sources":["../../src/work-items/search-words.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEnD;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAE5E"}
1
+ {"version":3,"file":"search-words.d.ts","sourceRoot":"","sources":["../../src/work-items/search-words.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEnD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD"}
@@ -3,10 +3,13 @@
3
3
  function searchWords(query) {
4
4
  return query.toLowerCase().split(/\s+/).filter(Boolean);
5
5
  }
6
- /** Whether every word is somewhere in `text`, which the caller has lowercased. */
7
- function hasEveryWord(text, words) {
8
- return words.every((word) => text.includes(word));
6
+ /**
7
+ * A typed search as the server is asked it: its words, lowercased, one space apart. Searches that
8
+ * differ only in case or spacing find the same cards, so they share one request and one cached answer.
9
+ */
10
+ function searchQuery(query) {
11
+ return searchWords(query).join(" ");
9
12
  }
10
- export { hasEveryWord, searchWords };
13
+ export { searchQuery, searchWords };
11
14
 
12
15
  //# sourceMappingURL=search-words.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"search-words.js","names":[],"sources":["../../src/work-items/search-words.ts"],"sourcesContent":["/** The words of a typed search, lowercased. */\nexport function searchWords(query: string): string[] {\n return query.toLowerCase().split(/\\s+/).filter(Boolean);\n}\n\n/** Whether every word is somewhere in `text`, which the caller has lowercased. */\nexport function hasEveryWord(text: string, words: readonly string[]): boolean {\n return words.every(word => text.includes(word));\n}\n"],"mappings":";;AACA,SAAgB,YAAY,OAAyB;CACnD,OAAO,MAAM,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;AACxD;;AAGA,SAAgB,aAAa,MAAc,OAAmC;CAC5E,OAAO,MAAM,OAAM,SAAQ,KAAK,SAAS,IAAI,CAAC;AAChD"}
1
+ {"version":3,"file":"search-words.js","names":[],"sources":["../../src/work-items/search-words.ts"],"sourcesContent":["/** The words of a typed search, lowercased. */\nexport function searchWords(query: string): string[] {\n return query.toLowerCase().split(/\\s+/).filter(Boolean);\n}\n\n/**\n * A typed search as the server is asked it: its words, lowercased, one space apart. Searches that\n * differ only in case or spacing find the same cards, so they share one request and one cached answer.\n */\nexport function searchQuery(query: string): string {\n return searchWords(query).join(' ');\n}\n"],"mappings":";;AACA,SAAgB,YAAY,OAAyB;CACnD,OAAO,MAAM,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;AACxD;;;;;AAMA,SAAgB,YAAY,OAAuB;CACjD,OAAO,YAAY,KAAK,CAAC,CAAC,KAAK,GAAG;AACpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/factory",
3
- "version": "0.30.0-alpha.3",
3
+ "version": "0.30.0",
4
4
  "description": "Mastra Software Factory module: the server core behind the Mastra Software Factory — storage domains, integrations, and surfaces for agent-powered software delivery",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -58,11 +58,11 @@
58
58
  "hono": "^4.13.13",
59
59
  "posthog-node": "^5.57.1",
60
60
  "zod": "^4.6.7",
61
- "@mastra/auth-studio": "1.4.1-alpha.0",
61
+ "@mastra/auth-studio": "1.4.1",
62
62
  "@mastra/auth-workos": "1.6.9",
63
- "@mastra/code-sdk": "1.20.0-alpha.2",
63
+ "@mastra/code-sdk": "1.20.0",
64
64
  "@mastra/connect": "1.4.1",
65
- "@mastra/core": "1.85.0-alpha.2",
65
+ "@mastra/core": "1.85.0",
66
66
  "@mastra/mcp": "2.10.0",
67
67
  "@mastra/platform-workspace": "1.13.1",
68
68
  "@mastra/slack": "1.9.0"
@@ -74,13 +74,13 @@
74
74
  "tsdown": "0.23.1",
75
75
  "typescript": "^6.0.3",
76
76
  "vitest": "5.1.0",
77
- "@internal/lint": "0.0.150",
78
- "@internal/types-builder": "0.0.125",
79
- "@internal/workspace": "0.0.22",
80
- "@mastra/deployer": "1.85.0-alpha.2",
81
- "@mastra/libsql": "1.31.0",
77
+ "@internal/lint": "0.0.151",
78
+ "@internal/types-builder": "0.0.126",
79
+ "@internal/workspace": "0.0.23",
80
+ "@mastra/deployer": "1.85.0",
81
+ "@mastra/libsql": "1.31.1",
82
82
  "@mastra/pg": "1.37.0",
83
- "@mastra/server": "1.85.0-alpha.2"
83
+ "@mastra/server": "1.85.0"
84
84
  },
85
85
  "engines": {
86
86
  "node": ">=22.19.0"
@@ -1,4 +0,0 @@
1
- import type { Card } from '../storage/domains/work-items/base.js';
2
- /** What a search reads of a card, lowercased: its title, its key (`ENG-42`), its number and its source id. */
3
- export declare function cardSearchText(card: Card): string;
4
- //# sourceMappingURL=card-search-text.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"card-search-text.d.ts","sourceRoot":"","sources":["../../src/work-items/card-search-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAGlE,8GAA8G;AAC9G,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAMjD"}
@@ -1,15 +0,0 @@
1
- import { workItemNumber } from "./card-number.js";
2
- // src/work-items/card-search-text.ts
3
- /** What a search reads of a card, lowercased: its title, its key (`ENG-42`), its number and its source id. */
4
- function cardSearchText(card) {
5
- const number = workItemNumber(card);
6
- return [
7
- card.title,
8
- card.workItem.key,
9
- number === null ? null : `#${number}`,
10
- card.externalSource?.externalId
11
- ].join(" ").toLowerCase();
12
- }
13
- export { cardSearchText };
14
-
15
- //# sourceMappingURL=card-search-text.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"card-search-text.js","names":[],"sources":["../../src/work-items/card-search-text.ts"],"sourcesContent":["import type { Card } from '../storage/domains/work-items/base.js';\nimport { workItemNumber } from './card-number.js';\n\n/** What a search reads of a card, lowercased: its title, its key (`ENG-42`), its number and its source id. */\nexport function cardSearchText(card: Card): string {\n const number = workItemNumber(card);\n // `#12` also answers a search for `12`.\n return [card.title, card.workItem.key, number === null ? null : `#${number}`, card.externalSource?.externalId]\n .join(' ')\n .toLowerCase();\n}\n"],"mappings":";;;AAIA,SAAgB,eAAe,MAAoB;CACjD,MAAM,SAAS,eAAe,IAAI;CAElC,OAAO;EAAC,KAAK;EAAO,KAAK,SAAS;EAAK,WAAW,OAAO,OAAO,IAAI;EAAU,KAAK,gBAAgB;CAAU,CAAC,CAC3G,KAAK,GAAG,CAAC,CACT,YAAY;AACjB"}