@vantageos/event-schemas 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +72 -0
- package/convex.config.ts +24 -0
- package/dist/index.d.ts +146 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +264 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/intake-event-v1.d.ts +367 -0
- package/dist/schemas/intake-event-v1.d.ts.map +1 -0
- package/dist/schemas/intake-event-v1.js +99 -0
- package/dist/schemas/intake-event-v1.js.map +1 -0
- package/dist/schemas/task-complete-v1.d.ts +138 -0
- package/dist/schemas/task-complete-v1.d.ts.map +1 -0
- package/dist/schemas/task-complete-v1.js +53 -0
- package/dist/schemas/task-complete-v1.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VantageOS Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @vantageos/event-schemas
|
|
2
|
+
|
|
3
|
+
Versioned event schema registry for Vantage Immo feature MCPs.
|
|
4
|
+
|
|
5
|
+
## What it is
|
|
6
|
+
|
|
7
|
+
A code-side schema registry. No Convex tables. No event bus.
|
|
8
|
+
Provides typed validators, type-guards, and helpers so feature MCPs can publish
|
|
9
|
+
validated events into the host app's `intakeEvents` table without re-implementing
|
|
10
|
+
validation logic.
|
|
11
|
+
|
|
12
|
+
## Schemas
|
|
13
|
+
|
|
14
|
+
| Schema ID | Convex Validator | Type-guard | Status | Variants |
|
|
15
|
+
|---|---|---|---|---|
|
|
16
|
+
| `intake.event.v1` | `IntakeEventV1Schema` | `isIntakeEventV1` | Production | `mail`, `document`, `contract`, `candidature`, `external-event` |
|
|
17
|
+
| `task.complete.v1` | `TaskCompleteV1Schema` | `isTaskCompleteV1` | Placeholder (Sigma API 5 v2 roadmap) | `normal`, `auto-resolved` |
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import {
|
|
23
|
+
publishEvent,
|
|
24
|
+
isIntakeEventV1,
|
|
25
|
+
IntakeEventV1Schema,
|
|
26
|
+
} from "@vantageos/event-schemas";
|
|
27
|
+
|
|
28
|
+
// 1. Validate and get typed payload (runtime type-guard)
|
|
29
|
+
const result = publishEvent("intake.event.v1", isIntakeEventV1, rawPayload);
|
|
30
|
+
if (!result.ok) {
|
|
31
|
+
throw new Error(`Event validation failed: ${result.error}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 2. result.payload is typed as IntakeEventV1
|
|
35
|
+
// 3. Insert into host app's intakeEvents table (Component does NOT insert)
|
|
36
|
+
await ctx.db.insert("intakeEvents", {
|
|
37
|
+
orgId: result.payload.orgId,
|
|
38
|
+
// ...
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// validatePayload directly
|
|
42
|
+
import { validatePayload, isIntakeEventMailV1 } from "@vantageos/event-schemas";
|
|
43
|
+
const check = validatePayload(isIntakeEventMailV1, unknownValue);
|
|
44
|
+
if (check.ok) {
|
|
45
|
+
console.log(check.value.sujet); // typed as IntakeEventMailV1
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Convex schema args
|
|
50
|
+
|
|
51
|
+
Use the exported Convex validators in function args:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { v } from "convex/values";
|
|
55
|
+
import { IntakeEventV1Schema } from "@vantageos/event-schemas";
|
|
56
|
+
|
|
57
|
+
export const myMutation = mutation({
|
|
58
|
+
args: { event: IntakeEventV1Schema },
|
|
59
|
+
// ...
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Rules
|
|
64
|
+
|
|
65
|
+
- No `v.any()` at any public boundary.
|
|
66
|
+
- All exported symbols carry a `V1` version suffix.
|
|
67
|
+
- `publishEvent` validates but never inserts — the host app owns the table.
|
|
68
|
+
- `registerSchema` throws on duplicate IDs — one schema per version.
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT
|
package/convex.config.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vantage/event-schemas — Convex Component definition
|
|
3
|
+
*
|
|
4
|
+
* This Component carries the code-side registry of versioned event schemas
|
|
5
|
+
* consumed by feature MCPs (F7 briefing matinal, F8 reporting, F11 candidature, etc.).
|
|
6
|
+
*
|
|
7
|
+
* It is NOT an event bus. It provides:
|
|
8
|
+
* - Versioned schema validators (discriminated unions, no v.any())
|
|
9
|
+
* - validatePayload() helper: type-safe validation before publish
|
|
10
|
+
* - publishEvent() helper: validate + return typed payload ready for db.insert
|
|
11
|
+
*
|
|
12
|
+
* The Component owns zero Convex tables. All persistence is delegated to the
|
|
13
|
+
* host app (vantage-immo convex/schema.ts — intakeEvents table).
|
|
14
|
+
*
|
|
15
|
+
* Source: decisions/c2-spec-schema-2026-05-21.md §4 CF2
|
|
16
|
+
* Flag: Eta F-Xi-1 (risk B4 — implicit cross-feature coupling via data lake)
|
|
17
|
+
* ADR: vantage-memory/decisions/c1-public-apis-design-2026-05-21.md §"Hors scope C1.v1"
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { defineComponent } from "convex/server";
|
|
21
|
+
|
|
22
|
+
const eventSchemas = defineComponent("eventSchemas");
|
|
23
|
+
|
|
24
|
+
export default eventSchemas;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vantageos/event-schemas — public API
|
|
3
|
+
*
|
|
4
|
+
* Versioned event schema registry for Vantage Immo feature MCPs.
|
|
5
|
+
* Code-side validators only — no Convex tables owned by this Component.
|
|
6
|
+
*
|
|
7
|
+
* Exports:
|
|
8
|
+
* - Versioned schemas: IntakeEventV1Schema, TaskCompleteV1Schema
|
|
9
|
+
* - Sub-validators per variant (vIntakeEvent*V1, vTaskComplete*V1)
|
|
10
|
+
* - TypeScript types derived from validators
|
|
11
|
+
* - Helpers: registerSchema, validatePayload, publishEvent
|
|
12
|
+
*
|
|
13
|
+
* Feature MCPs import this package to publish validated events into
|
|
14
|
+
* the host app's intakeEvents table without re-implementing validation.
|
|
15
|
+
*
|
|
16
|
+
* Source: decisions/c2-spec-schema-2026-05-21.md §4 CF2
|
|
17
|
+
*/
|
|
18
|
+
export { IntakeEventV1Schema, vIntakeEventMailV1, vIntakeEventDocumentV1, vIntakeEventContractV1, vIntakeEventCandidatureV1, vIntakeEventExternalV1, } from "./schemas/intake-event-v1.js";
|
|
19
|
+
export type { IntakeEventV1, IntakeEventMailV1, IntakeEventDocumentV1, IntakeEventContractV1, IntakeEventCandidatureV1, IntakeEventExternalV1, } from "./schemas/intake-event-v1.js";
|
|
20
|
+
export { TaskCompleteV1Schema, vTaskCompleteNormalV1, vTaskCompleteAutoResolvedV1, } from "./schemas/task-complete-v1.js";
|
|
21
|
+
export type { TaskCompleteV1, TaskCompleteNormalV1, TaskCompleteAutoResolvedV1, } from "./schemas/task-complete-v1.js";
|
|
22
|
+
/**
|
|
23
|
+
* A SchemaEntry pairs a stable schema ID with a runtime type-guard function.
|
|
24
|
+
* The type-guard is responsible for structural validation of an unknown value.
|
|
25
|
+
*
|
|
26
|
+
* Using type-guard functions (rather than Convex Validator runtime methods,
|
|
27
|
+
* which are not exposed publicly) keeps this package portable and avoids
|
|
28
|
+
* coupling to Convex internals.
|
|
29
|
+
*/
|
|
30
|
+
export type SchemaEntry<T> = {
|
|
31
|
+
schemaId: string;
|
|
32
|
+
guard: (value: unknown) => value is T;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* registerSchema — register a versioned schema by its type-guard function.
|
|
36
|
+
*
|
|
37
|
+
* @param schemaId Stable string identifier e.g. "intake.event.v1", "task.complete.v1"
|
|
38
|
+
* @param guard Type-guard function: (value: unknown) => value is T
|
|
39
|
+
*
|
|
40
|
+
* Throws if the schemaId is already registered (prevents silent override).
|
|
41
|
+
* Feature MCPs call this at module init to declare the schemas they produce/consume.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* import { registerSchema, isIntakeEventV1 } from "@vantageos/event-schemas";
|
|
45
|
+
* registerSchema("intake.event.v1", isIntakeEventV1);
|
|
46
|
+
*/
|
|
47
|
+
export declare function registerSchema<T>(schemaId: string, guard: (value: unknown) => value is T): void;
|
|
48
|
+
/**
|
|
49
|
+
* getRegisteredSchemaIds — list all registered schema IDs.
|
|
50
|
+
* Useful for debugging and audit.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getRegisteredSchemaIds(): string[];
|
|
53
|
+
/**
|
|
54
|
+
* ValidationResult — discriminated union returned by validatePayload.
|
|
55
|
+
*/
|
|
56
|
+
export type ValidationResult<T> = {
|
|
57
|
+
ok: true;
|
|
58
|
+
value: T;
|
|
59
|
+
} | {
|
|
60
|
+
ok: false;
|
|
61
|
+
error: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* validatePayload — validate an unknown payload against a type-guard function.
|
|
65
|
+
*
|
|
66
|
+
* Returns a discriminated result — never throws on validation failure.
|
|
67
|
+
*
|
|
68
|
+
* @param guard Type-guard: (value: unknown) => value is T
|
|
69
|
+
* @param payload Raw unknown value to validate
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* import { validatePayload, isIntakeEventV1 } from "@vantageos/event-schemas";
|
|
73
|
+
* const result = validatePayload(isIntakeEventV1, rawPayload);
|
|
74
|
+
* if (!result.ok) { logger.warn(result.error); return; }
|
|
75
|
+
* const event = result.value; // typed as IntakeEventV1
|
|
76
|
+
*/
|
|
77
|
+
export declare function validatePayload<T>(guard: (value: unknown) => value is T, payload: unknown): ValidationResult<T>;
|
|
78
|
+
/**
|
|
79
|
+
* PublishEventResult — payload ready for db.insert into intakeEvents.
|
|
80
|
+
* The Component does NOT perform the insertion — the host app owns the table.
|
|
81
|
+
*/
|
|
82
|
+
export type PublishEventResult<T> = {
|
|
83
|
+
ok: true;
|
|
84
|
+
payload: T;
|
|
85
|
+
schemaId: string;
|
|
86
|
+
} | {
|
|
87
|
+
ok: false;
|
|
88
|
+
error: string;
|
|
89
|
+
schemaId: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* publishEvent — validate an event payload and return it typed, ready to insert.
|
|
93
|
+
*
|
|
94
|
+
* The Component validates but does NOT insert. The caller (host app mutation
|
|
95
|
+
* or feature MCP) is responsible for db.insert into intakeEvents.
|
|
96
|
+
* This preserves the boundary: the Component owns zero tables.
|
|
97
|
+
*
|
|
98
|
+
* @param schemaId The versioned schema identifier e.g. "intake.event.v1"
|
|
99
|
+
* @param guard Type-guard function for the schema
|
|
100
|
+
* @param payload Raw unknown payload from the caller
|
|
101
|
+
* @returns PublishEventResult — ok=true with typed payload, or ok=false with error
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* import { publishEvent, isIntakeEventV1 } from "@vantageos/event-schemas";
|
|
105
|
+
*
|
|
106
|
+
* const result = publishEvent("intake.event.v1", isIntakeEventV1, rawPayload);
|
|
107
|
+
* if (!result.ok) { throw new Error(`Validation failed: ${result.error}`); }
|
|
108
|
+
*
|
|
109
|
+
* // result.payload is typed as IntakeEventV1
|
|
110
|
+
* await ctx.db.insert("intakeEvents", {
|
|
111
|
+
* orgId: result.payload.orgId,
|
|
112
|
+
* intakeId: ctx.db.normalizeId("intakeQueue", result.payload.intakeId)!,
|
|
113
|
+
* objectId: ctx.db.normalizeId("customObjects", result.payload.objectId)!,
|
|
114
|
+
* objectType: result.payload.sourceType,
|
|
115
|
+
* eventType: "document_ingested",
|
|
116
|
+
* createdAt: result.payload.createdAt,
|
|
117
|
+
* });
|
|
118
|
+
*/
|
|
119
|
+
export declare function publishEvent<T>(schemaId: string, guard: (value: unknown) => value is T, payload: unknown): PublishEventResult<T>;
|
|
120
|
+
import type { IntakeEventV1, IntakeEventMailV1, IntakeEventDocumentV1, IntakeEventContractV1, IntakeEventCandidatureV1, IntakeEventExternalV1 } from "./schemas/intake-event-v1.js";
|
|
121
|
+
import type { TaskCompleteV1 } from "./schemas/task-complete-v1.js";
|
|
122
|
+
/** Type-guard for IntakeEventMailV1 */
|
|
123
|
+
export declare function isIntakeEventMailV1(v: unknown): v is IntakeEventMailV1;
|
|
124
|
+
/** Type-guard for IntakeEventDocumentV1 */
|
|
125
|
+
export declare function isIntakeEventDocumentV1(v: unknown): v is IntakeEventDocumentV1;
|
|
126
|
+
/** Type-guard for IntakeEventContractV1 */
|
|
127
|
+
export declare function isIntakeEventContractV1(v: unknown): v is IntakeEventContractV1;
|
|
128
|
+
/** Type-guard for IntakeEventCandidatureV1 */
|
|
129
|
+
export declare function isIntakeEventCandidatureV1(v: unknown): v is IntakeEventCandidatureV1;
|
|
130
|
+
/** Type-guard for IntakeEventExternalV1 */
|
|
131
|
+
export declare function isIntakeEventExternalV1(v: unknown): v is IntakeEventExternalV1;
|
|
132
|
+
/**
|
|
133
|
+
* isIntakeEventV1 — master type-guard for the full IntakeEventV1 discriminated union.
|
|
134
|
+
* Dispatches on sourceType to the appropriate variant guard.
|
|
135
|
+
*/
|
|
136
|
+
export declare function isIntakeEventV1(v: unknown): v is IntakeEventV1;
|
|
137
|
+
import type { TaskCompleteNormalV1, TaskCompleteAutoResolvedV1 } from "./schemas/task-complete-v1.js";
|
|
138
|
+
/** Type-guard for TaskCompleteNormalV1 */
|
|
139
|
+
export declare function isTaskCompleteNormalV1(v: unknown): v is TaskCompleteNormalV1;
|
|
140
|
+
/** Type-guard for TaskCompleteAutoResolvedV1 */
|
|
141
|
+
export declare function isTaskCompleteAutoResolvedV1(v: unknown): v is TaskCompleteAutoResolvedV1;
|
|
142
|
+
/**
|
|
143
|
+
* isTaskCompleteV1 — master type-guard for the full TaskCompleteV1 union.
|
|
144
|
+
*/
|
|
145
|
+
export declare function isTaskCompleteV1(v: unknown): v is TaskCompleteV1;
|
|
146
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,EAEL,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAEL,oBAAoB,EACpB,qBAAq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CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,cAAc,CAWhE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vantageos/event-schemas — public API
|
|
3
|
+
*
|
|
4
|
+
* Versioned event schema registry for Vantage Immo feature MCPs.
|
|
5
|
+
* Code-side validators only — no Convex tables owned by this Component.
|
|
6
|
+
*
|
|
7
|
+
* Exports:
|
|
8
|
+
* - Versioned schemas: IntakeEventV1Schema, TaskCompleteV1Schema
|
|
9
|
+
* - Sub-validators per variant (vIntakeEvent*V1, vTaskComplete*V1)
|
|
10
|
+
* - TypeScript types derived from validators
|
|
11
|
+
* - Helpers: registerSchema, validatePayload, publishEvent
|
|
12
|
+
*
|
|
13
|
+
* Feature MCPs import this package to publish validated events into
|
|
14
|
+
* the host app's intakeEvents table without re-implementing validation.
|
|
15
|
+
*
|
|
16
|
+
* Source: decisions/c2-spec-schema-2026-05-21.md §4 CF2
|
|
17
|
+
*/
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Re-export schemas and types
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
export {
|
|
22
|
+
// Intake event V1 — master schema + variants
|
|
23
|
+
IntakeEventV1Schema, vIntakeEventMailV1, vIntakeEventDocumentV1, vIntakeEventContractV1, vIntakeEventCandidatureV1, vIntakeEventExternalV1, } from "./schemas/intake-event-v1.js";
|
|
24
|
+
export {
|
|
25
|
+
// Task complete V1 — placeholder for Sigma API 5 v2 roadmap
|
|
26
|
+
TaskCompleteV1Schema, vTaskCompleteNormalV1, vTaskCompleteAutoResolvedV1, } from "./schemas/task-complete-v1.js";
|
|
27
|
+
/** Internal registry: schemaId → type-guard function */
|
|
28
|
+
const _schemaRegistry = new Map();
|
|
29
|
+
/**
|
|
30
|
+
* registerSchema — register a versioned schema by its type-guard function.
|
|
31
|
+
*
|
|
32
|
+
* @param schemaId Stable string identifier e.g. "intake.event.v1", "task.complete.v1"
|
|
33
|
+
* @param guard Type-guard function: (value: unknown) => value is T
|
|
34
|
+
*
|
|
35
|
+
* Throws if the schemaId is already registered (prevents silent override).
|
|
36
|
+
* Feature MCPs call this at module init to declare the schemas they produce/consume.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* import { registerSchema, isIntakeEventV1 } from "@vantageos/event-schemas";
|
|
40
|
+
* registerSchema("intake.event.v1", isIntakeEventV1);
|
|
41
|
+
*/
|
|
42
|
+
export function registerSchema(schemaId, guard) {
|
|
43
|
+
if (_schemaRegistry.has(schemaId)) {
|
|
44
|
+
throw new Error(`@vantageos/event-schemas: schema "${schemaId}" is already registered. ` +
|
|
45
|
+
`Use a unique schemaId per version (e.g. "intake.event.v2").`);
|
|
46
|
+
}
|
|
47
|
+
_schemaRegistry.set(schemaId, guard);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* getRegisteredSchemaIds — list all registered schema IDs.
|
|
51
|
+
* Useful for debugging and audit.
|
|
52
|
+
*/
|
|
53
|
+
export function getRegisteredSchemaIds() {
|
|
54
|
+
return Array.from(_schemaRegistry.keys());
|
|
55
|
+
}
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
// validatePayload helper
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
/**
|
|
60
|
+
* validatePayload — validate an unknown payload against a type-guard function.
|
|
61
|
+
*
|
|
62
|
+
* Returns a discriminated result — never throws on validation failure.
|
|
63
|
+
*
|
|
64
|
+
* @param guard Type-guard: (value: unknown) => value is T
|
|
65
|
+
* @param payload Raw unknown value to validate
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* import { validatePayload, isIntakeEventV1 } from "@vantageos/event-schemas";
|
|
69
|
+
* const result = validatePayload(isIntakeEventV1, rawPayload);
|
|
70
|
+
* if (!result.ok) { logger.warn(result.error); return; }
|
|
71
|
+
* const event = result.value; // typed as IntakeEventV1
|
|
72
|
+
*/
|
|
73
|
+
export function validatePayload(guard, payload) {
|
|
74
|
+
try {
|
|
75
|
+
if (guard(payload)) {
|
|
76
|
+
return { ok: true, value: payload };
|
|
77
|
+
}
|
|
78
|
+
return { ok: false, error: "Payload did not match expected schema shape" };
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
const message = err instanceof Error ? err.message : "Unknown validation error";
|
|
82
|
+
return { ok: false, error: message };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* publishEvent — validate an event payload and return it typed, ready to insert.
|
|
87
|
+
*
|
|
88
|
+
* The Component validates but does NOT insert. The caller (host app mutation
|
|
89
|
+
* or feature MCP) is responsible for db.insert into intakeEvents.
|
|
90
|
+
* This preserves the boundary: the Component owns zero tables.
|
|
91
|
+
*
|
|
92
|
+
* @param schemaId The versioned schema identifier e.g. "intake.event.v1"
|
|
93
|
+
* @param guard Type-guard function for the schema
|
|
94
|
+
* @param payload Raw unknown payload from the caller
|
|
95
|
+
* @returns PublishEventResult — ok=true with typed payload, or ok=false with error
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* import { publishEvent, isIntakeEventV1 } from "@vantageos/event-schemas";
|
|
99
|
+
*
|
|
100
|
+
* const result = publishEvent("intake.event.v1", isIntakeEventV1, rawPayload);
|
|
101
|
+
* if (!result.ok) { throw new Error(`Validation failed: ${result.error}`); }
|
|
102
|
+
*
|
|
103
|
+
* // result.payload is typed as IntakeEventV1
|
|
104
|
+
* await ctx.db.insert("intakeEvents", {
|
|
105
|
+
* orgId: result.payload.orgId,
|
|
106
|
+
* intakeId: ctx.db.normalizeId("intakeQueue", result.payload.intakeId)!,
|
|
107
|
+
* objectId: ctx.db.normalizeId("customObjects", result.payload.objectId)!,
|
|
108
|
+
* objectType: result.payload.sourceType,
|
|
109
|
+
* eventType: "document_ingested",
|
|
110
|
+
* createdAt: result.payload.createdAt,
|
|
111
|
+
* });
|
|
112
|
+
*/
|
|
113
|
+
export function publishEvent(schemaId, guard, payload) {
|
|
114
|
+
const validation = validatePayload(guard, payload);
|
|
115
|
+
if (!validation.ok) {
|
|
116
|
+
return { ok: false, error: validation.error, schemaId };
|
|
117
|
+
}
|
|
118
|
+
return { ok: true, payload: validation.value, schemaId };
|
|
119
|
+
}
|
|
120
|
+
const CANDIDATURE_PIECE_TYPES = new Set([
|
|
121
|
+
"identite",
|
|
122
|
+
"justificatif_domicile",
|
|
123
|
+
"justificatif_revenus",
|
|
124
|
+
"avis_imposition",
|
|
125
|
+
"quittances_loyer",
|
|
126
|
+
"autre",
|
|
127
|
+
]);
|
|
128
|
+
/** Type-guard for IntakeEventMailV1 */
|
|
129
|
+
export function isIntakeEventMailV1(v) {
|
|
130
|
+
if (typeof v !== "object" || v === null)
|
|
131
|
+
return false;
|
|
132
|
+
const o = v;
|
|
133
|
+
return (o["sourceType"] === "mail" &&
|
|
134
|
+
typeof o["orgId"] === "string" &&
|
|
135
|
+
typeof o["intakeId"] === "string" &&
|
|
136
|
+
typeof o["objectId"] === "string" &&
|
|
137
|
+
typeof o["sujet"] === "string" &&
|
|
138
|
+
typeof o["expediteur"] === "string" &&
|
|
139
|
+
Array.isArray(o["destinataires"]) &&
|
|
140
|
+
typeof o["dateReception"] === "number" &&
|
|
141
|
+
typeof o["mimeType"] === "string" &&
|
|
142
|
+
typeof o["createdAt"] === "number");
|
|
143
|
+
}
|
|
144
|
+
/** Type-guard for IntakeEventDocumentV1 */
|
|
145
|
+
export function isIntakeEventDocumentV1(v) {
|
|
146
|
+
if (typeof v !== "object" || v === null)
|
|
147
|
+
return false;
|
|
148
|
+
const o = v;
|
|
149
|
+
return (o["sourceType"] === "document" &&
|
|
150
|
+
typeof o["orgId"] === "string" &&
|
|
151
|
+
typeof o["intakeId"] === "string" &&
|
|
152
|
+
typeof o["objectId"] === "string" &&
|
|
153
|
+
typeof o["storageId"] === "string" &&
|
|
154
|
+
typeof o["mimeType"] === "string" &&
|
|
155
|
+
typeof o["sizeBytes"] === "number" &&
|
|
156
|
+
typeof o["createdAt"] === "number");
|
|
157
|
+
}
|
|
158
|
+
/** Type-guard for IntakeEventContractV1 */
|
|
159
|
+
export function isIntakeEventContractV1(v) {
|
|
160
|
+
if (typeof v !== "object" || v === null)
|
|
161
|
+
return false;
|
|
162
|
+
const o = v;
|
|
163
|
+
return (o["sourceType"] === "contract" &&
|
|
164
|
+
typeof o["orgId"] === "string" &&
|
|
165
|
+
typeof o["intakeId"] === "string" &&
|
|
166
|
+
typeof o["objectId"] === "string" &&
|
|
167
|
+
typeof o["storageId"] === "string" &&
|
|
168
|
+
typeof o["mimeType"] === "string" &&
|
|
169
|
+
typeof o["sizeBytes"] === "number" &&
|
|
170
|
+
typeof o["createdAt"] === "number");
|
|
171
|
+
}
|
|
172
|
+
/** Type-guard for IntakeEventCandidatureV1 */
|
|
173
|
+
export function isIntakeEventCandidatureV1(v) {
|
|
174
|
+
if (typeof v !== "object" || v === null)
|
|
175
|
+
return false;
|
|
176
|
+
const o = v;
|
|
177
|
+
return (o["sourceType"] === "candidature" &&
|
|
178
|
+
typeof o["orgId"] === "string" &&
|
|
179
|
+
typeof o["intakeId"] === "string" &&
|
|
180
|
+
typeof o["objectId"] === "string" &&
|
|
181
|
+
typeof o["lotObjectId"] === "string" &&
|
|
182
|
+
typeof o["pieceType"] === "string" &&
|
|
183
|
+
CANDIDATURE_PIECE_TYPES.has(o["pieceType"]) &&
|
|
184
|
+
typeof o["storageId"] === "string" &&
|
|
185
|
+
typeof o["mimeType"] === "string" &&
|
|
186
|
+
typeof o["createdAt"] === "number");
|
|
187
|
+
}
|
|
188
|
+
/** Type-guard for IntakeEventExternalV1 */
|
|
189
|
+
export function isIntakeEventExternalV1(v) {
|
|
190
|
+
if (typeof v !== "object" || v === null)
|
|
191
|
+
return false;
|
|
192
|
+
const o = v;
|
|
193
|
+
return (o["sourceType"] === "external-event" &&
|
|
194
|
+
typeof o["orgId"] === "string" &&
|
|
195
|
+
typeof o["intakeId"] === "string" &&
|
|
196
|
+
typeof o["objectId"] === "string" &&
|
|
197
|
+
typeof o["systemId"] === "string" &&
|
|
198
|
+
typeof o["externalEventType"] === "string" &&
|
|
199
|
+
typeof o["payloadJson"] === "string" &&
|
|
200
|
+
typeof o["createdAt"] === "number");
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* isIntakeEventV1 — master type-guard for the full IntakeEventV1 discriminated union.
|
|
204
|
+
* Dispatches on sourceType to the appropriate variant guard.
|
|
205
|
+
*/
|
|
206
|
+
export function isIntakeEventV1(v) {
|
|
207
|
+
if (typeof v !== "object" || v === null)
|
|
208
|
+
return false;
|
|
209
|
+
const o = v;
|
|
210
|
+
switch (o["sourceType"]) {
|
|
211
|
+
case "mail":
|
|
212
|
+
return isIntakeEventMailV1(v);
|
|
213
|
+
case "document":
|
|
214
|
+
return isIntakeEventDocumentV1(v);
|
|
215
|
+
case "contract":
|
|
216
|
+
return isIntakeEventContractV1(v);
|
|
217
|
+
case "candidature":
|
|
218
|
+
return isIntakeEventCandidatureV1(v);
|
|
219
|
+
case "external-event":
|
|
220
|
+
return isIntakeEventExternalV1(v);
|
|
221
|
+
default:
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/** Type-guard for TaskCompleteNormalV1 */
|
|
226
|
+
export function isTaskCompleteNormalV1(v) {
|
|
227
|
+
if (typeof v !== "object" || v === null)
|
|
228
|
+
return false;
|
|
229
|
+
const o = v;
|
|
230
|
+
return (o["completionKind"] === "normal" &&
|
|
231
|
+
typeof o["taskId"] === "string" &&
|
|
232
|
+
typeof o["completedBy"] === "string" &&
|
|
233
|
+
typeof o["completionNote"] === "string" &&
|
|
234
|
+
typeof o["completedAt"] === "number");
|
|
235
|
+
}
|
|
236
|
+
/** Type-guard for TaskCompleteAutoResolvedV1 */
|
|
237
|
+
export function isTaskCompleteAutoResolvedV1(v) {
|
|
238
|
+
if (typeof v !== "object" || v === null)
|
|
239
|
+
return false;
|
|
240
|
+
const o = v;
|
|
241
|
+
return (o["completionKind"] === "auto-resolved" &&
|
|
242
|
+
typeof o["taskId"] === "string" &&
|
|
243
|
+
typeof o["resolvedBy"] === "string" &&
|
|
244
|
+
typeof o["reason"] === "string" &&
|
|
245
|
+
typeof o["completionNote"] === "string" &&
|
|
246
|
+
typeof o["completedAt"] === "number");
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* isTaskCompleteV1 — master type-guard for the full TaskCompleteV1 union.
|
|
250
|
+
*/
|
|
251
|
+
export function isTaskCompleteV1(v) {
|
|
252
|
+
if (typeof v !== "object" || v === null)
|
|
253
|
+
return false;
|
|
254
|
+
const o = v;
|
|
255
|
+
switch (o["completionKind"]) {
|
|
256
|
+
case "normal":
|
|
257
|
+
return isTaskCompleteNormalV1(v);
|
|
258
|
+
case "auto-resolved":
|
|
259
|
+
return isTaskCompleteAutoResolvedV1(v);
|
|
260
|
+
default:
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,8EAA8E;AAC9E,8BAA8B;AAC9B,8EAA8E;AAE9E,OAAO;AACL,6CAA6C;AAC7C,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AAWtC,OAAO;AACL,4DAA4D;AAC5D,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,+BAA+B,CAAC;AAyBvC,wDAAwD;AACxD,MAAM,eAAe,GAAG,IAAI,GAAG,EAAuC,CAAC;AAEvE;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAgB,EAChB,KAAqC;IAErC,IAAI,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,C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B,CAAC,KAAK,QAAQ;QACvC,OAAO,CAAC,CAAC,aAAa,CAAC,KAAK,QAAQ,CACrC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,CAAC,GAAG,CAA4B,CAAC;IACvC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC5B,KAAK,QAAQ;YACX,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC;QACnC,KAAK,eAAe;YAClB,OAAO,4BAA4B,CAAC,CAAC,CAAC,CAAC;QACzC;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* intake-event-v1 — Versioned schema for intake pipeline events.
|
|
3
|
+
*
|
|
4
|
+
* Discriminated union on sourceType — 5 variants:
|
|
5
|
+
* mail — inbound mail ingested from Gmail push / Composio
|
|
6
|
+
* document — document ingested from Drive webhook / manual upload
|
|
7
|
+
* contract — contract document (sous-type discriminé du document)
|
|
8
|
+
* candidature — candidature pieces (F11 — locataire candidate)
|
|
9
|
+
* external-event — tiers system webhook (Hektor, LOJII, Immodvisor …)
|
|
10
|
+
*
|
|
11
|
+
* Rule: no v.any(), no opaque v.string() at public boundaries (Pi doctrine).
|
|
12
|
+
* Naming: V1 suffix on all exported symbols.
|
|
13
|
+
*/
|
|
14
|
+
/** Mail intake variant — sujet, expediteur, thread context */
|
|
15
|
+
export declare const vIntakeEventMailV1: import("convex/values").VObject<{
|
|
16
|
+
threadId?: string;
|
|
17
|
+
sourceType: "mail";
|
|
18
|
+
orgId: string;
|
|
19
|
+
intakeId: string;
|
|
20
|
+
objectId: string;
|
|
21
|
+
sujet: string;
|
|
22
|
+
expediteur: string;
|
|
23
|
+
destinataires: string[];
|
|
24
|
+
dateReception: number;
|
|
25
|
+
mimeType: string;
|
|
26
|
+
createdAt: number;
|
|
27
|
+
}, {
|
|
28
|
+
sourceType: import("convex/values").VLiteral<"mail", "required">;
|
|
29
|
+
orgId: import("convex/values").VString<string, "required">;
|
|
30
|
+
intakeId: import("convex/values").VString<string, "required">;
|
|
31
|
+
objectId: import("convex/values").VString<string, "required">;
|
|
32
|
+
sujet: import("convex/values").VString<string, "required">;
|
|
33
|
+
expediteur: import("convex/values").VString<string, "required">;
|
|
34
|
+
destinataires: import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">;
|
|
35
|
+
threadId: import("convex/values").VString<string | undefined, "optional">;
|
|
36
|
+
dateReception: import("convex/values").VFloat64<number, "required">;
|
|
37
|
+
mimeType: import("convex/values").VString<string, "required">;
|
|
38
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
39
|
+
}, "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "sujet" | "expediteur" | "destinataires" | "dateReception" | "mimeType" | "createdAt" | "threadId">;
|
|
40
|
+
/** Document intake variant — storage reference + type document */
|
|
41
|
+
export declare const vIntakeEventDocumentV1: import("convex/values").VObject<{
|
|
42
|
+
nomenclatureKey?: string;
|
|
43
|
+
sourceType: "document";
|
|
44
|
+
orgId: string;
|
|
45
|
+
intakeId: string;
|
|
46
|
+
objectId: string;
|
|
47
|
+
mimeType: string;
|
|
48
|
+
createdAt: number;
|
|
49
|
+
storageId: string;
|
|
50
|
+
sizeBytes: number;
|
|
51
|
+
}, {
|
|
52
|
+
sourceType: import("convex/values").VLiteral<"document", "required">;
|
|
53
|
+
orgId: import("convex/values").VString<string, "required">;
|
|
54
|
+
intakeId: import("convex/values").VString<string, "required">;
|
|
55
|
+
objectId: import("convex/values").VString<string, "required">;
|
|
56
|
+
storageId: import("convex/values").VString<string, "required">;
|
|
57
|
+
mimeType: import("convex/values").VString<string, "required">;
|
|
58
|
+
sizeBytes: import("convex/values").VFloat64<number, "required">;
|
|
59
|
+
/** Canonical nomenclature key e.g. "BAIL_ENTRANT", "RELEVE_CHARGES" */
|
|
60
|
+
nomenclatureKey: import("convex/values").VString<string | undefined, "optional">;
|
|
61
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
62
|
+
}, "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "mimeType" | "createdAt" | "storageId" | "sizeBytes" | "nomenclatureKey">;
|
|
63
|
+
/** Contract intake variant — document with mandatory contract metadata */
|
|
64
|
+
export declare const vIntakeEventContractV1: import("convex/values").VObject<{
|
|
65
|
+
signataire?: string;
|
|
66
|
+
signingRef?: string;
|
|
67
|
+
sourceType: "contract";
|
|
68
|
+
orgId: string;
|
|
69
|
+
intakeId: string;
|
|
70
|
+
objectId: string;
|
|
71
|
+
mimeType: string;
|
|
72
|
+
createdAt: number;
|
|
73
|
+
storageId: string;
|
|
74
|
+
sizeBytes: number;
|
|
75
|
+
}, {
|
|
76
|
+
sourceType: import("convex/values").VLiteral<"contract", "required">;
|
|
77
|
+
orgId: import("convex/values").VString<string, "required">;
|
|
78
|
+
intakeId: import("convex/values").VString<string, "required">;
|
|
79
|
+
objectId: import("convex/values").VString<string, "required">;
|
|
80
|
+
storageId: import("convex/values").VString<string, "required">;
|
|
81
|
+
mimeType: import("convex/values").VString<string, "required">;
|
|
82
|
+
sizeBytes: import("convex/values").VFloat64<number, "required">;
|
|
83
|
+
/** Clerk userId of the signer (if known at intake time) */
|
|
84
|
+
signataire: import("convex/values").VString<string | undefined, "optional">;
|
|
85
|
+
/** Signing platform reference e.g. Yousign envelope ID */
|
|
86
|
+
signingRef: import("convex/values").VString<string | undefined, "optional">;
|
|
87
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
88
|
+
}, "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "mimeType" | "createdAt" | "storageId" | "sizeBytes" | "signataire" | "signingRef">;
|
|
89
|
+
/** Candidature intake variant — F11 locataire candidate */
|
|
90
|
+
export declare const vIntakeEventCandidatureV1: import("convex/values").VObject<{
|
|
91
|
+
sourceType: "candidature";
|
|
92
|
+
orgId: string;
|
|
93
|
+
intakeId: string;
|
|
94
|
+
objectId: string;
|
|
95
|
+
mimeType: string;
|
|
96
|
+
createdAt: number;
|
|
97
|
+
storageId: string;
|
|
98
|
+
lotObjectId: string;
|
|
99
|
+
pieceType: "identite" | "justificatif_domicile" | "justificatif_revenus" | "avis_imposition" | "quittances_loyer" | "autre";
|
|
100
|
+
}, {
|
|
101
|
+
sourceType: import("convex/values").VLiteral<"candidature", "required">;
|
|
102
|
+
orgId: import("convex/values").VString<string, "required">;
|
|
103
|
+
intakeId: import("convex/values").VString<string, "required">;
|
|
104
|
+
objectId: import("convex/values").VString<string, "required">;
|
|
105
|
+
/** ID of the lot (customObject) the candidature targets */
|
|
106
|
+
lotObjectId: import("convex/values").VString<string, "required">;
|
|
107
|
+
/** Piece type for this candidature item */
|
|
108
|
+
pieceType: import("convex/values").VUnion<"identite" | "justificatif_domicile" | "justificatif_revenus" | "avis_imposition" | "quittances_loyer" | "autre", [import("convex/values").VLiteral<"identite", "required">, import("convex/values").VLiteral<"justificatif_domicile", "required">, import("convex/values").VLiteral<"justificatif_revenus", "required">, import("convex/values").VLiteral<"avis_imposition", "required">, import("convex/values").VLiteral<"quittances_loyer", "required">, import("convex/values").VLiteral<"autre", "required">], "required", never>;
|
|
109
|
+
storageId: import("convex/values").VString<string, "required">;
|
|
110
|
+
mimeType: import("convex/values").VString<string, "required">;
|
|
111
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
112
|
+
}, "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "mimeType" | "createdAt" | "storageId" | "lotObjectId" | "pieceType">;
|
|
113
|
+
/** External event intake variant — third-party system webhook */
|
|
114
|
+
export declare const vIntakeEventExternalV1: import("convex/values").VObject<{
|
|
115
|
+
sourceType: "external-event";
|
|
116
|
+
orgId: string;
|
|
117
|
+
intakeId: string;
|
|
118
|
+
objectId: string;
|
|
119
|
+
createdAt: number;
|
|
120
|
+
systemId: string;
|
|
121
|
+
externalEventType: string;
|
|
122
|
+
payloadJson: string;
|
|
123
|
+
}, {
|
|
124
|
+
sourceType: import("convex/values").VLiteral<"external-event", "required">;
|
|
125
|
+
orgId: import("convex/values").VString<string, "required">;
|
|
126
|
+
intakeId: import("convex/values").VString<string, "required">;
|
|
127
|
+
objectId: import("convex/values").VString<string, "required">;
|
|
128
|
+
/** Stable ID of the external system e.g. "hektor", "lojii", "immodvisor" */
|
|
129
|
+
systemId: import("convex/values").VString<string, "required">;
|
|
130
|
+
/** Event type as declared by the external system */
|
|
131
|
+
externalEventType: import("convex/values").VString<string, "required">;
|
|
132
|
+
/** JSON-serialised payload from the external system (string, not v.any()) */
|
|
133
|
+
payloadJson: import("convex/values").VString<string, "required">;
|
|
134
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
135
|
+
}, "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "createdAt" | "systemId" | "externalEventType" | "payloadJson">;
|
|
136
|
+
/**
|
|
137
|
+
* IntakeEventV1Schema — the master validator for all intake event variants.
|
|
138
|
+
*
|
|
139
|
+
* Usage:
|
|
140
|
+
* import { IntakeEventV1Schema } from "@vantage/event-schemas";
|
|
141
|
+
* const validated = validatePayload(IntakeEventV1Schema, rawPayload);
|
|
142
|
+
*/
|
|
143
|
+
export declare const IntakeEventV1Schema: import("convex/values").VUnion<{
|
|
144
|
+
threadId?: string;
|
|
145
|
+
sourceType: "mail";
|
|
146
|
+
orgId: string;
|
|
147
|
+
intakeId: string;
|
|
148
|
+
objectId: string;
|
|
149
|
+
sujet: string;
|
|
150
|
+
expediteur: string;
|
|
151
|
+
destinataires: string[];
|
|
152
|
+
dateReception: number;
|
|
153
|
+
mimeType: string;
|
|
154
|
+
createdAt: number;
|
|
155
|
+
} | {
|
|
156
|
+
nomenclatureKey?: string;
|
|
157
|
+
sourceType: "document";
|
|
158
|
+
orgId: string;
|
|
159
|
+
intakeId: string;
|
|
160
|
+
objectId: string;
|
|
161
|
+
mimeType: string;
|
|
162
|
+
createdAt: number;
|
|
163
|
+
storageId: string;
|
|
164
|
+
sizeBytes: number;
|
|
165
|
+
} | {
|
|
166
|
+
signataire?: string;
|
|
167
|
+
signingRef?: string;
|
|
168
|
+
sourceType: "contract";
|
|
169
|
+
orgId: string;
|
|
170
|
+
intakeId: string;
|
|
171
|
+
objectId: string;
|
|
172
|
+
mimeType: string;
|
|
173
|
+
createdAt: number;
|
|
174
|
+
storageId: string;
|
|
175
|
+
sizeBytes: number;
|
|
176
|
+
} | {
|
|
177
|
+
sourceType: "candidature";
|
|
178
|
+
orgId: string;
|
|
179
|
+
intakeId: string;
|
|
180
|
+
objectId: string;
|
|
181
|
+
mimeType: string;
|
|
182
|
+
createdAt: number;
|
|
183
|
+
storageId: string;
|
|
184
|
+
lotObjectId: string;
|
|
185
|
+
pieceType: "identite" | "justificatif_domicile" | "justificatif_revenus" | "avis_imposition" | "quittances_loyer" | "autre";
|
|
186
|
+
} | {
|
|
187
|
+
sourceType: "external-event";
|
|
188
|
+
orgId: string;
|
|
189
|
+
intakeId: string;
|
|
190
|
+
objectId: string;
|
|
191
|
+
createdAt: number;
|
|
192
|
+
systemId: string;
|
|
193
|
+
externalEventType: string;
|
|
194
|
+
payloadJson: string;
|
|
195
|
+
}, [import("convex/values").VObject<{
|
|
196
|
+
threadId?: string;
|
|
197
|
+
sourceType: "mail";
|
|
198
|
+
orgId: string;
|
|
199
|
+
intakeId: string;
|
|
200
|
+
objectId: string;
|
|
201
|
+
sujet: string;
|
|
202
|
+
expediteur: string;
|
|
203
|
+
destinataires: string[];
|
|
204
|
+
dateReception: number;
|
|
205
|
+
mimeType: string;
|
|
206
|
+
createdAt: number;
|
|
207
|
+
}, {
|
|
208
|
+
sourceType: import("convex/values").VLiteral<"mail", "required">;
|
|
209
|
+
orgId: import("convex/values").VString<string, "required">;
|
|
210
|
+
intakeId: import("convex/values").VString<string, "required">;
|
|
211
|
+
objectId: import("convex/values").VString<string, "required">;
|
|
212
|
+
sujet: import("convex/values").VString<string, "required">;
|
|
213
|
+
expediteur: import("convex/values").VString<string, "required">;
|
|
214
|
+
destinataires: import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">;
|
|
215
|
+
threadId: import("convex/values").VString<string | undefined, "optional">;
|
|
216
|
+
dateReception: import("convex/values").VFloat64<number, "required">;
|
|
217
|
+
mimeType: import("convex/values").VString<string, "required">;
|
|
218
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
219
|
+
}, "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "sujet" | "expediteur" | "destinataires" | "dateReception" | "mimeType" | "createdAt" | "threadId">, import("convex/values").VObject<{
|
|
220
|
+
nomenclatureKey?: string;
|
|
221
|
+
sourceType: "document";
|
|
222
|
+
orgId: string;
|
|
223
|
+
intakeId: string;
|
|
224
|
+
objectId: string;
|
|
225
|
+
mimeType: string;
|
|
226
|
+
createdAt: number;
|
|
227
|
+
storageId: string;
|
|
228
|
+
sizeBytes: number;
|
|
229
|
+
}, {
|
|
230
|
+
sourceType: import("convex/values").VLiteral<"document", "required">;
|
|
231
|
+
orgId: import("convex/values").VString<string, "required">;
|
|
232
|
+
intakeId: import("convex/values").VString<string, "required">;
|
|
233
|
+
objectId: import("convex/values").VString<string, "required">;
|
|
234
|
+
storageId: import("convex/values").VString<string, "required">;
|
|
235
|
+
mimeType: import("convex/values").VString<string, "required">;
|
|
236
|
+
sizeBytes: import("convex/values").VFloat64<number, "required">;
|
|
237
|
+
/** Canonical nomenclature key e.g. "BAIL_ENTRANT", "RELEVE_CHARGES" */
|
|
238
|
+
nomenclatureKey: import("convex/values").VString<string | undefined, "optional">;
|
|
239
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
240
|
+
}, "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "mimeType" | "createdAt" | "storageId" | "sizeBytes" | "nomenclatureKey">, import("convex/values").VObject<{
|
|
241
|
+
signataire?: string;
|
|
242
|
+
signingRef?: string;
|
|
243
|
+
sourceType: "contract";
|
|
244
|
+
orgId: string;
|
|
245
|
+
intakeId: string;
|
|
246
|
+
objectId: string;
|
|
247
|
+
mimeType: string;
|
|
248
|
+
createdAt: number;
|
|
249
|
+
storageId: string;
|
|
250
|
+
sizeBytes: number;
|
|
251
|
+
}, {
|
|
252
|
+
sourceType: import("convex/values").VLiteral<"contract", "required">;
|
|
253
|
+
orgId: import("convex/values").VString<string, "required">;
|
|
254
|
+
intakeId: import("convex/values").VString<string, "required">;
|
|
255
|
+
objectId: import("convex/values").VString<string, "required">;
|
|
256
|
+
storageId: import("convex/values").VString<string, "required">;
|
|
257
|
+
mimeType: import("convex/values").VString<string, "required">;
|
|
258
|
+
sizeBytes: import("convex/values").VFloat64<number, "required">;
|
|
259
|
+
/** Clerk userId of the signer (if known at intake time) */
|
|
260
|
+
signataire: import("convex/values").VString<string | undefined, "optional">;
|
|
261
|
+
/** Signing platform reference e.g. Yousign envelope ID */
|
|
262
|
+
signingRef: import("convex/values").VString<string | undefined, "optional">;
|
|
263
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
264
|
+
}, "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "mimeType" | "createdAt" | "storageId" | "sizeBytes" | "signataire" | "signingRef">, import("convex/values").VObject<{
|
|
265
|
+
sourceType: "candidature";
|
|
266
|
+
orgId: string;
|
|
267
|
+
intakeId: string;
|
|
268
|
+
objectId: string;
|
|
269
|
+
mimeType: string;
|
|
270
|
+
createdAt: number;
|
|
271
|
+
storageId: string;
|
|
272
|
+
lotObjectId: string;
|
|
273
|
+
pieceType: "identite" | "justificatif_domicile" | "justificatif_revenus" | "avis_imposition" | "quittances_loyer" | "autre";
|
|
274
|
+
}, {
|
|
275
|
+
sourceType: import("convex/values").VLiteral<"candidature", "required">;
|
|
276
|
+
orgId: import("convex/values").VString<string, "required">;
|
|
277
|
+
intakeId: import("convex/values").VString<string, "required">;
|
|
278
|
+
objectId: import("convex/values").VString<string, "required">;
|
|
279
|
+
/** ID of the lot (customObject) the candidature targets */
|
|
280
|
+
lotObjectId: import("convex/values").VString<string, "required">;
|
|
281
|
+
/** Piece type for this candidature item */
|
|
282
|
+
pieceType: import("convex/values").VUnion<"identite" | "justificatif_domicile" | "justificatif_revenus" | "avis_imposition" | "quittances_loyer" | "autre", [import("convex/values").VLiteral<"identite", "required">, import("convex/values").VLiteral<"justificatif_domicile", "required">, import("convex/values").VLiteral<"justificatif_revenus", "required">, import("convex/values").VLiteral<"avis_imposition", "required">, import("convex/values").VLiteral<"quittances_loyer", "required">, import("convex/values").VLiteral<"autre", "required">], "required", never>;
|
|
283
|
+
storageId: import("convex/values").VString<string, "required">;
|
|
284
|
+
mimeType: import("convex/values").VString<string, "required">;
|
|
285
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
286
|
+
}, "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "mimeType" | "createdAt" | "storageId" | "lotObjectId" | "pieceType">, import("convex/values").VObject<{
|
|
287
|
+
sourceType: "external-event";
|
|
288
|
+
orgId: string;
|
|
289
|
+
intakeId: string;
|
|
290
|
+
objectId: string;
|
|
291
|
+
createdAt: number;
|
|
292
|
+
systemId: string;
|
|
293
|
+
externalEventType: string;
|
|
294
|
+
payloadJson: string;
|
|
295
|
+
}, {
|
|
296
|
+
sourceType: import("convex/values").VLiteral<"external-event", "required">;
|
|
297
|
+
orgId: import("convex/values").VString<string, "required">;
|
|
298
|
+
intakeId: import("convex/values").VString<string, "required">;
|
|
299
|
+
objectId: import("convex/values").VString<string, "required">;
|
|
300
|
+
/** Stable ID of the external system e.g. "hektor", "lojii", "immodvisor" */
|
|
301
|
+
systemId: import("convex/values").VString<string, "required">;
|
|
302
|
+
/** Event type as declared by the external system */
|
|
303
|
+
externalEventType: import("convex/values").VString<string, "required">;
|
|
304
|
+
/** JSON-serialised payload from the external system (string, not v.any()) */
|
|
305
|
+
payloadJson: import("convex/values").VString<string, "required">;
|
|
306
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
307
|
+
}, "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "createdAt" | "systemId" | "externalEventType" | "payloadJson">], "required", "sourceType" | "orgId" | "intakeId" | "objectId" | "sujet" | "expediteur" | "destinataires" | "dateReception" | "mimeType" | "createdAt" | "storageId" | "sizeBytes" | "lotObjectId" | "pieceType" | "systemId" | "externalEventType" | "payloadJson" | "threadId" | "nomenclatureKey" | "signataire" | "signingRef">;
|
|
308
|
+
export type IntakeEventMailV1 = {
|
|
309
|
+
sourceType: "mail";
|
|
310
|
+
orgId: string;
|
|
311
|
+
intakeId: string;
|
|
312
|
+
objectId: string;
|
|
313
|
+
sujet: string;
|
|
314
|
+
expediteur: string;
|
|
315
|
+
destinataires: string[];
|
|
316
|
+
threadId?: string;
|
|
317
|
+
dateReception: number;
|
|
318
|
+
mimeType: string;
|
|
319
|
+
createdAt: number;
|
|
320
|
+
};
|
|
321
|
+
export type IntakeEventDocumentV1 = {
|
|
322
|
+
sourceType: "document";
|
|
323
|
+
orgId: string;
|
|
324
|
+
intakeId: string;
|
|
325
|
+
objectId: string;
|
|
326
|
+
storageId: string;
|
|
327
|
+
mimeType: string;
|
|
328
|
+
sizeBytes: number;
|
|
329
|
+
nomenclatureKey?: string;
|
|
330
|
+
createdAt: number;
|
|
331
|
+
};
|
|
332
|
+
export type IntakeEventContractV1 = {
|
|
333
|
+
sourceType: "contract";
|
|
334
|
+
orgId: string;
|
|
335
|
+
intakeId: string;
|
|
336
|
+
objectId: string;
|
|
337
|
+
storageId: string;
|
|
338
|
+
mimeType: string;
|
|
339
|
+
sizeBytes: number;
|
|
340
|
+
signataire?: string;
|
|
341
|
+
signingRef?: string;
|
|
342
|
+
createdAt: number;
|
|
343
|
+
};
|
|
344
|
+
export type IntakeEventCandidatureV1 = {
|
|
345
|
+
sourceType: "candidature";
|
|
346
|
+
orgId: string;
|
|
347
|
+
intakeId: string;
|
|
348
|
+
objectId: string;
|
|
349
|
+
lotObjectId: string;
|
|
350
|
+
pieceType: "identite" | "justificatif_domicile" | "justificatif_revenus" | "avis_imposition" | "quittances_loyer" | "autre";
|
|
351
|
+
storageId: string;
|
|
352
|
+
mimeType: string;
|
|
353
|
+
createdAt: number;
|
|
354
|
+
};
|
|
355
|
+
export type IntakeEventExternalV1 = {
|
|
356
|
+
sourceType: "external-event";
|
|
357
|
+
orgId: string;
|
|
358
|
+
intakeId: string;
|
|
359
|
+
objectId: string;
|
|
360
|
+
systemId: string;
|
|
361
|
+
externalEventType: string;
|
|
362
|
+
payloadJson: string;
|
|
363
|
+
createdAt: number;
|
|
364
|
+
};
|
|
365
|
+
/** Union of all intake event V1 variants */
|
|
366
|
+
export type IntakeEventV1 = IntakeEventMailV1 | IntakeEventDocumentV1 | IntakeEventContractV1 | IntakeEventCandidatureV1 | IntakeEventExternalV1;
|
|
367
|
+
//# sourceMappingURL=intake-event-v1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intake-event-v1.d.ts","sourceRoot":"","sources":["../../src/schemas/intake-event-v1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,8DAA8D;AAC9D,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;qKAY7B,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;IAQjC,uEAAuE;;;2IAGvE,CAAC;AAEH,0EAA0E;AAC1E,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;IAQjC,2DAA2D;;IAE3D,0DAA0D;;;qJAG1D,CAAC;AAEH,2DAA2D;AAC3D,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;IAKpC,2DAA2D;;IAE3D,2CAA2C;;;;;uIAY3C,CAAC;AAEH,iEAAiE;AACjE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;IAKjC,4EAA4E;;IAE5E,oDAAoD;;IAEpD,6EAA6E;;;iIAG7E,CAAC;AAMH;;;;;;GAMG;AACH,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AE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,aAAa,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EACL,UAAU,GACV,uBAAuB,GACvB,sBAAsB,GACtB,iBAAiB,GACjB,kBAAkB,GAClB,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,qBAAqB,GACrB,qBAAqB,GACrB,wBAAwB,GACxB,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* intake-event-v1 — Versioned schema for intake pipeline events.
|
|
3
|
+
*
|
|
4
|
+
* Discriminated union on sourceType — 5 variants:
|
|
5
|
+
* mail — inbound mail ingested from Gmail push / Composio
|
|
6
|
+
* document — document ingested from Drive webhook / manual upload
|
|
7
|
+
* contract — contract document (sous-type discriminé du document)
|
|
8
|
+
* candidature — candidature pieces (F11 — locataire candidate)
|
|
9
|
+
* external-event — tiers system webhook (Hektor, LOJII, Immodvisor …)
|
|
10
|
+
*
|
|
11
|
+
* Rule: no v.any(), no opaque v.string() at public boundaries (Pi doctrine).
|
|
12
|
+
* Naming: V1 suffix on all exported symbols.
|
|
13
|
+
*/
|
|
14
|
+
import { v } from "convex/values";
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Variant sub-validators (reusable by callers)
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
/** Mail intake variant — sujet, expediteur, thread context */
|
|
19
|
+
export const vIntakeEventMailV1 = v.object({
|
|
20
|
+
sourceType: v.literal("mail"),
|
|
21
|
+
orgId: v.string(),
|
|
22
|
+
intakeId: v.string(),
|
|
23
|
+
objectId: v.string(),
|
|
24
|
+
sujet: v.string(),
|
|
25
|
+
expediteur: v.string(),
|
|
26
|
+
destinataires: v.array(v.string()),
|
|
27
|
+
threadId: v.optional(v.string()),
|
|
28
|
+
dateReception: v.number(),
|
|
29
|
+
mimeType: v.string(),
|
|
30
|
+
createdAt: v.number(),
|
|
31
|
+
});
|
|
32
|
+
/** Document intake variant — storage reference + type document */
|
|
33
|
+
export const vIntakeEventDocumentV1 = v.object({
|
|
34
|
+
sourceType: v.literal("document"),
|
|
35
|
+
orgId: v.string(),
|
|
36
|
+
intakeId: v.string(),
|
|
37
|
+
objectId: v.string(),
|
|
38
|
+
storageId: v.string(),
|
|
39
|
+
mimeType: v.string(),
|
|
40
|
+
sizeBytes: v.number(),
|
|
41
|
+
/** Canonical nomenclature key e.g. "BAIL_ENTRANT", "RELEVE_CHARGES" */
|
|
42
|
+
nomenclatureKey: v.optional(v.string()),
|
|
43
|
+
createdAt: v.number(),
|
|
44
|
+
});
|
|
45
|
+
/** Contract intake variant — document with mandatory contract metadata */
|
|
46
|
+
export const vIntakeEventContractV1 = v.object({
|
|
47
|
+
sourceType: v.literal("contract"),
|
|
48
|
+
orgId: v.string(),
|
|
49
|
+
intakeId: v.string(),
|
|
50
|
+
objectId: v.string(),
|
|
51
|
+
storageId: v.string(),
|
|
52
|
+
mimeType: v.string(),
|
|
53
|
+
sizeBytes: v.number(),
|
|
54
|
+
/** Clerk userId of the signer (if known at intake time) */
|
|
55
|
+
signataire: v.optional(v.string()),
|
|
56
|
+
/** Signing platform reference e.g. Yousign envelope ID */
|
|
57
|
+
signingRef: v.optional(v.string()),
|
|
58
|
+
createdAt: v.number(),
|
|
59
|
+
});
|
|
60
|
+
/** Candidature intake variant — F11 locataire candidate */
|
|
61
|
+
export const vIntakeEventCandidatureV1 = v.object({
|
|
62
|
+
sourceType: v.literal("candidature"),
|
|
63
|
+
orgId: v.string(),
|
|
64
|
+
intakeId: v.string(),
|
|
65
|
+
objectId: v.string(),
|
|
66
|
+
/** ID of the lot (customObject) the candidature targets */
|
|
67
|
+
lotObjectId: v.string(),
|
|
68
|
+
/** Piece type for this candidature item */
|
|
69
|
+
pieceType: v.union(v.literal("identite"), v.literal("justificatif_domicile"), v.literal("justificatif_revenus"), v.literal("avis_imposition"), v.literal("quittances_loyer"), v.literal("autre")),
|
|
70
|
+
storageId: v.string(),
|
|
71
|
+
mimeType: v.string(),
|
|
72
|
+
createdAt: v.number(),
|
|
73
|
+
});
|
|
74
|
+
/** External event intake variant — third-party system webhook */
|
|
75
|
+
export const vIntakeEventExternalV1 = v.object({
|
|
76
|
+
sourceType: v.literal("external-event"),
|
|
77
|
+
orgId: v.string(),
|
|
78
|
+
intakeId: v.string(),
|
|
79
|
+
objectId: v.string(),
|
|
80
|
+
/** Stable ID of the external system e.g. "hektor", "lojii", "immodvisor" */
|
|
81
|
+
systemId: v.string(),
|
|
82
|
+
/** Event type as declared by the external system */
|
|
83
|
+
externalEventType: v.string(),
|
|
84
|
+
/** JSON-serialised payload from the external system (string, not v.any()) */
|
|
85
|
+
payloadJson: v.string(),
|
|
86
|
+
createdAt: v.number(),
|
|
87
|
+
});
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Master discriminated union — IntakeEventV1Schema
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
/**
|
|
92
|
+
* IntakeEventV1Schema — the master validator for all intake event variants.
|
|
93
|
+
*
|
|
94
|
+
* Usage:
|
|
95
|
+
* import { IntakeEventV1Schema } from "@vantage/event-schemas";
|
|
96
|
+
* const validated = validatePayload(IntakeEventV1Schema, rawPayload);
|
|
97
|
+
*/
|
|
98
|
+
export const IntakeEventV1Schema = v.union(vIntakeEventMailV1, vIntakeEventDocumentV1, vIntakeEventContractV1, vIntakeEventCandidatureV1, vIntakeEventExternalV1);
|
|
99
|
+
//# sourceMappingURL=intake-event-v1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intake-event-v1.js","sourceRoot":"","sources":["../../src/schemas/intake-event-v1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,8EAA8E;AAC9E,+CAA+C;AAC/C,8EAA8E;AAE9E,8DAA8D;AAC9D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAChC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,QAAQ,EAAE,C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AM,EAAE;IACvB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAEH,8EAA8E;AAC9E,mDAAmD;AACnD,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CACxC,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,CACvB,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* task-complete-v1 — Placeholder schema for Sigma API 5 roadmap (v2).
|
|
3
|
+
*
|
|
4
|
+
* ADR reference: vantage-memory/decisions/c1-public-apis-design-2026-05-21.md
|
|
5
|
+
* §"Hors scope C1.v1" — API 5 `issues.notifyTaskComplete` uses a typed
|
|
6
|
+
* direct mutation in v1. For v2, this schema enables event-driven
|
|
7
|
+
* decoupling (agent-protocol → VP-core) without structural coupling.
|
|
8
|
+
*
|
|
9
|
+
* Status: PLACEHOLDER — not consumed in production yet.
|
|
10
|
+
* Wire-up target: C3/C4 when @vantage/agent-protocol Component is integrated.
|
|
11
|
+
*
|
|
12
|
+
* Rule: no v.any(), explicit typed fields only.
|
|
13
|
+
* Naming: V1 suffix on all exported symbols.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Variant: task completed normally by an agent or user.
|
|
17
|
+
*/
|
|
18
|
+
export declare const vTaskCompleteNormalV1: import("convex/values").VObject<{
|
|
19
|
+
missionId?: string;
|
|
20
|
+
linkedIssueId?: string;
|
|
21
|
+
completionKind: "normal";
|
|
22
|
+
taskId: string;
|
|
23
|
+
completedBy: string;
|
|
24
|
+
completionNote: string;
|
|
25
|
+
completedAt: number;
|
|
26
|
+
}, {
|
|
27
|
+
completionKind: import("convex/values").VLiteral<"normal", "required">;
|
|
28
|
+
taskId: import("convex/values").VString<string, "required">;
|
|
29
|
+
missionId: import("convex/values").VString<string | undefined, "optional">;
|
|
30
|
+
completedBy: import("convex/values").VString<string, "required">;
|
|
31
|
+
completionNote: import("convex/values").VString<string, "required">;
|
|
32
|
+
linkedIssueId: import("convex/values").VString<string | undefined, "optional">;
|
|
33
|
+
completedAt: import("convex/values").VFloat64<number, "required">;
|
|
34
|
+
}, "required", "completionKind" | "taskId" | "completedBy" | "completionNote" | "completedAt" | "missionId" | "linkedIssueId">;
|
|
35
|
+
/**
|
|
36
|
+
* Variant: task auto-resolved by the system (IRP cascade, timeout, etc.).
|
|
37
|
+
*/
|
|
38
|
+
export declare const vTaskCompleteAutoResolvedV1: import("convex/values").VObject<{
|
|
39
|
+
missionId?: string;
|
|
40
|
+
linkedIssueId?: string;
|
|
41
|
+
completionKind: "auto-resolved";
|
|
42
|
+
taskId: string;
|
|
43
|
+
completionNote: string;
|
|
44
|
+
completedAt: number;
|
|
45
|
+
resolvedBy: string;
|
|
46
|
+
reason: string;
|
|
47
|
+
}, {
|
|
48
|
+
completionKind: import("convex/values").VLiteral<"auto-resolved", "required">;
|
|
49
|
+
taskId: import("convex/values").VString<string, "required">;
|
|
50
|
+
missionId: import("convex/values").VString<string | undefined, "optional">;
|
|
51
|
+
resolvedBy: import("convex/values").VString<string, "required">;
|
|
52
|
+
reason: import("convex/values").VString<string, "required">;
|
|
53
|
+
completionNote: import("convex/values").VString<string, "required">;
|
|
54
|
+
linkedIssueId: import("convex/values").VString<string | undefined, "optional">;
|
|
55
|
+
completedAt: import("convex/values").VFloat64<number, "required">;
|
|
56
|
+
}, "required", "completionKind" | "taskId" | "completionNote" | "completedAt" | "resolvedBy" | "reason" | "missionId" | "linkedIssueId">;
|
|
57
|
+
/**
|
|
58
|
+
* TaskCompleteV1Schema — master discriminated union.
|
|
59
|
+
*
|
|
60
|
+
* v2 usage (not yet wired):
|
|
61
|
+
* import { TaskCompleteV1Schema } from "@vantage/event-schemas";
|
|
62
|
+
* const validated = validatePayload(TaskCompleteV1Schema, rawEvent);
|
|
63
|
+
* // then publish into an event bus or call notifyTaskComplete
|
|
64
|
+
*/
|
|
65
|
+
export declare const TaskCompleteV1Schema: import("convex/values").VUnion<{
|
|
66
|
+
missionId?: string;
|
|
67
|
+
linkedIssueId?: string;
|
|
68
|
+
completionKind: "normal";
|
|
69
|
+
taskId: string;
|
|
70
|
+
completedBy: string;
|
|
71
|
+
completionNote: string;
|
|
72
|
+
completedAt: number;
|
|
73
|
+
} | {
|
|
74
|
+
missionId?: string;
|
|
75
|
+
linkedIssueId?: string;
|
|
76
|
+
completionKind: "auto-resolved";
|
|
77
|
+
taskId: string;
|
|
78
|
+
completionNote: string;
|
|
79
|
+
completedAt: number;
|
|
80
|
+
resolvedBy: string;
|
|
81
|
+
reason: string;
|
|
82
|
+
}, [import("convex/values").VObject<{
|
|
83
|
+
missionId?: string;
|
|
84
|
+
linkedIssueId?: string;
|
|
85
|
+
completionKind: "normal";
|
|
86
|
+
taskId: string;
|
|
87
|
+
completedBy: string;
|
|
88
|
+
completionNote: string;
|
|
89
|
+
completedAt: number;
|
|
90
|
+
}, {
|
|
91
|
+
completionKind: import("convex/values").VLiteral<"normal", "required">;
|
|
92
|
+
taskId: import("convex/values").VString<string, "required">;
|
|
93
|
+
missionId: import("convex/values").VString<string | undefined, "optional">;
|
|
94
|
+
completedBy: import("convex/values").VString<string, "required">;
|
|
95
|
+
completionNote: import("convex/values").VString<string, "required">;
|
|
96
|
+
linkedIssueId: import("convex/values").VString<string | undefined, "optional">;
|
|
97
|
+
completedAt: import("convex/values").VFloat64<number, "required">;
|
|
98
|
+
}, "required", "completionKind" | "taskId" | "completedBy" | "completionNote" | "completedAt" | "missionId" | "linkedIssueId">, import("convex/values").VObject<{
|
|
99
|
+
missionId?: string;
|
|
100
|
+
linkedIssueId?: string;
|
|
101
|
+
completionKind: "auto-resolved";
|
|
102
|
+
taskId: string;
|
|
103
|
+
completionNote: string;
|
|
104
|
+
completedAt: number;
|
|
105
|
+
resolvedBy: string;
|
|
106
|
+
reason: string;
|
|
107
|
+
}, {
|
|
108
|
+
completionKind: import("convex/values").VLiteral<"auto-resolved", "required">;
|
|
109
|
+
taskId: import("convex/values").VString<string, "required">;
|
|
110
|
+
missionId: import("convex/values").VString<string | undefined, "optional">;
|
|
111
|
+
resolvedBy: import("convex/values").VString<string, "required">;
|
|
112
|
+
reason: import("convex/values").VString<string, "required">;
|
|
113
|
+
completionNote: import("convex/values").VString<string, "required">;
|
|
114
|
+
linkedIssueId: import("convex/values").VString<string | undefined, "optional">;
|
|
115
|
+
completedAt: import("convex/values").VFloat64<number, "required">;
|
|
116
|
+
}, "required", "completionKind" | "taskId" | "completionNote" | "completedAt" | "resolvedBy" | "reason" | "missionId" | "linkedIssueId">], "required", "completionKind" | "taskId" | "completedBy" | "completionNote" | "completedAt" | "resolvedBy" | "reason" | "missionId" | "linkedIssueId">;
|
|
117
|
+
export type TaskCompleteNormalV1 = {
|
|
118
|
+
completionKind: "normal";
|
|
119
|
+
taskId: string;
|
|
120
|
+
missionId?: string;
|
|
121
|
+
completedBy: string;
|
|
122
|
+
completionNote: string;
|
|
123
|
+
linkedIssueId?: string;
|
|
124
|
+
completedAt: number;
|
|
125
|
+
};
|
|
126
|
+
export type TaskCompleteAutoResolvedV1 = {
|
|
127
|
+
completionKind: "auto-resolved";
|
|
128
|
+
taskId: string;
|
|
129
|
+
missionId?: string;
|
|
130
|
+
resolvedBy: string;
|
|
131
|
+
reason: string;
|
|
132
|
+
completionNote: string;
|
|
133
|
+
linkedIssueId?: string;
|
|
134
|
+
completedAt: number;
|
|
135
|
+
};
|
|
136
|
+
/** Union of all task-complete V1 variants */
|
|
137
|
+
export type TaskCompleteV1 = TaskCompleteNormalV1 | TaskCompleteAutoResolvedV1;
|
|
138
|
+
//# sourceMappingURL=task-complete-v1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-complete-v1.d.ts","sourceRoot":"","sources":["../../src/schemas/task-complete-v1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAQH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;8HAQhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;wIAStC,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gSAGhC,CAAC;AAMF,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,QAAQ,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,cAAc,EAAE,eAAe,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* task-complete-v1 — Placeholder schema for Sigma API 5 roadmap (v2).
|
|
3
|
+
*
|
|
4
|
+
* ADR reference: vantage-memory/decisions/c1-public-apis-design-2026-05-21.md
|
|
5
|
+
* §"Hors scope C1.v1" — API 5 `issues.notifyTaskComplete` uses a typed
|
|
6
|
+
* direct mutation in v1. For v2, this schema enables event-driven
|
|
7
|
+
* decoupling (agent-protocol → VP-core) without structural coupling.
|
|
8
|
+
*
|
|
9
|
+
* Status: PLACEHOLDER — not consumed in production yet.
|
|
10
|
+
* Wire-up target: C3/C4 when @vantage/agent-protocol Component is integrated.
|
|
11
|
+
*
|
|
12
|
+
* Rule: no v.any(), explicit typed fields only.
|
|
13
|
+
* Naming: V1 suffix on all exported symbols.
|
|
14
|
+
*/
|
|
15
|
+
import { v } from "convex/values";
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// TaskCompleteV1Schema — discriminated union (roadmap v2, placeholder)
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
/**
|
|
20
|
+
* Variant: task completed normally by an agent or user.
|
|
21
|
+
*/
|
|
22
|
+
export const vTaskCompleteNormalV1 = v.object({
|
|
23
|
+
completionKind: v.literal("normal"),
|
|
24
|
+
taskId: v.string(),
|
|
25
|
+
missionId: v.optional(v.string()),
|
|
26
|
+
completedBy: v.string(),
|
|
27
|
+
completionNote: v.string(),
|
|
28
|
+
linkedIssueId: v.optional(v.string()),
|
|
29
|
+
completedAt: v.number(),
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Variant: task auto-resolved by the system (IRP cascade, timeout, etc.).
|
|
33
|
+
*/
|
|
34
|
+
export const vTaskCompleteAutoResolvedV1 = v.object({
|
|
35
|
+
completionKind: v.literal("auto-resolved"),
|
|
36
|
+
taskId: v.string(),
|
|
37
|
+
missionId: v.optional(v.string()),
|
|
38
|
+
resolvedBy: v.string(),
|
|
39
|
+
reason: v.string(),
|
|
40
|
+
completionNote: v.string(),
|
|
41
|
+
linkedIssueId: v.optional(v.string()),
|
|
42
|
+
completedAt: v.number(),
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* TaskCompleteV1Schema — master discriminated union.
|
|
46
|
+
*
|
|
47
|
+
* v2 usage (not yet wired):
|
|
48
|
+
* import { TaskCompleteV1Schema } from "@vantage/event-schemas";
|
|
49
|
+
* const validated = validatePayload(TaskCompleteV1Schema, rawEvent);
|
|
50
|
+
* // then publish into an event bus or call notifyTaskComplete
|
|
51
|
+
*/
|
|
52
|
+
export const TaskCompleteV1Schema = v.union(vTaskCompleteNormalV1, vTaskCompleteAutoResolvedV1);
|
|
53
|
+
//# sourceMappingURL=task-complete-v1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-complete-v1.js","sourceRoot":"","sources":["../../src/schemas/task-complete-v1.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,8EAA8E;AAC9E,uEAAuE;AACvE,8EAA8E;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACnC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACrC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IAC1C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACrC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CACzC,qBAAqB,EACrB,2BAA2B,CAC5B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vantageos/event-schemas",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Versioned event schema registry for Vantage Immo feature MCPs. Code-side validators — no DB table. Validates before publication into intakeEvents.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "VantageOS Team",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/elpiarthera/vantage-immo.git",
|
|
11
|
+
"directory": "packages/event-schemas"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"vantageos",
|
|
15
|
+
"event-schemas",
|
|
16
|
+
"convex",
|
|
17
|
+
"validation",
|
|
18
|
+
"intake"
|
|
19
|
+
],
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist/",
|
|
30
|
+
"package.json",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"convex.config.ts"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"registry": "https://registry.npmjs.org/"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc --project tsconfig.json",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"clean": "rm -rf dist"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"convex": ">=1.16.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"typescript": "^5.5.0",
|
|
49
|
+
"convex": "^1.16.0"
|
|
50
|
+
}
|
|
51
|
+
}
|