@aneuhold/core-ts-api-lib 2.1.0 → 2.1.2
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/lib/services/DOFunctionService/DOFunctionService.d.ts.map +1 -1
- package/lib/services/DOFunctionService/DOFunctionService.js +24 -20
- package/lib/services/DOFunctionService/DOFunctionService.js.map +1 -1
- package/lib/services/DOFunctionService/DOFunctionService.ts +54 -19
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DOFunctionService.d.ts","sourceRoot":"./src/","sources":["services/DOFunctionService/DOFunctionService.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;OAEG;IACH,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,CAAmC;IAE9E;;OAEG;IACH,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAkC;IAE3E;;OAEG;IACH,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAkC;IAE3E;;;;;;;;;;;;;OAaG;WACU,gBAAgB,CAC3B,MAAM,SAAS,eAAe,EAC9B,OAAO,SAAS,gBAAgB,EAEhC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,GACjE,OAAO,CAAC,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"DOFunctionService.d.ts","sourceRoot":"./src/","sources":["services/DOFunctionService/DOFunctionService.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;OAEG;IACH,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,CAAmC;IAE9E;;OAEG;IACH,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAkC;IAE3E;;OAEG;IACH,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAkC;IAE3E;;;;;;;;;;;;;OAaG;WACU,gBAAgB,CAC3B,MAAM,SAAS,eAAe,EAC9B,OAAO,SAAS,gBAAgB,EAEhC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,GACjE,OAAO,CAAC,mBAAmB,CAAC;IAyE/B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAwC/B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;CAM/B"}
|
|
@@ -34,8 +34,10 @@ export default class DOFunctionService {
|
|
|
34
34
|
* @returns The raw output of the function call.
|
|
35
35
|
*/
|
|
36
36
|
static async handleApiRequest(functionName, rawInput, handler) {
|
|
37
|
+
DR.logger.info(`[DOFunctionService] handleApiRequest called for "${functionName}".`); // Log entry
|
|
38
|
+
DR.logger.info(`[DOFunctionService] Calling DR.tracer.startSpan for "${functionName}"...`); // Log before startSpan
|
|
37
39
|
return DR.tracer.startSpan(functionName, async (span) => {
|
|
38
|
-
//
|
|
40
|
+
DR.logger.info(`[DOFunctionService] Tracer span callback started for "${functionName}".`); // Log span callback start
|
|
39
41
|
const rawOutput = {
|
|
40
42
|
body: '',
|
|
41
43
|
statusCode: 200,
|
|
@@ -43,45 +45,40 @@ export default class DOFunctionService {
|
|
|
43
45
|
'Content-Type': 'application/octet-stream'
|
|
44
46
|
}
|
|
45
47
|
};
|
|
46
|
-
// Default output
|
|
47
48
|
const defaultOutput = {
|
|
48
49
|
success: false,
|
|
49
50
|
errors: [],
|
|
50
51
|
data: {}
|
|
51
52
|
};
|
|
52
53
|
try {
|
|
53
|
-
//
|
|
54
|
+
DR.logger.info(`[DOFunctionService] Deserializing input for "${functionName}"...`); // Log before deserialize
|
|
54
55
|
const input = this.deserializeInput(rawInput);
|
|
55
|
-
//
|
|
56
|
+
DR.logger.info(`[DOFunctionService] Calling handler function for "${functionName}"...`); // Log before handler
|
|
56
57
|
const output = await handler(input);
|
|
57
|
-
//
|
|
58
|
+
DR.logger.info(`[DOFunctionService] Handler function finished for "${functionName}".`); // Log after handler
|
|
59
|
+
DR.logger.info(`[DOFunctionService] Serializing output for "${functionName}"...`); // Log before serialize
|
|
58
60
|
rawOutput.body = this.serializeOutput(output);
|
|
59
61
|
if (!output.success) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
DR.logger.failure(`[DOFunctionService] Handler reported failure for "${functionName}". Setting status code 400.`); // Log handler failure
|
|
63
|
+
rawOutput.statusCode = 400;
|
|
64
|
+
span?.setStatus({ code: 2, message: 'handler_error' });
|
|
62
65
|
}
|
|
63
66
|
else {
|
|
64
|
-
|
|
67
|
+
DR.logger.success(`[DOFunctionService] Handler reported success for "${functionName}". Setting status code 200.`); // Log handler success
|
|
68
|
+
span?.setStatus({ code: 1, message: 'ok' });
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
catch (e) {
|
|
68
|
-
//
|
|
72
|
+
DR.logger.error(`[DOFunctionService] Error caught in handleApiRequest for "${functionName}": ${String(e)}`); // Log error
|
|
69
73
|
DR.tracer.captureException(e);
|
|
70
|
-
span?.setStatus({ code: 2, message: 'internal_error' });
|
|
71
|
-
// Serialize as JSON if something fails to simplify in case the error
|
|
72
|
-
// happened in the normal serialization.
|
|
74
|
+
span?.setStatus({ code: 2, message: 'internal_error' });
|
|
73
75
|
const error = e;
|
|
74
76
|
defaultOutput.errors.push(JSON.stringify(error, null, 2));
|
|
75
77
|
rawOutput.body = JSON.stringify(defaultOutput);
|
|
76
78
|
rawOutput.headers['Content-Type'] = 'application/json';
|
|
77
79
|
rawOutput.statusCode = 500;
|
|
78
80
|
}
|
|
79
|
-
|
|
80
|
-
// Ensure traces are flushed in serverless environments
|
|
81
|
-
if (DR.tracer.isEnabled()) {
|
|
82
|
-
await DR.tracer.flush(2000);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
81
|
+
DR.logger.info(`[DOFunctionService] Tracer span callback finished for "${functionName}". Returning rawOutput.`); // Log span callback end
|
|
85
82
|
return rawOutput;
|
|
86
83
|
});
|
|
87
84
|
}
|
|
@@ -92,8 +89,15 @@ export default class DOFunctionService {
|
|
|
92
89
|
* @returns The deserialized input object.
|
|
93
90
|
*/
|
|
94
91
|
static deserializeInput(rawInput) {
|
|
95
|
-
|
|
96
|
-
const {
|
|
92
|
+
DR.logger.info(`[DOFunctionService] deserializeInput received rawInput: ${JSON.stringify(rawInput)}`); // Log the raw input
|
|
93
|
+
const { http } = rawInput; // Potential error source
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
95
|
+
if (!http) {
|
|
96
|
+
DR.logger.error('[DOFunctionService] deserializeInput: rawInput.http is undefined!');
|
|
97
|
+
// Optionally throw a more specific error here if needed
|
|
98
|
+
throw new Error('Internal error: rawInput.http is undefined during deserialization.');
|
|
99
|
+
}
|
|
100
|
+
const { body, isBase64Encoded, headers } = http; // This line throws if http is undefined
|
|
97
101
|
let decodedBody;
|
|
98
102
|
if (isBase64Encoded) {
|
|
99
103
|
decodedBody = Buffer.from(body, 'base64');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DOFunctionService.js","sourceRoot":"./src/","sources":["services/DOFunctionService/DOFunctionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ5B,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;OAEG;IACH,MAAM,CAAC,iBAAiB,GAAsB,iBAAiB,CAAC,WAAW,EAAE,CAAC;IAE9E;;OAEG;IACH,MAAM,CAAC,gBAAgB,GAAqB,gBAAgB,CAAC,WAAW,EAAE,CAAC;IAE3E;;OAEG;IACH,MAAM,CAAC,gBAAgB,GAAqB,gBAAgB,CAAC,WAAW,EAAE,CAAC;IAE3E;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAI3B,YAAoB,EACpB,QAA4B,EAC5B,OAAkE;QAElE,OAAO,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YACtD,
|
|
1
|
+
{"version":3,"file":"DOFunctionService.js","sourceRoot":"./src/","sources":["services/DOFunctionService/DOFunctionService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ5B,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAC/D,OAAO,gBAAgB,MAAM,iCAAiC,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC;;OAEG;IACH,MAAM,CAAC,iBAAiB,GAAsB,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MAAM,EAAE,CAAC;YACX,wBAAwB;YACxB,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAW,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,kBAAkB;YAClB,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAW,CAAC;QACnE,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACK,MAAM,CAAC,eAAe,CAC5B,MAAqC;QAErC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC"}
|
|
@@ -52,8 +52,16 @@ export default class DOFunctionService {
|
|
|
52
52
|
rawInput: DOFunctionRawInput,
|
|
53
53
|
handler: (input: TInput) => Promise<DOFunctionCallOutput<TOutput>>
|
|
54
54
|
): Promise<DOFunctionRawOutput> {
|
|
55
|
+
DR.logger.info(
|
|
56
|
+
`[DOFunctionService] handleApiRequest called for "${functionName}".`
|
|
57
|
+
); // Log entry
|
|
58
|
+
DR.logger.info(
|
|
59
|
+
`[DOFunctionService] Calling DR.tracer.startSpan for "${functionName}"...`
|
|
60
|
+
); // Log before startSpan
|
|
55
61
|
return DR.tracer.startSpan(functionName, async (span) => {
|
|
56
|
-
|
|
62
|
+
DR.logger.info(
|
|
63
|
+
`[DOFunctionService] Tracer span callback started for "${functionName}".`
|
|
64
|
+
); // Log span callback start
|
|
57
65
|
const rawOutput: DOFunctionRawOutput = {
|
|
58
66
|
body: '',
|
|
59
67
|
statusCode: 200,
|
|
@@ -61,43 +69,57 @@ export default class DOFunctionService {
|
|
|
61
69
|
'Content-Type': 'application/octet-stream'
|
|
62
70
|
}
|
|
63
71
|
};
|
|
64
|
-
// Default output
|
|
65
72
|
const defaultOutput: DOFunctionCallOutput<TOutput> = {
|
|
66
73
|
success: false,
|
|
67
74
|
errors: [],
|
|
68
75
|
data: {} as TOutput
|
|
69
76
|
};
|
|
77
|
+
|
|
70
78
|
try {
|
|
71
|
-
|
|
79
|
+
DR.logger.info(
|
|
80
|
+
`[DOFunctionService] Deserializing input for "${functionName}"...`
|
|
81
|
+
); // Log before deserialize
|
|
72
82
|
const input: TInput = this.deserializeInput(rawInput);
|
|
73
|
-
|
|
83
|
+
DR.logger.info(
|
|
84
|
+
`[DOFunctionService] Calling handler function for "${functionName}"...`
|
|
85
|
+
); // Log before handler
|
|
74
86
|
const output = await handler(input);
|
|
75
|
-
|
|
87
|
+
DR.logger.info(
|
|
88
|
+
`[DOFunctionService] Handler function finished for "${functionName}".`
|
|
89
|
+
); // Log after handler
|
|
90
|
+
DR.logger.info(
|
|
91
|
+
`[DOFunctionService] Serializing output for "${functionName}"...`
|
|
92
|
+
); // Log before serialize
|
|
76
93
|
rawOutput.body = this.serializeOutput(output);
|
|
94
|
+
|
|
77
95
|
if (!output.success) {
|
|
78
|
-
|
|
79
|
-
|
|
96
|
+
DR.logger.failure(
|
|
97
|
+
`[DOFunctionService] Handler reported failure for "${functionName}". Setting status code 400.`
|
|
98
|
+
); // Log handler failure
|
|
99
|
+
rawOutput.statusCode = 400;
|
|
100
|
+
span?.setStatus({ code: 2, message: 'handler_error' });
|
|
80
101
|
} else {
|
|
81
|
-
|
|
102
|
+
DR.logger.success(
|
|
103
|
+
`[DOFunctionService] Handler reported success for "${functionName}". Setting status code 200.`
|
|
104
|
+
); // Log handler success
|
|
105
|
+
span?.setStatus({ code: 1, message: 'ok' });
|
|
82
106
|
}
|
|
83
107
|
} catch (e) {
|
|
84
|
-
|
|
108
|
+
DR.logger.error(
|
|
109
|
+
`[DOFunctionService] Error caught in handleApiRequest for "${functionName}": ${String(e)}`
|
|
110
|
+
); // Log error
|
|
85
111
|
DR.tracer.captureException(e);
|
|
86
|
-
span?.setStatus({ code: 2, message: 'internal_error' });
|
|
112
|
+
span?.setStatus({ code: 2, message: 'internal_error' });
|
|
87
113
|
|
|
88
|
-
// Serialize as JSON if something fails to simplify in case the error
|
|
89
|
-
// happened in the normal serialization.
|
|
90
114
|
const error = e as Error;
|
|
91
115
|
defaultOutput.errors.push(JSON.stringify(error, null, 2));
|
|
92
116
|
rawOutput.body = JSON.stringify(defaultOutput);
|
|
93
117
|
rawOutput.headers['Content-Type'] = 'application/json';
|
|
94
118
|
rawOutput.statusCode = 500;
|
|
95
|
-
} finally {
|
|
96
|
-
// Ensure traces are flushed in serverless environments
|
|
97
|
-
if (DR.tracer.isEnabled()) {
|
|
98
|
-
await DR.tracer.flush(2000);
|
|
99
|
-
}
|
|
100
119
|
}
|
|
120
|
+
DR.logger.info(
|
|
121
|
+
`[DOFunctionService] Tracer span callback finished for "${functionName}". Returning rawOutput.`
|
|
122
|
+
); // Log span callback end
|
|
101
123
|
return rawOutput;
|
|
102
124
|
});
|
|
103
125
|
}
|
|
@@ -111,8 +133,21 @@ export default class DOFunctionService {
|
|
|
111
133
|
private static deserializeInput<TInput extends DOFunctionInput>(
|
|
112
134
|
rawInput: DOFunctionRawInput
|
|
113
135
|
): TInput {
|
|
114
|
-
|
|
115
|
-
|
|
136
|
+
DR.logger.info(
|
|
137
|
+
`[DOFunctionService] deserializeInput received rawInput: ${JSON.stringify(rawInput)}`
|
|
138
|
+
); // Log the raw input
|
|
139
|
+
const { http } = rawInput; // Potential error source
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
141
|
+
if (!http) {
|
|
142
|
+
DR.logger.error(
|
|
143
|
+
'[DOFunctionService] deserializeInput: rawInput.http is undefined!'
|
|
144
|
+
);
|
|
145
|
+
// Optionally throw a more specific error here if needed
|
|
146
|
+
throw new Error(
|
|
147
|
+
'Internal error: rawInput.http is undefined during deserialization.'
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
const { body, isBase64Encoded, headers } = http; // This line throws if http is undefined
|
|
116
151
|
|
|
117
152
|
let decodedBody: Buffer;
|
|
118
153
|
if (isBase64Encoded) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@aneuhold/core-ts-api-lib",
|
|
3
3
|
"author": "Anton G. Neuhold Jr.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "2.1.
|
|
5
|
+
"version": "2.1.2",
|
|
6
6
|
"description": "A library for interacting with the backend and defining the backend API for personal projects.",
|
|
7
7
|
"packageManager": "yarn@4.6.0",
|
|
8
8
|
"type": "module",
|