@ai-pip/core 0.1.2 → 0.1.3
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 +102 -9
- package/dist/cpe/envelope.d.ts +34 -0
- package/dist/cpe/envelope.d.ts.map +1 -0
- package/dist/cpe/envelope.js +70 -0
- package/dist/cpe/envelope.js.map +1 -0
- package/dist/cpe/exceptions/EnvelopeError.d.ts +8 -0
- package/dist/cpe/exceptions/EnvelopeError.d.ts.map +1 -0
- package/dist/cpe/exceptions/EnvelopeError.js +13 -0
- package/dist/cpe/exceptions/EnvelopeError.js.map +1 -0
- package/dist/cpe/exceptions/index.d.ts +5 -0
- package/dist/cpe/exceptions/index.d.ts.map +1 -0
- package/dist/cpe/exceptions/index.js +5 -0
- package/dist/cpe/exceptions/index.js.map +1 -0
- package/dist/cpe/index.d.ts +24 -0
- package/dist/cpe/index.d.ts.map +1 -0
- package/dist/cpe/index.js +28 -0
- package/dist/cpe/index.js.map +1 -0
- package/dist/cpe/types.d.ts +58 -0
- package/dist/cpe/types.d.ts.map +1 -0
- package/dist/cpe/types.js +5 -0
- package/dist/cpe/types.js.map +1 -0
- package/dist/cpe/utils.d.ts +38 -0
- package/dist/cpe/utils.d.ts.map +1 -0
- package/dist/cpe/utils.js +47 -0
- package/dist/cpe/utils.js.map +1 -0
- package/dist/cpe/value-objects/Metadata.d.ts +32 -0
- package/dist/cpe/value-objects/Metadata.d.ts.map +1 -0
- package/dist/cpe/value-objects/Metadata.js +65 -0
- package/dist/cpe/value-objects/Metadata.js.map +1 -0
- package/dist/cpe/value-objects/Nonce.d.ts +33 -0
- package/dist/cpe/value-objects/Nonce.d.ts.map +1 -0
- package/dist/cpe/value-objects/Nonce.js +44 -0
- package/dist/cpe/value-objects/Nonce.js.map +1 -0
- package/dist/cpe/value-objects/Signature.d.ts +39 -0
- package/dist/cpe/value-objects/Signature.d.ts.map +1 -0
- package/dist/cpe/value-objects/Signature.js +60 -0
- package/dist/cpe/value-objects/Signature.js.map +1 -0
- package/dist/cpe/value-objects/index.d.ts +7 -0
- package/dist/cpe/value-objects/index.d.ts.map +1 -0
- package/dist/cpe/value-objects/index.js +7 -0
- package/dist/cpe/value-objects/index.js.map +1 -0
- package/dist/csl/classify.d.ts +35 -0
- package/dist/csl/classify.d.ts.map +1 -0
- package/dist/csl/classify.js +62 -0
- package/dist/csl/classify.js.map +1 -0
- package/dist/csl/exceptions/ClassificationError.d.ts +12 -0
- package/dist/csl/exceptions/ClassificationError.d.ts.map +1 -0
- package/dist/csl/exceptions/ClassificationError.js +16 -0
- package/dist/csl/exceptions/ClassificationError.js.map +1 -0
- package/dist/csl/exceptions/SegmentationError.d.ts +13 -0
- package/dist/csl/exceptions/SegmentationError.d.ts.map +1 -0
- package/dist/csl/exceptions/SegmentationError.js +18 -0
- package/dist/csl/exceptions/SegmentationError.js.map +1 -0
- package/dist/csl/exceptions/index.d.ts +3 -0
- package/dist/csl/exceptions/index.d.ts.map +1 -0
- package/dist/csl/exceptions/index.js +3 -0
- package/dist/csl/exceptions/index.js.map +1 -0
- package/dist/csl/index.d.ts +24 -0
- package/dist/csl/index.d.ts.map +1 -0
- package/dist/csl/index.js +29 -0
- package/dist/csl/index.js.map +1 -0
- package/dist/csl/lineage.d.ts +31 -0
- package/dist/csl/lineage.d.ts.map +1 -0
- package/dist/csl/lineage.js +36 -0
- package/dist/csl/lineage.js.map +1 -0
- package/dist/csl/segment.d.ts +35 -0
- package/dist/csl/segment.d.ts.map +1 -0
- package/dist/csl/segment.js +90 -0
- package/dist/csl/segment.js.map +1 -0
- package/dist/csl/types.d.ts +97 -0
- package/dist/csl/types.d.ts.map +1 -0
- package/dist/csl/types.js +62 -0
- package/dist/csl/types.js.map +1 -0
- package/dist/csl/utils.d.ts +16 -0
- package/dist/csl/utils.d.ts.map +1 -0
- package/dist/csl/utils.js +27 -0
- package/dist/csl/utils.js.map +1 -0
- package/dist/csl/value-objects/ContentHash.d.ts +18 -0
- package/dist/csl/value-objects/ContentHash.d.ts.map +1 -0
- package/dist/csl/value-objects/ContentHash.js +33 -0
- package/dist/csl/value-objects/ContentHash.js.map +1 -0
- package/dist/csl/value-objects/LineageEntry.d.ts +20 -0
- package/dist/csl/value-objects/LineageEntry.d.ts.map +1 -0
- package/dist/csl/value-objects/LineageEntry.js +20 -0
- package/dist/csl/value-objects/LineageEntry.js.map +1 -0
- package/dist/csl/value-objects/Origin-map.d.ts +21 -0
- package/dist/csl/value-objects/Origin-map.d.ts.map +1 -0
- package/dist/csl/value-objects/Origin-map.js +42 -0
- package/dist/csl/value-objects/Origin-map.js.map +1 -0
- package/dist/csl/value-objects/Origin.d.ts +22 -0
- package/dist/csl/value-objects/Origin.d.ts.map +1 -0
- package/dist/csl/value-objects/Origin.js +38 -0
- package/dist/csl/value-objects/Origin.js.map +1 -0
- package/dist/csl/value-objects/TrustLevel.d.ts +18 -0
- package/dist/csl/value-objects/TrustLevel.d.ts.map +1 -0
- package/dist/csl/value-objects/TrustLevel.js +23 -0
- package/dist/csl/value-objects/TrustLevel.js.map +1 -0
- package/dist/csl/value-objects/index.d.ts +10 -0
- package/dist/csl/value-objects/index.d.ts.map +1 -0
- package/dist/csl/value-objects/index.js +8 -0
- package/dist/csl/value-objects/index.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/isl/exceptions/SanitizationError.d.ts +8 -0
- package/dist/isl/exceptions/SanitizationError.d.ts.map +1 -0
- package/dist/isl/exceptions/SanitizationError.js +13 -0
- package/dist/isl/exceptions/SanitizationError.js.map +1 -0
- package/dist/isl/exceptions/index.d.ts +2 -0
- package/dist/isl/exceptions/index.d.ts.map +1 -0
- package/dist/isl/exceptions/index.js +2 -0
- package/dist/isl/exceptions/index.js.map +1 -0
- package/dist/isl/index.d.ts +12 -0
- package/dist/isl/index.d.ts.map +1 -0
- package/dist/isl/index.js +16 -0
- package/dist/isl/index.js.map +1 -0
- package/dist/isl/sanitize.d.ts +13 -0
- package/dist/isl/sanitize.d.ts.map +1 -0
- package/dist/isl/sanitize.js +74 -0
- package/dist/isl/sanitize.js.map +1 -0
- package/dist/isl/types.d.ts +75 -0
- package/dist/isl/types.d.ts.map +1 -0
- package/dist/isl/types.js +5 -0
- package/dist/isl/types.js.map +1 -0
- package/dist/isl/value-objects/AnomalyScore.d.ts +19 -0
- package/dist/isl/value-objects/AnomalyScore.d.ts.map +1 -0
- package/dist/isl/value-objects/AnomalyScore.js +25 -0
- package/dist/isl/value-objects/AnomalyScore.js.map +1 -0
- package/dist/isl/value-objects/Pattern.d.ts +32 -0
- package/dist/isl/value-objects/Pattern.d.ts.map +1 -0
- package/dist/isl/value-objects/Pattern.js +116 -0
- package/dist/isl/value-objects/Pattern.js.map +1 -0
- package/dist/isl/value-objects/PiDetection.d.ts +22 -0
- package/dist/isl/value-objects/PiDetection.d.ts.map +1 -0
- package/dist/isl/value-objects/PiDetection.js +60 -0
- package/dist/isl/value-objects/PiDetection.js.map +1 -0
- package/dist/isl/value-objects/PiDetectionResult.d.ts +24 -0
- package/dist/isl/value-objects/PiDetectionResult.d.ts.map +1 -0
- package/dist/isl/value-objects/PiDetectionResult.js +90 -0
- package/dist/isl/value-objects/PiDetectionResult.js.map +1 -0
- package/dist/isl/value-objects/PolicyRule.d.ts +39 -0
- package/dist/isl/value-objects/PolicyRule.d.ts.map +1 -0
- package/dist/isl/value-objects/PolicyRule.js +65 -0
- package/dist/isl/value-objects/PolicyRule.js.map +1 -0
- package/dist/isl/value-objects/index.d.ts +9 -0
- package/dist/isl/value-objects/index.d.ts.map +1 -0
- package/dist/isl/value-objects/index.js +8 -0
- package/dist/isl/value-objects/index.js.map +1 -0
- package/dist/shared/index.d.ts +9 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +12 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/lineage.d.ts +29 -0
- package/dist/shared/lineage.d.ts.map +1 -0
- package/dist/shared/lineage.js +36 -0
- package/dist/shared/lineage.js.map +1 -0
- package/package.json +19 -18
- package/src/index.ts +2 -0
- package/tsconfig.json +6 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nonce - Valor único para prevenir ataques de replay
|
|
3
|
+
* Value Object puro e inmutable
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Nonce - Valor único generado aleatoriamente
|
|
7
|
+
*/
|
|
8
|
+
export type Nonce = {
|
|
9
|
+
readonly value: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Genera un nonce único
|
|
13
|
+
*
|
|
14
|
+
* @param length - Longitud del nonce en bytes (default: 16)
|
|
15
|
+
* @returns Nonce único
|
|
16
|
+
*/
|
|
17
|
+
export declare function createNonce(length?: number): Nonce;
|
|
18
|
+
/**
|
|
19
|
+
* Valida que un string sea un nonce válido
|
|
20
|
+
*
|
|
21
|
+
* @param value - String a validar
|
|
22
|
+
* @returns true si es un nonce válido
|
|
23
|
+
*/
|
|
24
|
+
export declare function isValidNonce(value: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Compara dos nonces
|
|
27
|
+
*
|
|
28
|
+
* @param nonce1 - Primer nonce
|
|
29
|
+
* @param nonce2 - Segundo nonce
|
|
30
|
+
* @returns true si son iguales
|
|
31
|
+
*/
|
|
32
|
+
export declare function equalsNonce(nonce1: Nonce, nonce2: Nonce): boolean;
|
|
33
|
+
//# sourceMappingURL=Nonce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Nonce.d.ts","sourceRoot":"","sources":["../../../src/cpe/value-objects/Nonce.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,GAAE,MAAW,GAAG,KAAK,CActD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG,OAAO,CAEjE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nonce - Valor único para prevenir ataques de replay
|
|
3
|
+
* Value Object puro e inmutable
|
|
4
|
+
*/
|
|
5
|
+
import { randomBytes } from 'node:crypto';
|
|
6
|
+
/**
|
|
7
|
+
* Genera un nonce único
|
|
8
|
+
*
|
|
9
|
+
* @param length - Longitud del nonce en bytes (default: 16)
|
|
10
|
+
* @returns Nonce único
|
|
11
|
+
*/
|
|
12
|
+
export function createNonce(length = 16) {
|
|
13
|
+
if (length < 8) {
|
|
14
|
+
throw new Error('Nonce length must be at least 8 bytes');
|
|
15
|
+
}
|
|
16
|
+
if (length > 64) {
|
|
17
|
+
throw new Error('Nonce length must be at most 64 bytes');
|
|
18
|
+
}
|
|
19
|
+
const bytes = randomBytes(length);
|
|
20
|
+
const value = bytes.toString('hex');
|
|
21
|
+
return Object.freeze({
|
|
22
|
+
value,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Valida que un string sea un nonce válido
|
|
27
|
+
*
|
|
28
|
+
* @param value - String a validar
|
|
29
|
+
* @returns true si es un nonce válido
|
|
30
|
+
*/
|
|
31
|
+
export function isValidNonce(value) {
|
|
32
|
+
return /^[a-f0-9]{16,128}$/i.test(value);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Compara dos nonces
|
|
36
|
+
*
|
|
37
|
+
* @param nonce1 - Primer nonce
|
|
38
|
+
* @param nonce2 - Segundo nonce
|
|
39
|
+
* @returns true si son iguales
|
|
40
|
+
*/
|
|
41
|
+
export function equalsNonce(nonce1, nonce2) {
|
|
42
|
+
return nonce1.value === nonce2.value;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=Nonce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Nonce.js","sourceRoot":"","sources":["../../../src/cpe/value-objects/Nonce.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AASzC;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB,EAAE;IAC7C,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IAC1D,CAAC;IACD,IAAI,MAAM,GAAG,EAAE,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IAC1D,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IACjC,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEnC,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK;KACN,CAAC,CAAA;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC1C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,MAAa,EAAE,MAAa;IACtD,OAAO,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature - Firma criptográfica HMAC-SHA256
|
|
3
|
+
* Value Object puro e inmutable
|
|
4
|
+
*/
|
|
5
|
+
import type { SignatureAlgorithm } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Signature - Firma criptográfica
|
|
8
|
+
*/
|
|
9
|
+
export type SignatureVO = {
|
|
10
|
+
readonly value: string;
|
|
11
|
+
readonly algorithm: SignatureAlgorithm;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Genera una firma HMAC-SHA256 del contenido
|
|
15
|
+
*
|
|
16
|
+
* @param content - Contenido a firmar
|
|
17
|
+
* @param secretKey - Clave secreta para HMAC
|
|
18
|
+
* @returns Signature inmutable
|
|
19
|
+
*
|
|
20
|
+
* @throws {Error} Si la clave secreta está vacía
|
|
21
|
+
*/
|
|
22
|
+
export declare function createSignature(content: string, secretKey: string): SignatureVO;
|
|
23
|
+
/**
|
|
24
|
+
* Verifica una firma HMAC-SHA256
|
|
25
|
+
*
|
|
26
|
+
* @param content - Contenido original
|
|
27
|
+
* @param signature - Firma a verificar
|
|
28
|
+
* @param secretKey - Clave secreta para HMAC
|
|
29
|
+
* @returns true si la firma es válida
|
|
30
|
+
*/
|
|
31
|
+
export declare function verifySignature(content: string, signature: string, secretKey: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Valida el formato de una firma
|
|
34
|
+
*
|
|
35
|
+
* @param signature - Firma a validar
|
|
36
|
+
* @returns true si el formato es válido
|
|
37
|
+
*/
|
|
38
|
+
export declare function isValidSignatureFormat(signature: string): boolean;
|
|
39
|
+
//# sourceMappingURL=Signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Signature.d.ts","sourceRoot":"","sources":["../../../src/cpe/value-objects/Signature.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAElD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAA;CACvC,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,WAAW,CAiBb;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAWT;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAGjE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature - Firma criptográfica HMAC-SHA256
|
|
3
|
+
* Value Object puro e inmutable
|
|
4
|
+
*/
|
|
5
|
+
import { createHmac } from 'node:crypto';
|
|
6
|
+
/**
|
|
7
|
+
* Genera una firma HMAC-SHA256 del contenido
|
|
8
|
+
*
|
|
9
|
+
* @param content - Contenido a firmar
|
|
10
|
+
* @param secretKey - Clave secreta para HMAC
|
|
11
|
+
* @returns Signature inmutable
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} Si la clave secreta está vacía
|
|
14
|
+
*/
|
|
15
|
+
export function createSignature(content, secretKey) {
|
|
16
|
+
if (!secretKey || secretKey.length === 0) {
|
|
17
|
+
throw new Error('Secret key is required for signature generation');
|
|
18
|
+
}
|
|
19
|
+
if (typeof content !== 'string') {
|
|
20
|
+
throw new TypeError('Content must be a string');
|
|
21
|
+
}
|
|
22
|
+
const hmac = createHmac('sha256', secretKey);
|
|
23
|
+
hmac.update(content);
|
|
24
|
+
const signature = hmac.digest('hex');
|
|
25
|
+
return Object.freeze({
|
|
26
|
+
value: signature,
|
|
27
|
+
algorithm: 'HMAC-SHA256',
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Verifica una firma HMAC-SHA256
|
|
32
|
+
*
|
|
33
|
+
* @param content - Contenido original
|
|
34
|
+
* @param signature - Firma a verificar
|
|
35
|
+
* @param secretKey - Clave secreta para HMAC
|
|
36
|
+
* @returns true si la firma es válida
|
|
37
|
+
*/
|
|
38
|
+
export function verifySignature(content, signature, secretKey) {
|
|
39
|
+
if (!secretKey || secretKey.length === 0) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const expectedSignature = createSignature(content, secretKey);
|
|
44
|
+
return expectedSignature.value === signature;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Valida el formato de una firma
|
|
52
|
+
*
|
|
53
|
+
* @param signature - Firma a validar
|
|
54
|
+
* @returns true si el formato es válido
|
|
55
|
+
*/
|
|
56
|
+
export function isValidSignatureFormat(signature) {
|
|
57
|
+
// HMAC-SHA256 produce un hash hexadecimal de 64 caracteres
|
|
58
|
+
return /^[a-f0-9]{64}$/i.test(signature);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=Signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Signature.js","sourceRoot":"","sources":["../../../src/cpe/value-objects/Signature.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAWxC;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,SAAiB;IAEjB,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;IACpE,CAAC;IAED,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAA;IACjD,CAAC;IAED,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;IAC5C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACpB,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAEpC,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,SAAS;QAChB,SAAS,EAAE,aAAa;KACzB,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,SAAiB,EACjB,SAAiB;IAEjB,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,iBAAiB,GAAG,eAAe,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QAC7D,OAAO,iBAAiB,CAAC,KAAK,KAAK,SAAS,CAAA;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,SAAiB;IACtD,2DAA2D;IAC3D,OAAO,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cpe/value-objects/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cpe/value-objects/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Origin } from './value-objects/Origin';
|
|
2
|
+
import type { Source } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Clasifica un source y retorna su TrustLevel - función pura determinista
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* - 100% determinista: mismo source → mismo trust level, siempre
|
|
8
|
+
* - Sin efectos secundarios: función pura
|
|
9
|
+
* - Sin análisis de contenido: solo el source importa
|
|
10
|
+
*
|
|
11
|
+
* @param source - El source del contenido ('DOM' | 'UI' | 'SYSTEM' | 'API')
|
|
12
|
+
* @returns TrustLevel determinado por el source
|
|
13
|
+
*
|
|
14
|
+
* @throws {ClassificationError} Si el source no puede ser clasificado
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const trust = classifySource('UI')
|
|
19
|
+
* // Returns: { value: 'TC' }
|
|
20
|
+
*
|
|
21
|
+
* const trust2 = classifySource('DOM')
|
|
22
|
+
* // Returns: { value: 'STC' }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function classifySource(source: Source): import("./value-objects").TrustLevel;
|
|
26
|
+
/**
|
|
27
|
+
* Clasifica un Origin y retorna su TrustLevel - función pura determinista
|
|
28
|
+
*
|
|
29
|
+
* @param origin - El Origin value object
|
|
30
|
+
* @returns TrustLevel determinado por el origin
|
|
31
|
+
*
|
|
32
|
+
* @throws {ClassificationError} Si el origin no está mapeado
|
|
33
|
+
*/
|
|
34
|
+
export declare function classifyOrigin(origin: Origin): import("./value-objects").TrustLevel;
|
|
35
|
+
//# sourceMappingURL=classify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../../src/csl/classify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,wCAyB5C;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,wCAW5C"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createTrustLevel } from './value-objects/TrustLevel';
|
|
2
|
+
import { originMap } from './value-objects/Origin-map';
|
|
3
|
+
import { ClassificationError } from './exceptions';
|
|
4
|
+
import { OriginType } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Clasifica un source y retorna su TrustLevel - función pura determinista
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* - 100% determinista: mismo source → mismo trust level, siempre
|
|
10
|
+
* - Sin efectos secundarios: función pura
|
|
11
|
+
* - Sin análisis de contenido: solo el source importa
|
|
12
|
+
*
|
|
13
|
+
* @param source - El source del contenido ('DOM' | 'UI' | 'SYSTEM' | 'API')
|
|
14
|
+
* @returns TrustLevel determinado por el source
|
|
15
|
+
*
|
|
16
|
+
* @throws {ClassificationError} Si el source no puede ser clasificado
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const trust = classifySource('UI')
|
|
21
|
+
* // Returns: { value: 'TC' }
|
|
22
|
+
*
|
|
23
|
+
* const trust2 = classifySource('DOM')
|
|
24
|
+
* // Returns: { value: 'STC' }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function classifySource(source) {
|
|
28
|
+
// Mapeo simple: Source → OriginType → TrustLevel
|
|
29
|
+
const sourceToOriginType = {
|
|
30
|
+
'UI': OriginType.SYSTEM_GENERATED, // UI directa → TC
|
|
31
|
+
'SYSTEM': OriginType.SYSTEM_GENERATED, // System → TC
|
|
32
|
+
'DOM': OriginType.DOM_VISIBLE, // DOM → STC
|
|
33
|
+
'API': OriginType.NETWORK_FETCHED // API → UC
|
|
34
|
+
};
|
|
35
|
+
const originType = sourceToOriginType[source];
|
|
36
|
+
if (!originType) {
|
|
37
|
+
throw new ClassificationError(`Source '${source}' cannot be classified`);
|
|
38
|
+
}
|
|
39
|
+
const trustLevelType = originMap.get(originType);
|
|
40
|
+
if (!trustLevelType) {
|
|
41
|
+
throw new ClassificationError(`Origin type '${originType}' is not mapped in originMap. ` +
|
|
42
|
+
`All OriginType values must have a corresponding TrustLevel mapping.`);
|
|
43
|
+
}
|
|
44
|
+
return createTrustLevel(trustLevelType);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Clasifica un Origin y retorna su TrustLevel - función pura determinista
|
|
48
|
+
*
|
|
49
|
+
* @param origin - El Origin value object
|
|
50
|
+
* @returns TrustLevel determinado por el origin
|
|
51
|
+
*
|
|
52
|
+
* @throws {ClassificationError} Si el origin no está mapeado
|
|
53
|
+
*/
|
|
54
|
+
export function classifyOrigin(origin) {
|
|
55
|
+
const trustLevelType = originMap.get(origin.type);
|
|
56
|
+
if (!trustLevelType) {
|
|
57
|
+
throw new ClassificationError(`Origin type '${origin.type}' is not mapped in originMap. ` +
|
|
58
|
+
`All OriginType values must have a corresponding TrustLevel mapping.`);
|
|
59
|
+
}
|
|
60
|
+
return createTrustLevel(trustLevelType);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=classify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify.js","sourceRoot":"","sources":["../../src/csl/classify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAGpC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,iDAAiD;IACjD,MAAM,kBAAkB,GAA+B;QACrD,IAAI,EAAE,UAAU,CAAC,gBAAgB,EAAO,kBAAkB;QAC1D,QAAQ,EAAE,UAAU,CAAC,gBAAgB,EAAI,cAAc;QACvD,KAAK,EAAE,UAAU,CAAC,WAAW,EAAY,YAAY;QACrD,KAAK,EAAE,UAAU,CAAC,eAAe,CAAQ,WAAW;KACrD,CAAA;IAED,MAAM,UAAU,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAA;IAE7C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,mBAAmB,CAAC,WAAW,MAAM,wBAAwB,CAAC,CAAA;IAC1E,CAAC;IAED,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAEhD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,mBAAmB,CAC3B,gBAAgB,UAAU,gCAAgC;YAC1D,qEAAqE,CACtE,CAAA;IACH,CAAC;IAED,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAEjD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,mBAAmB,CAC3B,gBAAgB,MAAM,CAAC,IAAI,gCAAgC;YAC3D,qEAAqE,CACtE,CAAA;IACH,CAAC;IAED,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClassificationError is thrown when classification fails.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This error is thrown when:
|
|
6
|
+
* - An origin type is not mapped in originMap
|
|
7
|
+
* - Classification cannot be determined
|
|
8
|
+
*/
|
|
9
|
+
export declare class ClassificationError extends Error {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ClassificationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassificationError.d.ts","sourceRoot":"","sources":["../../../src/csl/exceptions/ClassificationError.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAK5B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClassificationError is thrown when classification fails.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This error is thrown when:
|
|
6
|
+
* - An origin type is not mapped in originMap
|
|
7
|
+
* - Classification cannot be determined
|
|
8
|
+
*/
|
|
9
|
+
export class ClassificationError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'ClassificationError';
|
|
13
|
+
Object.setPrototypeOf(this, ClassificationError.prototype);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ClassificationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassificationError.js","sourceRoot":"","sources":["../../../src/csl/exceptions/ClassificationError.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;QACjC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAA;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SegmentationError is thrown when the segmentation process fails.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This error is thrown when:
|
|
6
|
+
* - Content segmentation fails
|
|
7
|
+
* - Critical pipeline steps fail
|
|
8
|
+
*/
|
|
9
|
+
export declare class SegmentationError extends Error {
|
|
10
|
+
readonly cause?: unknown | undefined;
|
|
11
|
+
constructor(message: string, cause?: unknown | undefined);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=SegmentationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentationError.d.ts","sourceRoot":"","sources":["../../../src/csl/exceptions/SegmentationError.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;aAGxB,KAAK,CAAC,EAAE,OAAO;gBAD/B,OAAO,EAAE,MAAM,EACC,KAAK,CAAC,EAAE,OAAO,YAAA;CAMlC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SegmentationError is thrown when the segmentation process fails.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This error is thrown when:
|
|
6
|
+
* - Content segmentation fails
|
|
7
|
+
* - Critical pipeline steps fail
|
|
8
|
+
*/
|
|
9
|
+
export class SegmentationError extends Error {
|
|
10
|
+
cause;
|
|
11
|
+
constructor(message, cause) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.cause = cause;
|
|
14
|
+
this.name = 'SegmentationError';
|
|
15
|
+
Object.setPrototypeOf(this, SegmentationError.prototype);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=SegmentationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentationError.js","sourceRoot":"","sources":["../../../src/csl/exceptions/SegmentationError.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAGxB;IAFlB,YACE,OAAe,EACC,KAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAA;QAFE,UAAK,GAAL,KAAK,CAAU;QAG/B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;QAC/B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;IAC1D,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/csl/exceptions/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/csl/exceptions/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSL (Context Segmentation Layer) - Core Semántico
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Este es el core semántico de CSL. Solo contiene:
|
|
6
|
+
* - Funciones puras (sin estado)
|
|
7
|
+
* - Value objects inmutables
|
|
8
|
+
* - Tipos y excepciones
|
|
9
|
+
*
|
|
10
|
+
* **NO contiene:**
|
|
11
|
+
* - Detección de prompt injection (va a ISL)
|
|
12
|
+
* - Políticas (van a ISL)
|
|
13
|
+
* - Anomaly scores (van a ISL)
|
|
14
|
+
* - Normalización agresiva (va a ISL)
|
|
15
|
+
* - Servicios con estado (van al SDK)
|
|
16
|
+
*/
|
|
17
|
+
export { segment } from './segment';
|
|
18
|
+
export { classifySource, classifyOrigin } from './classify';
|
|
19
|
+
export { initLineage, createLineageEntry } from './lineage';
|
|
20
|
+
export * from './value-objects';
|
|
21
|
+
export * from './exceptions';
|
|
22
|
+
export * from './types';
|
|
23
|
+
export { generateId, splitByContextRules } from './utils';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/csl/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAG3D,cAAc,iBAAiB,CAAA;AAG/B,cAAc,cAAc,CAAA;AAG5B,cAAc,SAAS,CAAA;AAGvB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSL (Context Segmentation Layer) - Core Semántico
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Este es el core semántico de CSL. Solo contiene:
|
|
6
|
+
* - Funciones puras (sin estado)
|
|
7
|
+
* - Value objects inmutables
|
|
8
|
+
* - Tipos y excepciones
|
|
9
|
+
*
|
|
10
|
+
* **NO contiene:**
|
|
11
|
+
* - Detección de prompt injection (va a ISL)
|
|
12
|
+
* - Políticas (van a ISL)
|
|
13
|
+
* - Anomaly scores (van a ISL)
|
|
14
|
+
* - Normalización agresiva (va a ISL)
|
|
15
|
+
* - Servicios con estado (van al SDK)
|
|
16
|
+
*/
|
|
17
|
+
// Funciones puras principales
|
|
18
|
+
export { segment } from './segment';
|
|
19
|
+
export { classifySource, classifyOrigin } from './classify';
|
|
20
|
+
export { initLineage, createLineageEntry } from './lineage';
|
|
21
|
+
// Value objects
|
|
22
|
+
export * from './value-objects';
|
|
23
|
+
// Exceptions
|
|
24
|
+
export * from './exceptions';
|
|
25
|
+
// Types
|
|
26
|
+
export * from './types';
|
|
27
|
+
// Utils
|
|
28
|
+
export { generateId, splitByContextRules } from './utils';
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/csl/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,8BAA8B;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE3D,gBAAgB;AAChB,cAAc,iBAAiB,CAAA;AAE/B,aAAa;AACb,cAAc,cAAc,CAAA;AAE5B,QAAQ;AACR,cAAc,SAAS,CAAA;AAEvB,QAAQ;AACR,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { LineageEntry } from './value-objects/LineageEntry';
|
|
2
|
+
import type { CSLSegment } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Inicializa el linaje para un segmento - función pura
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Crea la entrada inicial de linaje cuando se crea un segmento en CSL.
|
|
8
|
+
* El core solo registra step y timestamp, sin notes.
|
|
9
|
+
*
|
|
10
|
+
* @param segment - El segmento para el cual inicializar el linaje
|
|
11
|
+
* @returns Array con la entrada inicial de linaje
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const lineage = initLineage(segment)
|
|
16
|
+
* // Returns: [{ step: 'CSL', timestamp: ... }]
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function initLineage(_segment: CSLSegment): LineageEntry[];
|
|
20
|
+
/**
|
|
21
|
+
* Crea una entrada de linaje - función pura
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* El core solo registra step y timestamp.
|
|
25
|
+
* Notes y metadata van en el SDK para observabilidad.
|
|
26
|
+
*
|
|
27
|
+
* @param step - Nombre del paso de procesamiento
|
|
28
|
+
* @returns Nueva entrada de linaje
|
|
29
|
+
*/
|
|
30
|
+
export declare function createLineageEntry(step: string): LineageEntry;
|
|
31
|
+
//# sourceMappingURL=lineage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineage.d.ts","sourceRoot":"","sources":["../../src/csl/lineage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,UAAU,GAAG,YAAY,EAAE,CAIhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAE7D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createLineageEntry as createEntry } from './value-objects/LineageEntry';
|
|
2
|
+
/**
|
|
3
|
+
* Inicializa el linaje para un segmento - función pura
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Crea la entrada inicial de linaje cuando se crea un segmento en CSL.
|
|
7
|
+
* El core solo registra step y timestamp, sin notes.
|
|
8
|
+
*
|
|
9
|
+
* @param segment - El segmento para el cual inicializar el linaje
|
|
10
|
+
* @returns Array con la entrada inicial de linaje
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const lineage = initLineage(segment)
|
|
15
|
+
* // Returns: [{ step: 'CSL', timestamp: ... }]
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function initLineage(_segment) {
|
|
19
|
+
return [
|
|
20
|
+
createEntry('CSL', Date.now())
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Crea una entrada de linaje - función pura
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* El core solo registra step y timestamp.
|
|
28
|
+
* Notes y metadata van en el SDK para observabilidad.
|
|
29
|
+
*
|
|
30
|
+
* @param step - Nombre del paso de procesamiento
|
|
31
|
+
* @returns Nueva entrada de linaje
|
|
32
|
+
*/
|
|
33
|
+
export function createLineageEntry(step) {
|
|
34
|
+
return createEntry(step, Date.now());
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=lineage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineage.js","sourceRoot":"","sources":["../../src/csl/lineage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,IAAI,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAIhF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CAAC,QAAoB;IAC9C,OAAO;QACL,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;KAC/B,CAAA;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CSLInput, CSLResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Segmenta input en segmentos semánticos - función pura principal de CSL
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Esta es la función principal de CSL. Segmenta el contenido, clasifica
|
|
7
|
+
* por origen, e inicializa el linaje. Todo de forma pura y determinista.
|
|
8
|
+
*
|
|
9
|
+
* **Invariantes preservados:**
|
|
10
|
+
* - El contenido original nunca se pierde
|
|
11
|
+
* - El orden de segmentos es estable
|
|
12
|
+
* - Todo segmento tiene linaje inicial
|
|
13
|
+
* - CSL es determinista
|
|
14
|
+
*
|
|
15
|
+
* @param input - Input con contenido y source
|
|
16
|
+
* @returns CSLResult con segmentos clasificados y linaje inicializado
|
|
17
|
+
*
|
|
18
|
+
* @throws {SegmentationError} Si la segmentación falla
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const result = segment({
|
|
23
|
+
* content: 'Hello\nWorld',
|
|
24
|
+
* source: 'UI',
|
|
25
|
+
* metadata: {}
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* // result.segments contiene 2 segmentos, cada uno con:
|
|
29
|
+
* // - content original
|
|
30
|
+
* // - trust level clasificado
|
|
31
|
+
* // - lineage inicializado
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function segment(input: CSLInput): CSLResult;
|
|
35
|
+
//# sourceMappingURL=segment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../src/csl/segment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAc,MAAM,SAAS,CAAA;AAM9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CA4DlD"}
|