Skip to content

Commit 0547364

Browse files
committed
Lib
1 parent 5136b83 commit 0547364

File tree

6 files changed

+120
-0
lines changed

6 files changed

+120
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import 'reflect-metadata';
2+
export declare const DialogFlowParam: (property?: string) => (target: any, key: any, index: any) => any;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
require("reflect-metadata");
4+
const constant_1 = require("../constant");
5+
exports.DialogFlowParam = (property) => {
6+
return (target, key, index) => {
7+
const metadataValue = Reflect.getMetadata(constant_1.DIALOG_FLOW_PARAMS, target) || [];
8+
metadataValue.push({ key, property, index });
9+
Reflect.defineMetadata(constant_1.DIALOG_FLOW_PARAMS, metadataValue, target);
10+
return target;
11+
};
12+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
export declare const dialogFlowResponseData: {
2+
"responseId": string;
3+
"queryResult": {
4+
"queryText": string;
5+
"parameters": {
6+
"date": string;
7+
"geo-city": string;
8+
};
9+
"allRequiredParamsPresent": boolean;
10+
"fulfillmentMessages": {
11+
"text": {
12+
"text": string[];
13+
};
14+
}[];
15+
"outputContexts": {
16+
"name": string;
17+
"lifespanCount": number;
18+
"parameters": {
19+
"date.original": string;
20+
"date": string;
21+
"geo-city.original": string;
22+
"geo-city": string;
23+
};
24+
}[];
25+
"intent": {
26+
"name": string;
27+
"displayName": string;
28+
};
29+
"intentDetectionConfidence": number;
30+
"diagnosticInfo": {
31+
"webhook_latency_ms": number;
32+
};
33+
"languageCode": string;
34+
};
35+
"webhookStatus": {
36+
"code": number;
37+
"message": string;
38+
};
39+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.dialogFlowResponseData = {
4+
"responseId": "1d05835a-1092-442e-b363-910c34c6e735",
5+
"queryResult": {
6+
"queryText": "Météo de demain à marseille",
7+
"parameters": {
8+
"date": "2018-05-16T12:00:00+02:00",
9+
"geo-city": "Marseille"
10+
},
11+
"allRequiredParamsPresent": true,
12+
"fulfillmentMessages": [
13+
{
14+
"text": {
15+
"text": [
16+
""
17+
]
18+
}
19+
}
20+
],
21+
"outputContexts": [
22+
{
23+
"name": "projects/hermes-d8e54/agent/sessions/f060c5a3-f95e-4551-aedd-3d970d0d4dc4/contexts/weather_question",
24+
"lifespanCount": 5,
25+
"parameters": {
26+
"date.original": "de demain",
27+
"date": "2018-05-16T12:00:00+02:00",
28+
"geo-city.original": "marseille",
29+
"geo-city": "Marseille"
30+
}
31+
}
32+
],
33+
"intent": {
34+
"name": "projects/hermes-d8e54/agent/intents/62e2d690-bf1b-4eaa-af39-c9c0d48b8c41",
35+
"displayName": "Question:weather"
36+
},
37+
"intentDetectionConfidence": 1,
38+
"diagnosticInfo": {
39+
"webhook_latency_ms": 75
40+
},
41+
"languageCode": "fr"
42+
},
43+
"webhookStatus": {
44+
"code": 5,
45+
"message": "Webhook call failed. Error: 404 Not Found"
46+
}
47+
};

lib/utils.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare function applyParamsMetadataDecorator(paramsMetadata: any[], args: any[]): any[];

lib/utils.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
function applyParamsMetadataDecorator(paramsMetadata, args) {
4+
if (paramsMetadata.length && args.length) {
5+
for (const param of paramsMetadata) {
6+
if (typeof args[param.index] === 'object') {
7+
if (!param.property) {
8+
args[param.index] = args[param.index];
9+
continue;
10+
}
11+
args[param.index] = param.property
12+
.split('.')
13+
.reduce((accumulator, property) => accumulator[property], args[param.index]);
14+
}
15+
}
16+
}
17+
return args;
18+
}
19+
exports.applyParamsMetadataDecorator = applyParamsMetadataDecorator;

0 commit comments

Comments
 (0)