@walkeros/transformer-validator 0.8.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/README.md +61 -0
- package/dist/dev.d.mts +29 -0
- package/dist/dev.d.ts +29 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/index.d.mts +59 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @walkeros/transformer-validator
|
|
2
|
+
|
|
3
|
+
Event validation transformer using JSON Schema.
|
|
4
|
+
|
|
5
|
+
[Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/transformers/validator)
|
|
6
|
+
| [NPM](https://www.npmjs.com/package/@walkeros/transformer-validator) |
|
|
7
|
+
[Documentation](https://www.walkeros.io/docs/transformers/validator)
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"transformers": {
|
|
14
|
+
"validate": {
|
|
15
|
+
"package": "@walkeros/transformer-validator",
|
|
16
|
+
"config": {
|
|
17
|
+
"logger": { "level": "DEBUG" },
|
|
18
|
+
"settings": {
|
|
19
|
+
"format": true,
|
|
20
|
+
"contract": {
|
|
21
|
+
"product": {
|
|
22
|
+
"add": {
|
|
23
|
+
"schema": {
|
|
24
|
+
"properties": {
|
|
25
|
+
"data": { "required": ["id", "name"] }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- **Format validation**: Validates full WalkerOS.Event structure
|
|
41
|
+
- **Contract validation**: Entity/action-specific business rules
|
|
42
|
+
- **Wildcards**: Match multiple events with `*` patterns
|
|
43
|
+
- **Conditional rules**: Apply different schemas based on event data
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install @walkeros/transformer-validator
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
| Property | Type | Description |
|
|
54
|
+
| ---------- | ------------------------------------------------------------------------------- | --------------------------------------------------- |
|
|
55
|
+
| `format` | `boolean` | Validate WalkerOS.Event structure (default: `true`) |
|
|
56
|
+
| `contract` | [`Contract`](https://www.walkeros.io/docs/transformers/validator#configuration) | Entity/action validation rules (see docs) |
|
|
57
|
+
|
|
58
|
+
## Related
|
|
59
|
+
|
|
60
|
+
- [Documentation](https://www.walkeros.io/docs/transformers/validator)
|
|
61
|
+
- [Transformers Overview](https://www.walkeros.io/docs/transformers)
|
package/dist/dev.d.mts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { JSONSchemaType } from 'ajv';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Partial JSON Schema type - we auto-add type: 'object'.
|
|
5
|
+
* Can include: required, properties, additionalProperties, etc.
|
|
6
|
+
*/
|
|
7
|
+
type JsonSchema = Partial<JSONSchemaType<unknown>>;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Pre-compiled JSON Schema for WalkerOS.Event structure validation.
|
|
11
|
+
* Validates that all required fields exist with correct types.
|
|
12
|
+
*/
|
|
13
|
+
declare const formatSchema: JsonSchema;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Development exports for transformer-validator
|
|
17
|
+
* Used by website documentation and examples
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* JSON Schema describing ValidatorSettings for documentation.
|
|
22
|
+
*/
|
|
23
|
+
declare const settingsSchema: JsonSchema;
|
|
24
|
+
declare const schemas: {
|
|
25
|
+
format: JsonSchema;
|
|
26
|
+
settings: JsonSchema;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { formatSchema, schemas, settingsSchema };
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { JSONSchemaType } from 'ajv';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Partial JSON Schema type - we auto-add type: 'object'.
|
|
5
|
+
* Can include: required, properties, additionalProperties, etc.
|
|
6
|
+
*/
|
|
7
|
+
type JsonSchema = Partial<JSONSchemaType<unknown>>;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Pre-compiled JSON Schema for WalkerOS.Event structure validation.
|
|
11
|
+
* Validates that all required fields exist with correct types.
|
|
12
|
+
*/
|
|
13
|
+
declare const formatSchema: JsonSchema;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Development exports for transformer-validator
|
|
17
|
+
* Used by website documentation and examples
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* JSON Schema describing ValidatorSettings for documentation.
|
|
22
|
+
*/
|
|
23
|
+
declare const settingsSchema: JsonSchema;
|
|
24
|
+
declare const schemas: {
|
|
25
|
+
format: JsonSchema;
|
|
26
|
+
settings: JsonSchema;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { formatSchema, schemas, settingsSchema };
|
package/dist/dev.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n={};((e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})})(n,{formatSchema:()=>p,schemas:()=>c,settingsSchema:()=>s}),module.exports=(e=n,((e,n,p,s)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let c of o(n))i.call(e,c)||c===p||t(e,c,{get:()=>n[c],enumerable:!(s=r(n,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var p={type:"object",required:["name","entity","action","data","context","globals","custom","user","nested","consent","id","trigger","timestamp","timing","group","count","version","source"],properties:{name:{type:"string",pattern:"^\\S+ \\S+$"},entity:{type:"string"},action:{type:"string"},data:{type:"object"},context:{type:"object"},globals:{type:"object"},custom:{type:"object"},user:{type:"object"},nested:{type:"array"},consent:{type:"object"},id:{type:"string"},trigger:{type:"string"},timestamp:{type:"number"},timing:{type:"number"},group:{type:"string"},count:{type:"number"},version:{type:"object",required:["source","tagging"],properties:{source:{type:"string"},tagging:{type:"number"}}},source:{type:"object",required:["type","id","previous_id"],properties:{type:{type:"string"},id:{type:"string"},previous_id:{type:"string"}}}}},s={type:"object",properties:{format:{type:"boolean",description:"Validate full WalkerOS.Event structure. Pre-compiled at init.",default:!0},contract:{type:"object",description:"Event-specific validation rules. Entity/action keyed, supports wildcards."}}},c={format:p,settings:s};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/format-schema.ts"],"sourcesContent":["/**\n * Development exports for transformer-validator\n * Used by website documentation and examples\n */\nimport { formatSchema } from './format-schema';\nimport type { JsonSchema } from './types';\n\nexport { formatSchema };\n\n/**\n * JSON Schema describing ValidatorSettings for documentation.\n */\nexport const settingsSchema: JsonSchema = {\n type: 'object',\n properties: {\n format: {\n type: 'boolean',\n description:\n 'Validate full WalkerOS.Event structure. Pre-compiled at init.',\n default: true,\n },\n contract: {\n type: 'object',\n description:\n 'Event-specific validation rules. Entity/action keyed, supports wildcards.',\n },\n },\n};\n\n// Re-export for convenience\nexport const schemas: { format: JsonSchema; settings: JsonSchema } = {\n format: formatSchema,\n settings: settingsSchema,\n};\n","import type { JsonSchema } from './types';\n\n/**\n * Pre-compiled JSON Schema for WalkerOS.Event structure validation.\n * Validates that all required fields exist with correct types.\n */\nexport const formatSchema: JsonSchema = {\n type: 'object',\n required: [\n 'name',\n 'entity',\n 'action',\n 'data',\n 'context',\n 'globals',\n 'custom',\n 'user',\n 'nested',\n 'consent',\n 'id',\n 'trigger',\n 'timestamp',\n 'timing',\n 'group',\n 'count',\n 'version',\n 'source',\n ],\n properties: {\n name: { type: 'string', pattern: '^\\\\S+ \\\\S+$' }, // \"entity action\"\n entity: { type: 'string' },\n action: { type: 'string' },\n data: { type: 'object' },\n context: { type: 'object' },\n globals: { type: 'object' },\n custom: { type: 'object' },\n user: { type: 'object' },\n nested: { type: 'array' },\n consent: { type: 'object' },\n id: { type: 'string' },\n trigger: { type: 'string' },\n timestamp: { type: 'number' },\n timing: { type: 'number' },\n group: { type: 'string' },\n count: { type: 'number' },\n version: {\n type: 'object',\n required: ['source', 'tagging'],\n properties: {\n source: { type: 'string' },\n tagging: { type: 'number' },\n },\n },\n source: {\n type: 'object',\n required: ['type', 'id', 'previous_id'],\n properties: {\n type: { type: 'string' },\n id: { type: 'string' },\n previous_id: { type: 'string' },\n },\n },\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMO,IAAM,eAA2B;AAAA,EACtC,MAAM;AAAA,EACN,UAAU;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,MAAM,EAAE,MAAM,UAAU,SAAS,cAAc;AAAA;AAAA,IAC/C,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,MAAM,EAAE,MAAM,SAAS;AAAA,IACvB,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,MAAM,EAAE,MAAM,SAAS;AAAA,IACvB,QAAQ,EAAE,MAAM,QAAQ;AAAA,IACxB,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,IAAI,EAAE,MAAM,SAAS;AAAA,IACrB,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,WAAW,EAAE,MAAM,SAAS;AAAA,IAC5B,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,OAAO,EAAE,MAAM,SAAS;AAAA,IACxB,OAAO,EAAE,MAAM,SAAS;AAAA,IACxB,SAAS;AAAA,MACP,MAAM;AAAA,MACN,UAAU,CAAC,UAAU,SAAS;AAAA,MAC9B,YAAY;AAAA,QACV,QAAQ,EAAE,MAAM,SAAS;AAAA,QACzB,SAAS,EAAE,MAAM,SAAS;AAAA,MAC5B;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU,CAAC,QAAQ,MAAM,aAAa;AAAA,MACtC,YAAY;AAAA,QACV,MAAM,EAAE,MAAM,SAAS;AAAA,QACvB,IAAI,EAAE,MAAM,SAAS;AAAA,QACrB,aAAa,EAAE,MAAM,SAAS;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AACF;;;ADnDO,IAAM,iBAA6B;AAAA,EACxC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,aACE;AAAA,MACF,SAAS;AAAA,IACX;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aACE;AAAA,IACJ;AAAA,EACF;AACF;AAGO,IAAM,UAAwD;AAAA,EACnE,QAAQ;AAAA,EACR,UAAU;AACZ;","names":[]}
|
package/dist/dev.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t={type:"object",required:["name","entity","action","data","context","globals","custom","user","nested","consent","id","trigger","timestamp","timing","group","count","version","source"],properties:{name:{type:"string",pattern:"^\\S+ \\S+$"},entity:{type:"string"},action:{type:"string"},data:{type:"object"},context:{type:"object"},globals:{type:"object"},custom:{type:"object"},user:{type:"object"},nested:{type:"array"},consent:{type:"object"},id:{type:"string"},trigger:{type:"string"},timestamp:{type:"number"},timing:{type:"number"},group:{type:"string"},count:{type:"number"},version:{type:"object",required:["source","tagging"],properties:{source:{type:"string"},tagging:{type:"number"}}},source:{type:"object",required:["type","id","previous_id"],properties:{type:{type:"string"},id:{type:"string"},previous_id:{type:"string"}}}}},e={type:"object",properties:{format:{type:"boolean",description:"Validate full WalkerOS.Event structure. Pre-compiled at init.",default:!0},contract:{type:"object",description:"Event-specific validation rules. Entity/action keyed, supports wildcards."}}},r={format:t,settings:e};export{t as formatSchema,r as schemas,e as settingsSchema};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/format-schema.ts","../src/dev.ts"],"sourcesContent":["import type { JsonSchema } from './types';\n\n/**\n * Pre-compiled JSON Schema for WalkerOS.Event structure validation.\n * Validates that all required fields exist with correct types.\n */\nexport const formatSchema: JsonSchema = {\n type: 'object',\n required: [\n 'name',\n 'entity',\n 'action',\n 'data',\n 'context',\n 'globals',\n 'custom',\n 'user',\n 'nested',\n 'consent',\n 'id',\n 'trigger',\n 'timestamp',\n 'timing',\n 'group',\n 'count',\n 'version',\n 'source',\n ],\n properties: {\n name: { type: 'string', pattern: '^\\\\S+ \\\\S+$' }, // \"entity action\"\n entity: { type: 'string' },\n action: { type: 'string' },\n data: { type: 'object' },\n context: { type: 'object' },\n globals: { type: 'object' },\n custom: { type: 'object' },\n user: { type: 'object' },\n nested: { type: 'array' },\n consent: { type: 'object' },\n id: { type: 'string' },\n trigger: { type: 'string' },\n timestamp: { type: 'number' },\n timing: { type: 'number' },\n group: { type: 'string' },\n count: { type: 'number' },\n version: {\n type: 'object',\n required: ['source', 'tagging'],\n properties: {\n source: { type: 'string' },\n tagging: { type: 'number' },\n },\n },\n source: {\n type: 'object',\n required: ['type', 'id', 'previous_id'],\n properties: {\n type: { type: 'string' },\n id: { type: 'string' },\n previous_id: { type: 'string' },\n },\n },\n },\n};\n","/**\n * Development exports for transformer-validator\n * Used by website documentation and examples\n */\nimport { formatSchema } from './format-schema';\nimport type { JsonSchema } from './types';\n\nexport { formatSchema };\n\n/**\n * JSON Schema describing ValidatorSettings for documentation.\n */\nexport const settingsSchema: JsonSchema = {\n type: 'object',\n properties: {\n format: {\n type: 'boolean',\n description:\n 'Validate full WalkerOS.Event structure. Pre-compiled at init.',\n default: true,\n },\n contract: {\n type: 'object',\n description:\n 'Event-specific validation rules. Entity/action keyed, supports wildcards.',\n },\n },\n};\n\n// Re-export for convenience\nexport const schemas: { format: JsonSchema; settings: JsonSchema } = {\n format: formatSchema,\n settings: settingsSchema,\n};\n"],"mappings":";AAMO,IAAM,eAA2B;AAAA,EACtC,MAAM;AAAA,EACN,UAAU;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,MAAM,EAAE,MAAM,UAAU,SAAS,cAAc;AAAA;AAAA,IAC/C,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,MAAM,EAAE,MAAM,SAAS;AAAA,IACvB,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,MAAM,EAAE,MAAM,SAAS;AAAA,IACvB,QAAQ,EAAE,MAAM,QAAQ;AAAA,IACxB,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,IAAI,EAAE,MAAM,SAAS;AAAA,IACrB,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,WAAW,EAAE,MAAM,SAAS;AAAA,IAC5B,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,OAAO,EAAE,MAAM,SAAS;AAAA,IACxB,OAAO,EAAE,MAAM,SAAS;AAAA,IACxB,SAAS;AAAA,MACP,MAAM;AAAA,MACN,UAAU,CAAC,UAAU,SAAS;AAAA,MAC9B,YAAY;AAAA,QACV,QAAQ,EAAE,MAAM,SAAS;AAAA,QACzB,SAAS,EAAE,MAAM,SAAS;AAAA,MAC5B;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU,CAAC,QAAQ,MAAM,aAAa;AAAA,MACtC,YAAY;AAAA,QACV,MAAM,EAAE,MAAM,SAAS;AAAA,QACvB,IAAI,EAAE,MAAM,SAAS;AAAA,QACrB,aAAa,EAAE,MAAM,SAAS;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AACF;;;ACnDO,IAAM,iBAA6B;AAAA,EACxC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,aACE;AAAA,MACF,SAAS;AAAA,IACX;AAAA,IACA,UAAU;AAAA,MACR,MAAM;AAAA,MACN,aACE;AAAA,IACJ;AAAA,EACF;AACF;AAGO,IAAM,UAAwD;AAAA,EACnE,QAAQ;AAAA,EACR,UAAU;AACZ;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Mapping, WalkerOS, Transformer } from '@walkeros/core';
|
|
2
|
+
import { JSONSchemaType } from 'ajv';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Partial JSON Schema type - we auto-add type: 'object'.
|
|
6
|
+
* Can include: required, properties, additionalProperties, etc.
|
|
7
|
+
*/
|
|
8
|
+
type JsonSchema = Partial<JSONSchemaType<unknown>>;
|
|
9
|
+
/**
|
|
10
|
+
* Contract rule for event-specific validation.
|
|
11
|
+
* Extends the shape expected by getMappingEvent.
|
|
12
|
+
*/
|
|
13
|
+
interface ContractRule {
|
|
14
|
+
/**
|
|
15
|
+
* Condition function - first matching rule wins.
|
|
16
|
+
* MUST be synchronous. getMappingEvent uses .find() which doesn't await.
|
|
17
|
+
* For async checks, validate in the schema or use a separate transformer.
|
|
18
|
+
*/
|
|
19
|
+
condition?: (event: WalkerOS.DeepPartialEvent) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* JSON Schema (partial) - we auto-add type: 'object'.
|
|
22
|
+
* Can include: required, properties, additionalProperties, etc.
|
|
23
|
+
*/
|
|
24
|
+
schema: JsonSchema;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Contract extends Mapping.Rules for type compatibility with getMappingEvent.
|
|
28
|
+
* This avoids `as any` casting and ensures strict typing.
|
|
29
|
+
*/
|
|
30
|
+
type Contract = Mapping.Rules<ContractRule>;
|
|
31
|
+
/**
|
|
32
|
+
* Validator transformer settings.
|
|
33
|
+
*/
|
|
34
|
+
interface ValidatorSettings {
|
|
35
|
+
/**
|
|
36
|
+
* Validate full WalkerOS.Event structure.
|
|
37
|
+
* Pre-compiled at transformer init, runs on every event.
|
|
38
|
+
* Validates all fields exist with correct types.
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
format?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Event-specific validation rules.
|
|
44
|
+
* Entity/action keyed, supports wildcards and conditions.
|
|
45
|
+
* Schemas lazy-compiled on first match.
|
|
46
|
+
*/
|
|
47
|
+
contract?: Contract;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Event validation transformer using AJV with JSON Schema.
|
|
52
|
+
*
|
|
53
|
+
* Two validation modes:
|
|
54
|
+
* - format: Pre-compiled WalkerOS.Event structure validation (runs on every event)
|
|
55
|
+
* - contract: Entity/action keyed business rules with lazy compilation
|
|
56
|
+
*/
|
|
57
|
+
declare const transformerValidator: Transformer.Init<Transformer.Types<ValidatorSettings>>;
|
|
58
|
+
|
|
59
|
+
export { type Contract, type ContractRule, type JsonSchema, type ValidatorSettings, transformerValidator };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Mapping, WalkerOS, Transformer } from '@walkeros/core';
|
|
2
|
+
import { JSONSchemaType } from 'ajv';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Partial JSON Schema type - we auto-add type: 'object'.
|
|
6
|
+
* Can include: required, properties, additionalProperties, etc.
|
|
7
|
+
*/
|
|
8
|
+
type JsonSchema = Partial<JSONSchemaType<unknown>>;
|
|
9
|
+
/**
|
|
10
|
+
* Contract rule for event-specific validation.
|
|
11
|
+
* Extends the shape expected by getMappingEvent.
|
|
12
|
+
*/
|
|
13
|
+
interface ContractRule {
|
|
14
|
+
/**
|
|
15
|
+
* Condition function - first matching rule wins.
|
|
16
|
+
* MUST be synchronous. getMappingEvent uses .find() which doesn't await.
|
|
17
|
+
* For async checks, validate in the schema or use a separate transformer.
|
|
18
|
+
*/
|
|
19
|
+
condition?: (event: WalkerOS.DeepPartialEvent) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* JSON Schema (partial) - we auto-add type: 'object'.
|
|
22
|
+
* Can include: required, properties, additionalProperties, etc.
|
|
23
|
+
*/
|
|
24
|
+
schema: JsonSchema;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Contract extends Mapping.Rules for type compatibility with getMappingEvent.
|
|
28
|
+
* This avoids `as any` casting and ensures strict typing.
|
|
29
|
+
*/
|
|
30
|
+
type Contract = Mapping.Rules<ContractRule>;
|
|
31
|
+
/**
|
|
32
|
+
* Validator transformer settings.
|
|
33
|
+
*/
|
|
34
|
+
interface ValidatorSettings {
|
|
35
|
+
/**
|
|
36
|
+
* Validate full WalkerOS.Event structure.
|
|
37
|
+
* Pre-compiled at transformer init, runs on every event.
|
|
38
|
+
* Validates all fields exist with correct types.
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
format?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Event-specific validation rules.
|
|
44
|
+
* Entity/action keyed, supports wildcards and conditions.
|
|
45
|
+
* Schemas lazy-compiled on first match.
|
|
46
|
+
*/
|
|
47
|
+
contract?: Contract;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Event validation transformer using AJV with JSON Schema.
|
|
52
|
+
*
|
|
53
|
+
* Two validation modes:
|
|
54
|
+
* - format: Pre-compiled WalkerOS.Event structure validation (runs on every event)
|
|
55
|
+
* - contract: Entity/action keyed business rules with lazy compilation
|
|
56
|
+
*/
|
|
57
|
+
declare const transformerValidator: Transformer.Init<Transformer.Types<ValidatorSettings>>;
|
|
58
|
+
|
|
59
|
+
export { type Contract, type ContractRule, type JsonSchema, type ValidatorSettings, transformerValidator };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.create,r=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(e,t,i,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let p of n(t))s.call(e,p)||p===i||r(e,p,{get:()=>t[p],enumerable:!(a=o(t,p))||a.enumerable});return e},p={};((e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})})(p,{transformerValidator:()=>y}),module.exports=(e=p,a(r({},"__esModule",{value:!0}),e));var c=((e,o,n)=>(n=null!=e?t(i(e)):{},a(!o&&e&&e.__esModule?n:r(n,"default",{value:e,enumerable:!0}),e)))(require("ajv")),u=require("@walkeros/core"),g={type:"object",required:["name","entity","action","data","context","globals","custom","user","nested","consent","id","trigger","timestamp","timing","group","count","version","source"],properties:{name:{type:"string",pattern:"^\\S+ \\S+$"},entity:{type:"string"},action:{type:"string"},data:{type:"object"},context:{type:"object"},globals:{type:"object"},custom:{type:"object"},user:{type:"object"},nested:{type:"array"},consent:{type:"object"},id:{type:"string"},trigger:{type:"string"},timestamp:{type:"number"},timing:{type:"number"},group:{type:"string"},count:{type:"number"},version:{type:"object",required:["source","tagging"],properties:{source:{type:"string"},tagging:{type:"number"}}},source:{type:"object",required:["type","id","previous_id"],properties:{type:{type:"string"},id:{type:"string"},previous_id:{type:"string"}}}}},y=e=>{const{config:t}=e,r=t.settings||{},{format:o=!0,contract:n}=r,i=new c.default({allErrors:!0,strict:!1}),s=o?i.compile(g):null,a=new WeakMap;return{type:"validator",config:t,async push(e,t){const{logger:r}=t;if(s&&!s(e))return r.error("Event format invalid",{errors:i.errorsText(s.errors)}),!1;if(n){const{eventMapping:t,mappingKey:o}=await(0,u.getMappingEvent)(e,n),s=t;if(null==s?void 0:s.schema){const t=function(e){if(!a.has(e)){const t={type:"object",...e};a.set(e,i.compile(t))}return a.get(e)}(s.schema);if(!t(e))return r.error("Contract validation failed",{rule:o,errors:i.errorsText(t.errors)}),!1;r.debug("Contract validation passed",{rule:o})}}return e}}};//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/transformer.ts","../src/format-schema.ts"],"sourcesContent":["export { transformerValidator } from './transformer';\nexport type {\n ValidatorSettings,\n Contract,\n ContractRule,\n JsonSchema,\n} from './types';\n","import Ajv, { ValidateFunction } from 'ajv';\nimport { getMappingEvent } from '@walkeros/core';\nimport type { Mapping, Transformer } from '@walkeros/core';\nimport { formatSchema } from './format-schema';\nimport type { ValidatorSettings, ContractRule, JsonSchema } from './types';\n\n/**\n * Event validation transformer using AJV with JSON Schema.\n *\n * Two validation modes:\n * - format: Pre-compiled WalkerOS.Event structure validation (runs on every event)\n * - contract: Entity/action keyed business rules with lazy compilation\n */\nexport const transformerValidator: Transformer.Init<\n Transformer.Types<ValidatorSettings>\n> = (context) => {\n const { config } = context;\n const settings = config.settings || {};\n const { format = true, contract } = settings;\n\n const ajv = new Ajv({ allErrors: true, strict: false });\n\n // Pre-compile format validator (runs on every event)\n const formatValidator = format ? ajv.compile(formatSchema) : null;\n\n // Lazy-compiled contract validators - keyed by schema reference\n // Using WeakMap to cache by schema object, handling array rules with conditions\n const contractValidators = new WeakMap<JsonSchema, ValidateFunction>();\n\n function getContractValidator(schema: JsonSchema) {\n if (!contractValidators.has(schema)) {\n // Auto-wrap with type: 'object'\n const fullSchema = { type: 'object', ...schema };\n contractValidators.set(schema, ajv.compile(fullSchema));\n }\n return contractValidators.get(schema)!;\n }\n\n return {\n type: 'validator',\n config,\n\n async push(event, context) {\n const { logger } = context;\n\n // 1. Format validation (pre-compiled, fast)\n if (formatValidator && !formatValidator(event)) {\n logger.error('Event format invalid', {\n errors: ajv.errorsText(formatValidator.errors),\n });\n return false;\n }\n\n // 2. Contract validation (lazy compiled)\n if (contract) {\n // Contract is typed as Mapping.Rules<ContractRule> - cast needed for getMappingEvent\n const { eventMapping: rule, mappingKey } = await getMappingEvent(\n event,\n contract as Mapping.Rules,\n );\n\n // Type assertion: we know our rules have schema\n const contractRule = rule as ContractRule | undefined;\n\n if (contractRule?.schema) {\n const validator = getContractValidator(contractRule.schema);\n\n if (!validator(event)) {\n logger.error('Contract validation failed', {\n rule: mappingKey,\n errors: ajv.errorsText(validator.errors),\n });\n return false;\n }\n\n logger.debug('Contract validation passed', { rule: mappingKey });\n }\n }\n\n return event;\n },\n };\n};\n","import type { JsonSchema } from './types';\n\n/**\n * Pre-compiled JSON Schema for WalkerOS.Event structure validation.\n * Validates that all required fields exist with correct types.\n */\nexport const formatSchema: JsonSchema = {\n type: 'object',\n required: [\n 'name',\n 'entity',\n 'action',\n 'data',\n 'context',\n 'globals',\n 'custom',\n 'user',\n 'nested',\n 'consent',\n 'id',\n 'trigger',\n 'timestamp',\n 'timing',\n 'group',\n 'count',\n 'version',\n 'source',\n ],\n properties: {\n name: { type: 'string', pattern: '^\\\\S+ \\\\S+$' }, // \"entity action\"\n entity: { type: 'string' },\n action: { type: 'string' },\n data: { type: 'object' },\n context: { type: 'object' },\n globals: { type: 'object' },\n custom: { type: 'object' },\n user: { type: 'object' },\n nested: { type: 'array' },\n consent: { type: 'object' },\n id: { type: 'string' },\n trigger: { type: 'string' },\n timestamp: { type: 'number' },\n timing: { type: 'number' },\n group: { type: 'string' },\n count: { type: 'number' },\n version: {\n type: 'object',\n required: ['source', 'tagging'],\n properties: {\n source: { type: 'string' },\n tagging: { type: 'number' },\n },\n },\n source: {\n type: 'object',\n required: ['type', 'id', 'previous_id'],\n properties: {\n type: { type: 'string' },\n id: { type: 'string' },\n previous_id: { type: 'string' },\n },\n },\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAsC;AACtC,kBAAgC;;;ACKzB,IAAM,eAA2B;AAAA,EACtC,MAAM;AAAA,EACN,UAAU;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,MAAM,EAAE,MAAM,UAAU,SAAS,cAAc;AAAA;AAAA,IAC/C,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,MAAM,EAAE,MAAM,SAAS;AAAA,IACvB,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,QAAQ,EAAE,MAAM,SAAS;AAAA,IACzB,MAAM,EAAE,MAAM,SAAS;AAAA,IACvB,QAAQ,EAAE,MAAM,QAAQ;AAAA,IACxB,SAAS,EAAE,MAAM,SAAS;AAAA,IAC1B,IAAI,EAAE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AAS;AACzB,YAAM,EAAE,OAAO,IAAIA;AAGnB,UAAI,mBAAmB,CAAC,gBAAgB,KAAK,GAAG;AAC9C,eAAO,MAAM,wBAAwB;AAAA,UACnC,QAAQ,IAAI,WAAW,gBAAgB,MAAM;AAAA,QAC/C,CAAC;AACD,eAAO;AAAA,MACT;AAGA,UAAI,UAAU;AAEZ,cAAM,EAAE,cAAc,MAAM,WAAW,IAAI,UAAM;AAAA,UAC/C;AAAA,UACA;AAAA,QACF;AAGA,cAAM,eAAe;AAErB,YAAI,6CAAc,QAAQ;AACxB,gBAAM,YAAY,qBAAqB,aAAa,MAAM;AAE1D,cAAI,CAAC,UAAU,KAAK,GAAG;AACrB,mBAAO,MAAM,8BAA8B;AAAA,cACzC,MAAM;AAAA,cACN,QAAQ,IAAI,WAAW,UAAU,MAAM;AAAA,YACzC,CAAC;AACD,mBAAO;AAAA,UACT;AAEA,iBAAO,MAAM,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAAA,QACjE;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["Ajv","context"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"ajv";import{getMappingEvent as t}from"@walkeros/core";var r={type:"object",required:["name","entity","action","data","context","globals","custom","user","nested","consent","id","trigger","timestamp","timing","group","count","version","source"],properties:{name:{type:"string",pattern:"^\\S+ \\S+$"},entity:{type:"string"},action:{type:"string"},data:{type:"object"},context:{type:"object"},globals:{type:"object"},custom:{type:"object"},user:{type:"object"},nested:{type:"array"},consent:{type:"object"},id:{type:"string"},trigger:{type:"string"},timestamp:{type:"number"},timing:{type:"number"},group:{type:"string"},count:{type:"number"},version:{type:"object",required:["source","tagging"],properties:{source:{type:"string"},tagging:{type:"number"}}},source:{type:"object",required:["type","id","previous_id"],properties:{type:{type:"string"},id:{type:"string"},previous_id:{type:"string"}}}}},o=o=>{const{config:n}=o,i=n.settings||{},{format:s=!0,contract:p}=i,a=new e({allErrors:!0,strict:!1}),c=s?a.compile(r):null,g=new WeakMap;return{type:"validator",config:n,async push(e,r){const{logger:o}=r;if(c&&!c(e))return o.error("Event format invalid",{errors:a.errorsText(c.errors)}),!1;if(p){const{eventMapping:r,mappingKey:n}=await t(e,p),i=r;if(null==i?void 0:i.schema){const t=function(e){if(!g.has(e)){const t={type:"object",...e};g.set(e,a.compile(t))}return g.get(e)}(i.schema);if(!t(e))return o.error("Contract validation failed",{rule:n,errors:a.errorsText(t.errors)}),!1;o.debug("Contract validation passed",{rule:n})}}return e}}};export{o as transformerValidator};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transformer.ts","../src/format-schema.ts"],"sourcesContent":["import Ajv, { ValidateFunction } from 'ajv';\nimport { getMappingEvent } from '@walkeros/core';\nimport type { Mapping, Transformer } from '@walkeros/core';\nimport { formatSchema } from './format-schema';\nimport type { ValidatorSettings, ContractRule, JsonSchema } from './types';\n\n/**\n * Event validation transformer using AJV with JSON Schema.\n *\n * Two validation modes:\n * - format: Pre-compiled WalkerOS.Event structure validation (runs on every event)\n * - contract: Entity/action keyed business rules with lazy compilation\n */\nexport const transformerValidator: Transformer.Init<\n Transformer.Types<ValidatorSettings>\n> = (context) => {\n const { config } = context;\n const settings = config.settings || {};\n const { format = true, contract } = settings;\n\n const ajv = new Ajv({ allErrors: true, strict: false });\n\n // Pre-compile format validator (runs on every event)\n const formatValidator = format ? ajv.compile(formatSchema) : null;\n\n // Lazy-compiled contract validators - keyed by schema reference\n // Using WeakMap to cache by schema object, handling array rules with conditions\n const contractValidators = new WeakMap<JsonSchema, ValidateFunction>();\n\n function getContractValidator(schema: JsonSchema) {\n if (!contractValidators.has(schema)) {\n // Auto-wrap with type: 'object'\n const fullSchema = { type: 'object', ...schema };\n contractValidators.set(schema, ajv.compile(fullSchema));\n }\n return contractValidators.get(schema)!;\n }\n\n return {\n type: 'validator',\n config,\n\n async push(event, context) {\n const { logger } = context;\n\n // 1. Format validation (pre-compiled, fast)\n if (formatValidator && !formatValidator(event)) {\n logger.error('Event format invalid', {\n errors: ajv.errorsText(formatValidator.errors),\n });\n return false;\n }\n\n // 2. Contract validation (lazy compiled)\n if (contract) {\n // Contract is typed as Mapping.Rules<ContractRule> - cast needed for getMappingEvent\n const { eventMapping: rule, mappingKey } = await getMappingEvent(\n event,\n contract as Mapping.Rules,\n );\n\n // Type assertion: we know our rules have schema\n const contractRule = rule as ContractRule | undefined;\n\n if (contractRule?.schema) {\n const validator = getContractValidator(contractRule.schema);\n\n if (!validator(event)) {\n logger.error('Contract validation failed', {\n rule: mappingKey,\n errors: ajv.errorsText(validator.errors),\n });\n return false;\n }\n\n logger.debug('Contract validation passed', { rule: mappingKey });\n }\n }\n\n return event;\n },\n };\n};\n","import type { JsonSchema } from './types';\n\n/**\n * Pre-compiled JSON Schema for WalkerOS.Event structure validation.\n * Validates that all required fields exist with correct types.\n */\nexport const formatSchema: JsonSchema = {\n type: 'object',\n required: [\n 'name',\n 'entity',\n 'action',\n 'data',\n 'context',\n 'globals',\n 'custom',\n 'user',\n 'nested',\n 'consent',\n 'id',\n 'trigger',\n 'timestamp',\n 'timing',\n 'group',\n 'count',\n 'version',\n 'source',\n ],\n properties: {\n name: { type: 'string', pattern: '^\\\\S+ \\\\S+$' }, // \"entity action\"\n entity: { type: 'string' },\n action: { type: 'string' },\n data: { type: 'object' },\n context: { type: 'object' },\n globals: { type: 'object' },\n custom: { type: 'object' },\n user: { type: 'object' },\n nested: { type: 'array' },\n consent: { type: 'object' },\n id: { type: 'string' },\n trigger: { type: 'string' },\n timestamp: { type: 'number' },\n timing: { type: 'number' },\n group: { type: 'string' },\n count: { type: 'number' },\n version: {\n type: 'object',\n required: ['source', 'tagging'],\n properties: {\n source: { type: 'string' },\n tagging: { type: 'number' },\n },\n },\n source: {\n type: 'object',\n required: ['type', 'id', 'previous_id'],\n properties: {\n type: { type: 'string' },\n id: { type: 'string' },\n previous_id: { type: 'string'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AAQ,IAAI,WAAW,UAAU,MAAM;AAAA,YACzC,CAAC;AACD,mBAAO;AAAA,UACT;AAEA,iBAAO,MAAM,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAAA,QACjE;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["context"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@walkeros/transformer-validator",
|
|
3
|
+
"description": "Event validation transformer for walkerOS using AJV and JSON Schema",
|
|
4
|
+
"version": "0.8.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./dev": {
|
|
16
|
+
"types": "./dist/dev.d.ts",
|
|
17
|
+
"import": "./dist/dev.mjs",
|
|
18
|
+
"require": "./dist/dev.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist/**"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup --silent",
|
|
26
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
27
|
+
"dev": "jest --watchAll --colors",
|
|
28
|
+
"lint": "tsc --noEmit && eslint \"**/*.ts*\"",
|
|
29
|
+
"test": "jest",
|
|
30
|
+
"update": "npx npm-check-updates -u && npm update"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"ajv": "^8.17.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@walkeros/core": "^0.8.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@walkeros/core": "0.8.0"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"url": "git+https://github.com/elbwalker/walkerOS.git",
|
|
43
|
+
"directory": "packages/transformers/validator"
|
|
44
|
+
},
|
|
45
|
+
"author": "elbwalker <hello@elbwalker.com>",
|
|
46
|
+
"homepage": "https://github.com/elbwalker/walkerOS#readme",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/elbwalker/walkerOS/issues"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"walker",
|
|
52
|
+
"walkerOS",
|
|
53
|
+
"transformer",
|
|
54
|
+
"validator",
|
|
55
|
+
"ajv",
|
|
56
|
+
"json-schema"
|
|
57
|
+
],
|
|
58
|
+
"funding": [
|
|
59
|
+
{
|
|
60
|
+
"type": "GitHub Sponsors",
|
|
61
|
+
"url": "https://github.com/sponsors/elbwalker"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|