@indexnetwork/protocol 6.2.1-rc.378.1 → 6.2.2-rc.379.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/dist/opportunity/opportunity.actor.d.ts +16 -0
- package/dist/opportunity/opportunity.actor.d.ts.map +1 -0
- package/dist/opportunity/opportunity.actor.js +40 -0
- package/dist/opportunity/opportunity.actor.js.map +1 -0
- package/dist/opportunity/opportunity.evaluator.d.ts +3 -3
- package/dist/opportunity/opportunity.evaluator.d.ts.map +1 -1
- package/dist/opportunity/opportunity.evaluator.js +4 -1
- package/dist/opportunity/opportunity.evaluator.js.map +1 -1
- package/dist/opportunity/opportunity.graph.d.ts.map +1 -1
- package/dist/opportunity/opportunity.graph.js +32 -22
- package/dist/opportunity/opportunity.graph.js.map +1 -1
- package/dist/opportunity/opportunity.persist.d.ts.map +1 -1
- package/dist/opportunity/opportunity.persist.js +4 -2
- package/dist/opportunity/opportunity.persist.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opportunity.persist.d.ts","sourceRoot":"/","sources":["opportunity/opportunity.persist.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AACvJ,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4CAA4C,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"opportunity.persist.d.ts","sourceRoot":"/","sources":["opportunity/opportunity.persist.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AACvJ,OAAO,KAAK,EAAE,QA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B,CAAC,EAAE,6BAA6B,CAAC;CACpD;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,yBAAyB,EAAE,CAAC;CACtC;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CA0ElH"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Used by the opportunity graph persist node and by the manual opportunity service for consistency.
|
|
4
4
|
*/
|
|
5
5
|
import { enrichOrCreate } from './opportunity.enricher.js';
|
|
6
|
+
import { normalizeCreateOpportunityActorIntents } from './opportunity.actor.js';
|
|
6
7
|
import { protocolLogger } from '../shared/observability/protocol.logger.js';
|
|
7
8
|
const logger = protocolLogger('OpportunityPersist');
|
|
8
9
|
/**
|
|
@@ -18,8 +19,9 @@ export async function persistOpportunities(params) {
|
|
|
18
19
|
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
19
20
|
const data = items[itemIndex];
|
|
20
21
|
try {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
22
|
+
const normalizedData = normalizeCreateOpportunityActorIntents(data);
|
|
23
|
+
const enrichment = await enrichOrCreate(database, embedder, normalizedData);
|
|
24
|
+
const toCreate = normalizeCreateOpportunityActorIntents(enrichment.data);
|
|
23
25
|
if (enrichment.enriched) {
|
|
24
26
|
toCreate.status = enrichment.resolvedStatus;
|
|
25
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opportunity.persist.js","sourceRoot":"/","sources":["opportunity/opportunity.persist.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,O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AAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAChD,IAAI,WAAW,EAAE,MAAM,KAAK,SAAS,IAAI,UAAU,EAAE,CAAC;gBACpD,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;oBAC1C,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;gBACtF,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YACvC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACxE,CAAC","sourcesContent":["/**\n * Shared persist phase for opportunity creation: enrichOrCreate → create (or create+expire) → optional chat injection.\n * Used by the opportunity graph persist node and by the manual opportunity service for consistency.\n */\n\nimport type { CreateOpportunityData, Opportunity, OpportunityNetworkEligibility, OpportunityStatus } from '../shared/interfaces/database.interface.js';\nimport type { Embedder } from '../shared/interfaces/embedder.interface.js';\nimport type { EnricherDatabase } from './opportunity.enricher.js';\nimport { enrichOrCreate } from './opportunity.enricher.js';\nimport { normalizeCreateOpportunityActorIntents } from './opportunity.actor.js';\nimport { protocolLogger } from '../shared/observability/protocol.logger.js';\n\nconst logger = protocolLogger('OpportunityPersist');\n\nexport type PersistOpportunityDatabase = EnricherDatabase & {\n createOpportunity(data: CreateOpportunityData): Promise<Opportunity>;\n createOpportunityIfNetworkEligible?(\n data: CreateOpportunityData,\n eligibility: OpportunityNetworkEligibility,\n ): Promise<Opportunity | null>;\n updateOpportunityStatus(id: string, status: OpportunityStatus): Promise<void | Opportunity | null>;\n createOpportunityAndExpireIds?(\n data: CreateOpportunityData,\n expireIds: string[]\n ): Promise<{ created: Opportunity; expired: Opportunity[] }>;\n createOpportunityAndExpireIdsIfNetworkEligible?(\n data: CreateOpportunityData,\n expireIds: string[],\n eligibility: OpportunityNetworkEligibility,\n ): Promise<{ created: Opportunity; expired: Opportunity[] } | null>;\n /** Optional: used to populate expired list in non-atomic path. */\n getOpportunity?(id: string): Promise<Opportunity | null>;\n};\n\nexport interface PersistOpportunitiesParams {\n database: PersistOpportunityDatabase;\n embedder: Embedder;\n items: CreateOpportunityData[];\n injectChat?: (opportunity: Opportunity) => Promise<unknown>;\n /** Require adapter-level membership/assignment locks for discovery-created rows. */\n networkEligibility?: OpportunityNetworkEligibility;\n}\n\nexport interface PersistOpportunitiesError {\n itemIndex: number;\n error: unknown;\n}\n\nexport interface PersistOpportunitiesResult {\n created: Opportunity[];\n expired: Opportunity[];\n errors?: PersistOpportunitiesError[];\n}\n\n/**\n * Persist one or more opportunities: enrich (merge overlapping), create, expire replaced, optional chat injection.\n * When the database has createOpportunityAndExpireIds and enrichment produced expireIds, uses it for atomic create+expire.\n * Returns both created and expired so callers can emit events (e.g. manual service).\n */\nexport async function persistOpportunities(params: PersistOpportunitiesParams): Promise<PersistOpportunitiesResult> {\n const { database, embedder, items, injectChat, networkEligibility } = params;\n const created: Opportunity[] = [];\n const expired: Opportunity[] = [];\n const errors: PersistOpportunitiesError[] = [];\n\n for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n const data = items[itemIndex];\n try {\n const normalizedData = normalizeCreateOpportunityActorIntents(data);\n const enrichment = await enrichOrCreate(database, embedder, normalizedData);\n const toCreate = normalizeCreateOpportunityActorIntents(enrichment.data);\n if (enrichment.enriched) {\n toCreate.status = enrichment.resolvedStatus;\n }\n\n if (networkEligibility) {\n if (enrichment.enriched && enrichment.expiredIds.length > 0) {\n if (!database.createOpportunityAndExpireIdsIfNetworkEligible) {\n throw new Error('Network-eligible create+expire is required for discovery persistence');\n }\n const result = await database.createOpportunityAndExpireIdsIfNetworkEligible(\n toCreate,\n enrichment.expiredIds,\n networkEligibility,\n );\n if (!result) continue;\n created.push(result.created);\n expired.push(...result.expired);\n } else {\n if (!database.createOpportunityIfNetworkEligible) {\n throw new Error('Network-eligible create is required for discovery persistence');\n }\n const c = await database.createOpportunityIfNetworkEligible(toCreate, networkEligibility);\n if (!c) continue;\n created.push(c);\n }\n } else if (\n database.createOpportunityAndExpireIds &&\n enrichment.enriched &&\n enrichment.expiredIds.length > 0\n ) {\n const result = await database.createOpportunityAndExpireIds(toCreate, enrichment.expiredIds);\n created.push(result.created);\n expired.push(...result.expired);\n } else {\n const c = await database.createOpportunity(toCreate);\n created.push(c);\n if (enrichment.enriched && enrichment.expiredIds.length > 0) {\n for (const id of enrichment.expiredIds) {\n await database.updateOpportunityStatus(id, 'expired');\n }\n if (database.getOpportunity) {\n for (const id of enrichment.expiredIds) {\n const opp = await database.getOpportunity(id);\n if (opp) expired.push(opp);\n }\n }\n }\n }\n\n const lastCreated = created[created.length - 1];\n if (lastCreated?.status === 'pending' && injectChat) {\n await injectChat(lastCreated).catch((err) => {\n logger.warn('Chat injection failed', { opportunityId: lastCreated.id, error: err });\n });\n }\n } catch (err) {\n errors.push({ itemIndex, error: err });\n logger.warn('Item failed', { itemIndex, error: err });\n }\n }\n\n return { created, expired, ...(errors.length > 0 ? { errors } : {}) };\n}\n"]}
|