@aneuhold/core-ts-api-lib 3.0.0 → 3.0.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/CHANGELOG.md +27 -0
- package/lib/browser.d.ts +5 -7
- package/lib/browser.d.ts.map +1 -1
- package/lib/browser.js +1 -2
- package/lib/browser.js.map +1 -1
- package/lib/browser.ts +6 -19
- package/lib/services/APIService/APIService.d.ts +2 -2
- package/lib/services/APIService/APIService.d.ts.map +1 -1
- package/lib/services/APIService/APIService.ts +2 -2
- package/lib/services/GCloudAPIService/GCloudAPIService.d.ts +2 -2
- package/lib/services/GCloudAPIService/GCloudAPIService.d.ts.map +1 -1
- package/lib/services/GCloudAPIService/GCloudAPIService.js +9 -14
- package/lib/services/GCloudAPIService/GCloudAPIService.js.map +1 -1
- package/lib/services/GCloudAPIService/GCloudAPIService.ts +11 -16
- package/lib/types/AuthCheckPassword.d.ts +13 -0
- package/lib/types/AuthCheckPassword.d.ts.map +1 -0
- package/lib/types/AuthCheckPassword.js +2 -0
- package/lib/types/AuthCheckPassword.js.map +1 -0
- package/lib/types/AuthCheckPassword.ts +13 -0
- package/lib/types/AuthValidateUser.d.ts +34 -0
- package/lib/types/AuthValidateUser.d.ts.map +1 -0
- package/lib/types/AuthValidateUser.js +2 -0
- package/lib/types/AuthValidateUser.js.map +1 -0
- package/lib/types/AuthValidateUser.ts +35 -0
- package/lib/{services/DOFunctionService/functions/projectDashboard.d.ts → types/ProjectDashboard.d.ts} +4 -15
- package/lib/types/ProjectDashboard.d.ts.map +1 -0
- package/lib/types/ProjectDashboard.js +2 -0
- package/lib/types/ProjectDashboard.js.map +1 -0
- package/lib/{services/DOFunctionService/functions/projectDashboard.ts → types/ProjectDashboard.ts} +3 -27
- package/package.json +8 -8
- package/lib/services/DOFunctionService/DOFunction.d.ts +0 -109
- package/lib/services/DOFunctionService/DOFunction.d.ts.map +0 -1
- package/lib/services/DOFunctionService/DOFunction.js +0 -87
- package/lib/services/DOFunctionService/DOFunction.js.map +0 -1
- package/lib/services/DOFunctionService/DOFunction.ts +0 -165
- package/lib/services/DOFunctionService/DOFunctionService.d.ts +0 -54
- package/lib/services/DOFunctionService/DOFunctionService.d.ts.map +0 -1
- package/lib/services/DOFunctionService/DOFunctionService.js +0 -157
- package/lib/services/DOFunctionService/DOFunctionService.js.map +0 -1
- package/lib/services/DOFunctionService/DOFunctionService.ts +0 -191
- package/lib/services/DOFunctionService/functions/authCheckPassword.d.ts +0 -30
- package/lib/services/DOFunctionService/functions/authCheckPassword.d.ts.map +0 -1
- package/lib/services/DOFunctionService/functions/authCheckPassword.js +0 -26
- package/lib/services/DOFunctionService/functions/authCheckPassword.js.map +0 -1
- package/lib/services/DOFunctionService/functions/authCheckPassword.ts +0 -46
- package/lib/services/DOFunctionService/functions/authValidateUser.d.ts +0 -56
- package/lib/services/DOFunctionService/functions/authValidateUser.d.ts.map +0 -1
- package/lib/services/DOFunctionService/functions/authValidateUser.js +0 -32
- package/lib/services/DOFunctionService/functions/authValidateUser.js.map +0 -1
- package/lib/services/DOFunctionService/functions/authValidateUser.ts +0 -72
- package/lib/services/DOFunctionService/functions/projectDashboard.d.ts.map +0 -1
- package/lib/services/DOFunctionService/functions/projectDashboard.js +0 -19
- package/lib/services/DOFunctionService/functions/projectDashboard.js.map +0 -1
- package/lib/tests/ExampleFunction.d.ts +0 -15
- package/lib/tests/ExampleFunction.d.ts.map +0 -1
- package/lib/tests/ExampleFunction.js +0 -16
- package/lib/tests/ExampleFunction.js.map +0 -1
- package/lib/tests/ExampleFunction.ts +0 -31
- package/lib/tests/TestUtil.d.ts +0 -10
- package/lib/tests/TestUtil.d.ts.map +0 -1
- package/lib/tests/TestUtil.js +0 -17
- package/lib/tests/TestUtil.js.map +0 -1
- package/lib/tests/TestUtil.ts +0 -17
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { DR } from '@aneuhold/core-ts-lib';
|
|
2
|
-
import { BSON } from 'bson';
|
|
3
|
-
import type { APIResponse } from '../../types/APIResponse.js';
|
|
4
|
-
import type {
|
|
5
|
-
DOFunctionInput,
|
|
6
|
-
DOFunctionOutput,
|
|
7
|
-
DOFunctionRawInput,
|
|
8
|
-
DOFunctionRawOutput
|
|
9
|
-
} from './DOFunction.js';
|
|
10
|
-
import { isDOFunctionRawInput } from './DOFunction.js';
|
|
11
|
-
import AuthCheckPassword from './functions/authCheckPassword.js';
|
|
12
|
-
import AuthValidateUser from './functions/authValidateUser.js';
|
|
13
|
-
import ProjectDashboard from './functions/projectDashboard.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A service to provide some utility related to Digital Ocean functions.
|
|
17
|
-
*/
|
|
18
|
-
export default class DOFunctionService {
|
|
19
|
-
/**
|
|
20
|
-
* {@link AuthCheckPassword} function instance.
|
|
21
|
-
*/
|
|
22
|
-
static authCheckPassword: AuthCheckPassword = AuthCheckPassword.getFunction();
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* {@link AuthValidateUser} function instance.
|
|
26
|
-
*/
|
|
27
|
-
static authValidateUser: AuthValidateUser = AuthValidateUser.getFunction();
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* {@link ProjectDashboard} function instance.
|
|
31
|
-
*/
|
|
32
|
-
static projectDashboard: ProjectDashboard = ProjectDashboard.getFunction();
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* A generic method to handle any API request on the backend. This has
|
|
36
|
-
* no use on the frontend.
|
|
37
|
-
*
|
|
38
|
-
* This will take care of returning the error if the handler throws, and
|
|
39
|
-
* managing tracing spans via the registered ITracer.
|
|
40
|
-
* Ideally the handler should not throw though unless something really
|
|
41
|
-
* unexpected happened.
|
|
42
|
-
*
|
|
43
|
-
* @param functionName - The name to use for the root tracing span.
|
|
44
|
-
* @param rawInputFromDO - The raw input for the function.
|
|
45
|
-
* @param handler - The handler function to process the input.
|
|
46
|
-
* @returns The raw output of the function call.
|
|
47
|
-
*/
|
|
48
|
-
static async handleApiRequest<TInput extends DOFunctionInput, TOutput extends DOFunctionOutput>(
|
|
49
|
-
functionName: string,
|
|
50
|
-
rawInputFromDO: DOFunctionRawInput | TInput,
|
|
51
|
-
handler: (input: TInput) => Promise<APIResponse<TOutput>>
|
|
52
|
-
): Promise<DOFunctionRawOutput> {
|
|
53
|
-
DR.logger.info(`[DOFunctionService] handleApiRequest called for "${functionName}".`); // Log entry
|
|
54
|
-
DR.logger.info(`[DOFunctionService] Calling DR.tracer.startSpan for "${functionName}"...`); // Log before startSpan
|
|
55
|
-
return DR.tracer.startSpan(functionName, async (span) => {
|
|
56
|
-
DR.logger.info(`[DOFunctionService] Tracer span callback started for "${functionName}".`); // Log span callback start
|
|
57
|
-
const rawOutput: DOFunctionRawOutput = {
|
|
58
|
-
body: '',
|
|
59
|
-
statusCode: 200,
|
|
60
|
-
headers: {
|
|
61
|
-
'Content-Type': 'application/octet-stream'
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const defaultOutput: APIResponse<TOutput> = {
|
|
65
|
-
success: false,
|
|
66
|
-
errors: [],
|
|
67
|
-
data: {} as TOutput
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
DR.logger.info(`[DOFunctionService] Deserializing input for "${functionName}"...`); // Log before deserialize
|
|
72
|
-
const input: TInput = this.deserializeInput(rawInputFromDO);
|
|
73
|
-
DR.logger.info(`[DOFunctionService] Calling handler function for "${functionName}"...`); // Log before handler
|
|
74
|
-
const output = await handler(input);
|
|
75
|
-
DR.logger.info(`[DOFunctionService] Handler function finished for "${functionName}".`); // Log after handler
|
|
76
|
-
DR.logger.info(`[DOFunctionService] Serializing output for "${functionName}"...`); // Log before serialize
|
|
77
|
-
rawOutput.body = this.serializeOutput(output);
|
|
78
|
-
|
|
79
|
-
if (!output.success) {
|
|
80
|
-
DR.logger.warn(
|
|
81
|
-
`[DOFunctionService] Handler reported failure for "${functionName}". Setting status code 400.`
|
|
82
|
-
); // Log handler failure
|
|
83
|
-
rawOutput.statusCode = 400;
|
|
84
|
-
span?.setStatus({ code: 2, message: 'handler_error' });
|
|
85
|
-
} else {
|
|
86
|
-
DR.logger.success(
|
|
87
|
-
`[DOFunctionService] Handler reported success for "${functionName}". Setting status code 200.`
|
|
88
|
-
); // Log handler success
|
|
89
|
-
span?.setStatus({ code: 1, message: 'ok' });
|
|
90
|
-
}
|
|
91
|
-
} catch (e) {
|
|
92
|
-
DR.logger.error(
|
|
93
|
-
`[DOFunctionService] Error caught in handleApiRequest for "${functionName}": ${String(e)}`
|
|
94
|
-
); // Log error
|
|
95
|
-
DR.tracer.captureException(e);
|
|
96
|
-
span?.setStatus({ code: 2, message: 'internal_error' });
|
|
97
|
-
|
|
98
|
-
const error = e as Error;
|
|
99
|
-
defaultOutput.errors.push(JSON.stringify(error, null, 2));
|
|
100
|
-
rawOutput.body = JSON.stringify(defaultOutput);
|
|
101
|
-
rawOutput.headers['Content-Type'] = 'application/json';
|
|
102
|
-
rawOutput.statusCode = 500;
|
|
103
|
-
}
|
|
104
|
-
DR.logger.info(
|
|
105
|
-
`[DOFunctionService] Tracer span callback finished for "${functionName}". Returning rawOutput.`
|
|
106
|
-
); // Log span callback end
|
|
107
|
-
return rawOutput;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Deserializes the raw input into a typed input object using type guards.
|
|
113
|
-
* Handles raw HTTP input, the DO UI wrapper, or already deserialized input.
|
|
114
|
-
*
|
|
115
|
-
* @param inputFromDO - The raw input received from the DO environment.
|
|
116
|
-
* @returns The deserialized input object of type TInput.
|
|
117
|
-
*/
|
|
118
|
-
private static deserializeInput<TInput extends DOFunctionInput>(
|
|
119
|
-
inputFromDO: DOFunctionRawInput | TInput
|
|
120
|
-
): TInput {
|
|
121
|
-
DR.logger.info(`[DOFunctionService] deserializeInput received: ${JSON.stringify(inputFromDO)}`);
|
|
122
|
-
|
|
123
|
-
// 1. Check if it's the standard DOFunctionRawInput (from web: raw)
|
|
124
|
-
if (isDOFunctionRawInput(inputFromDO)) {
|
|
125
|
-
DR.logger.info(
|
|
126
|
-
'[DOFunctionService] Input matches DOFunctionRawInput (via type guard). Proceeding with raw deserialization.'
|
|
127
|
-
);
|
|
128
|
-
const { http } = inputFromDO;
|
|
129
|
-
const { body, isBase64Encoded, headers } = http;
|
|
130
|
-
|
|
131
|
-
let decodedBody: Buffer;
|
|
132
|
-
if (isBase64Encoded) {
|
|
133
|
-
DR.logger.info('[DOFunctionService] Body is base64 encoded, decoding...');
|
|
134
|
-
decodedBody = Buffer.from(body, 'base64');
|
|
135
|
-
} else {
|
|
136
|
-
DR.logger.info('[DOFunctionService] Body is not base64 encoded, using utf8.');
|
|
137
|
-
decodedBody = Buffer.from(body, 'utf8');
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const isBson = headers['content-type'] === 'application/octet-stream';
|
|
141
|
-
let requestData: TInput;
|
|
142
|
-
|
|
143
|
-
if (isBson) {
|
|
144
|
-
DR.logger.info('[DOFunctionService] Deserializing BSON body.');
|
|
145
|
-
try {
|
|
146
|
-
requestData = BSON.deserialize(decodedBody) as TInput;
|
|
147
|
-
} catch (bsonError) {
|
|
148
|
-
DR.logger.error(
|
|
149
|
-
`[DOFunctionService] BSON deserialization failed: ${String(bsonError)}. Falling back to JSON parse.`
|
|
150
|
-
);
|
|
151
|
-
try {
|
|
152
|
-
requestData = JSON.parse(decodedBody.toString('utf8')) as TInput;
|
|
153
|
-
} catch (jsonError) {
|
|
154
|
-
DR.logger.error(`[DOFunctionService] JSON fallback parse failed: ${String(jsonError)}`);
|
|
155
|
-
throw new Error('Failed to deserialize input body as BSON or JSON.');
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
} else {
|
|
159
|
-
DR.logger.info('[DOFunctionService] Deserializing non-BSON body (assuming JSON).');
|
|
160
|
-
try {
|
|
161
|
-
requestData = JSON.parse(decodedBody.toString('utf8')) as TInput;
|
|
162
|
-
} catch (jsonError) {
|
|
163
|
-
DR.logger.error(`[DOFunctionService] JSON parse failed: ${String(jsonError)}`);
|
|
164
|
-
throw new Error('Failed to deserialize input body as JSON.');
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return requestData;
|
|
168
|
-
}
|
|
169
|
-
// 2. Assume it's already the correct TInput type
|
|
170
|
-
else {
|
|
171
|
-
DR.logger.info(
|
|
172
|
-
'[DOFunctionService] Input does not match RawInput. Assuming input is already deserialized TInput.'
|
|
173
|
-
);
|
|
174
|
-
return inputFromDO;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Serializes the output object into a base64 string. This could be updated
|
|
180
|
-
* to support other serialization methods in the future.
|
|
181
|
-
*
|
|
182
|
-
* @param output - The output object to serialize.
|
|
183
|
-
* @returns The serialized output as a base64 string.
|
|
184
|
-
*/
|
|
185
|
-
private static serializeOutput<TOutput extends DOFunctionOutput>(
|
|
186
|
-
output: APIResponse<TOutput>
|
|
187
|
-
): string {
|
|
188
|
-
const bsonBuffer = BSON.serialize(output);
|
|
189
|
-
return Buffer.from(bsonBuffer).toString('base64');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { DOFunctionInput, DOFunctionOutput } from '../DOFunction.js';
|
|
2
|
-
import DOFunction from '../DOFunction.js';
|
|
3
|
-
/**
|
|
4
|
-
* Input interface for {@link AuthCheckPassword}.
|
|
5
|
-
*/
|
|
6
|
-
export interface AuthCheckPasswordInput extends DOFunctionInput {
|
|
7
|
-
password: string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Output interface for {@link AuthCheckPassword}.
|
|
11
|
-
*/
|
|
12
|
-
export interface AuthCheckPasswordOutput extends DOFunctionOutput {
|
|
13
|
-
passwordIsCorrect: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Class representing the AuthCheckPassword function.
|
|
17
|
-
*
|
|
18
|
-
* This class is a singleton and provides a method to get the instance of the function.
|
|
19
|
-
*/
|
|
20
|
-
export default class AuthCheckPassword extends DOFunction<AuthCheckPasswordInput, AuthCheckPasswordOutput> {
|
|
21
|
-
private static instance;
|
|
22
|
-
private constructor();
|
|
23
|
-
/**
|
|
24
|
-
* Gets the singleton instance of {@link AuthCheckPassword}.
|
|
25
|
-
*
|
|
26
|
-
* @returns The instance of the AuthCheckPassword function.
|
|
27
|
-
*/
|
|
28
|
-
static getFunction(): AuthCheckPassword;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=authCheckPassword.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authCheckPassword.d.ts","sourceRoot":"","sources":["../../../../src/services/DOFunctionService/functions/authCheckPassword.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;IAC/D,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAAU,CACvD,sBAAsB,EACtB,uBAAuB,CACxB;IACC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgC;IAEvD,OAAO;IAMP;;;;OAIG;IACH,MAAM,CAAC,WAAW,IAAI,iBAAiB;CAMxC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import DOFunction from '../DOFunction.js';
|
|
2
|
-
/**
|
|
3
|
-
* Class representing the AuthCheckPassword function.
|
|
4
|
-
*
|
|
5
|
-
* This class is a singleton and provides a method to get the instance of the function.
|
|
6
|
-
*/
|
|
7
|
-
export default class AuthCheckPassword extends DOFunction {
|
|
8
|
-
static instance;
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
this.url =
|
|
12
|
-
'https://faas-sfo3-7872a1dd.doserverless.co/api/v1/web/fn-66dd3ef6-c21d-46dc-b7ae-caf2ac8041ec/auth/checkPassword';
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Gets the singleton instance of {@link AuthCheckPassword}.
|
|
16
|
-
*
|
|
17
|
-
* @returns The instance of the AuthCheckPassword function.
|
|
18
|
-
*/
|
|
19
|
-
static getFunction() {
|
|
20
|
-
if (!AuthCheckPassword.instance) {
|
|
21
|
-
AuthCheckPassword.instance = new AuthCheckPassword();
|
|
22
|
-
}
|
|
23
|
-
return AuthCheckPassword.instance;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=authCheckPassword.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authCheckPassword.js","sourceRoot":"","sources":["../../../../src/services/DOFunctionService/functions/authCheckPassword.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAgB1C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAG9C;IACS,MAAM,CAAC,QAAQ,CAAgC;IAEvD;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG;YACN,kHAAkH,CAAC;IACvH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC;YAChC,iBAAiB,CAAC,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACvD,CAAC;QACD,OAAO,iBAAiB,CAAC,QAAQ,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { DOFunctionInput, DOFunctionOutput } from '../DOFunction.js';
|
|
2
|
-
import DOFunction from '../DOFunction.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Input interface for {@link AuthCheckPassword}.
|
|
6
|
-
*/
|
|
7
|
-
export interface AuthCheckPasswordInput extends DOFunctionInput {
|
|
8
|
-
password: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Output interface for {@link AuthCheckPassword}.
|
|
13
|
-
*/
|
|
14
|
-
export interface AuthCheckPasswordOutput extends DOFunctionOutput {
|
|
15
|
-
passwordIsCorrect: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Class representing the AuthCheckPassword function.
|
|
20
|
-
*
|
|
21
|
-
* This class is a singleton and provides a method to get the instance of the function.
|
|
22
|
-
*/
|
|
23
|
-
export default class AuthCheckPassword extends DOFunction<
|
|
24
|
-
AuthCheckPasswordInput,
|
|
25
|
-
AuthCheckPasswordOutput
|
|
26
|
-
> {
|
|
27
|
-
private static instance: AuthCheckPassword | undefined;
|
|
28
|
-
|
|
29
|
-
private constructor() {
|
|
30
|
-
super();
|
|
31
|
-
this.url =
|
|
32
|
-
'https://faas-sfo3-7872a1dd.doserverless.co/api/v1/web/fn-66dd3ef6-c21d-46dc-b7ae-caf2ac8041ec/auth/checkPassword';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Gets the singleton instance of {@link AuthCheckPassword}.
|
|
37
|
-
*
|
|
38
|
-
* @returns The instance of the AuthCheckPassword function.
|
|
39
|
-
*/
|
|
40
|
-
static getFunction(): AuthCheckPassword {
|
|
41
|
-
if (!AuthCheckPassword.instance) {
|
|
42
|
-
AuthCheckPassword.instance = new AuthCheckPassword();
|
|
43
|
-
}
|
|
44
|
-
return AuthCheckPassword.instance;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { ApiKey, User } from '@aneuhold/core-ts-db-lib';
|
|
2
|
-
import type { DashboardConfig } from '../../../types/DashboardConfig.js';
|
|
3
|
-
import type { DOFunctionInput, DOFunctionOutput } from '../DOFunction.js';
|
|
4
|
-
import DOFunction from '../DOFunction.js';
|
|
5
|
-
/**
|
|
6
|
-
* Interface representing the input to the {@link AuthValidateUser} function.
|
|
7
|
-
*/
|
|
8
|
-
export interface AuthValidateUserInput extends DOFunctionInput {
|
|
9
|
-
/**
|
|
10
|
-
* The username of the user to be validated.
|
|
11
|
-
*/
|
|
12
|
-
userName: string;
|
|
13
|
-
/**
|
|
14
|
-
* The password of the user to be validated.
|
|
15
|
-
*/
|
|
16
|
-
password: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Interface representing the output of the {@link AuthValidateUser} function.
|
|
20
|
-
*/
|
|
21
|
-
export interface AuthValidateUserOutput extends DOFunctionOutput {
|
|
22
|
-
/**
|
|
23
|
-
* Information about the authenticated user.
|
|
24
|
-
*/
|
|
25
|
-
userInfo?: {
|
|
26
|
-
user: User;
|
|
27
|
-
apiKey: ApiKey;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Basic configuration for the projects that the user has access to.
|
|
31
|
-
*/
|
|
32
|
-
config?: {
|
|
33
|
-
dashboard?: DashboardConfig;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Class representing the {@link AuthValidateUser} function.
|
|
38
|
-
* This class is a singleton and extends {@link DOFunction}.
|
|
39
|
-
* It is used to validate user authentication.
|
|
40
|
-
*/
|
|
41
|
-
export default class AuthValidateUser extends DOFunction<AuthValidateUserInput, AuthValidateUserOutput> {
|
|
42
|
-
private static instance;
|
|
43
|
-
/**
|
|
44
|
-
* Private constructor to prevent direct instantiation.
|
|
45
|
-
* Initializes the URL for the validate user function.
|
|
46
|
-
*/
|
|
47
|
-
private constructor();
|
|
48
|
-
/**
|
|
49
|
-
* Retrieves the singleton instance of {@link AuthValidateUser}.
|
|
50
|
-
* If the instance does not exist, it creates a new one.
|
|
51
|
-
*
|
|
52
|
-
* @returns The singleton instance of {@link AuthValidateUser}.
|
|
53
|
-
*/
|
|
54
|
-
static getFunction(): AuthValidateUser;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=authValidateUser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authValidateUser.d.ts","sourceRoot":"","sources":["../../../../src/services/DOFunctionService/functions/authValidateUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,IAAI,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF;;OAEG;IACH,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,eAAe,CAAC;KAC7B,CAAC;CACH;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU,CACtD,qBAAqB,EACrB,sBAAsB,CACvB;IACC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA+B;IAEtD;;;OAGG;IACH,OAAO;IAMP;;;;;OAKG;IACH,MAAM,CAAC,WAAW,IAAI,gBAAgB;CAMvC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ApiKey, User } from '@aneuhold/core-ts-db-lib';
|
|
2
|
-
import DOFunction from '../DOFunction.js';
|
|
3
|
-
/**
|
|
4
|
-
* Class representing the {@link AuthValidateUser} function.
|
|
5
|
-
* This class is a singleton and extends {@link DOFunction}.
|
|
6
|
-
* It is used to validate user authentication.
|
|
7
|
-
*/
|
|
8
|
-
export default class AuthValidateUser extends DOFunction {
|
|
9
|
-
static instance;
|
|
10
|
-
/**
|
|
11
|
-
* Private constructor to prevent direct instantiation.
|
|
12
|
-
* Initializes the URL for the validate user function.
|
|
13
|
-
*/
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
this.url =
|
|
17
|
-
'https://faas-sfo3-7872a1dd.doserverless.co/api/v1/web/fn-66dd3ef6-c21d-46dc-b7ae-caf2ac8041ec/auth/validateUser';
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Retrieves the singleton instance of {@link AuthValidateUser}.
|
|
21
|
-
* If the instance does not exist, it creates a new one.
|
|
22
|
-
*
|
|
23
|
-
* @returns The singleton instance of {@link AuthValidateUser}.
|
|
24
|
-
*/
|
|
25
|
-
static getFunction() {
|
|
26
|
-
if (!AuthValidateUser.instance) {
|
|
27
|
-
AuthValidateUser.instance = new AuthValidateUser();
|
|
28
|
-
}
|
|
29
|
-
return AuthValidateUser.instance;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=authValidateUser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authValidateUser.js","sourceRoot":"","sources":["../../../../src/services/DOFunctionService/functions/authValidateUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAGxD,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAmC1C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAG7C;IACS,MAAM,CAAC,QAAQ,CAA+B;IAEtD;;;OAGG;IACH;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG;YACN,iHAAiH,CAAC;IACtH,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;YAC/B,gBAAgB,CAAC,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACrD,CAAC;QACD,OAAO,gBAAgB,CAAC,QAAQ,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { ApiKey, User } from '@aneuhold/core-ts-db-lib';
|
|
2
|
-
import type { DashboardConfig } from '../../../types/DashboardConfig.js';
|
|
3
|
-
import type { DOFunctionInput, DOFunctionOutput } from '../DOFunction.js';
|
|
4
|
-
import DOFunction from '../DOFunction.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Interface representing the input to the {@link AuthValidateUser} function.
|
|
8
|
-
*/
|
|
9
|
-
export interface AuthValidateUserInput extends DOFunctionInput {
|
|
10
|
-
/**
|
|
11
|
-
* The username of the user to be validated.
|
|
12
|
-
*/
|
|
13
|
-
userName: string;
|
|
14
|
-
/**
|
|
15
|
-
* The password of the user to be validated.
|
|
16
|
-
*/
|
|
17
|
-
password: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Interface representing the output of the {@link AuthValidateUser} function.
|
|
22
|
-
*/
|
|
23
|
-
export interface AuthValidateUserOutput extends DOFunctionOutput {
|
|
24
|
-
/**
|
|
25
|
-
* Information about the authenticated user.
|
|
26
|
-
*/
|
|
27
|
-
userInfo?: {
|
|
28
|
-
user: User;
|
|
29
|
-
apiKey: ApiKey;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Basic configuration for the projects that the user has access to.
|
|
33
|
-
*/
|
|
34
|
-
config?: {
|
|
35
|
-
dashboard?: DashboardConfig;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Class representing the {@link AuthValidateUser} function.
|
|
41
|
-
* This class is a singleton and extends {@link DOFunction}.
|
|
42
|
-
* It is used to validate user authentication.
|
|
43
|
-
*/
|
|
44
|
-
export default class AuthValidateUser extends DOFunction<
|
|
45
|
-
AuthValidateUserInput,
|
|
46
|
-
AuthValidateUserOutput
|
|
47
|
-
> {
|
|
48
|
-
private static instance: AuthValidateUser | undefined;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Private constructor to prevent direct instantiation.
|
|
52
|
-
* Initializes the URL for the validate user function.
|
|
53
|
-
*/
|
|
54
|
-
private constructor() {
|
|
55
|
-
super();
|
|
56
|
-
this.url =
|
|
57
|
-
'https://faas-sfo3-7872a1dd.doserverless.co/api/v1/web/fn-66dd3ef6-c21d-46dc-b7ae-caf2ac8041ec/auth/validateUser';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Retrieves the singleton instance of {@link AuthValidateUser}.
|
|
62
|
-
* If the instance does not exist, it creates a new one.
|
|
63
|
-
*
|
|
64
|
-
* @returns The singleton instance of {@link AuthValidateUser}.
|
|
65
|
-
*/
|
|
66
|
-
static getFunction(): AuthValidateUser {
|
|
67
|
-
if (!AuthValidateUser.instance) {
|
|
68
|
-
AuthValidateUser.instance = new AuthValidateUser();
|
|
69
|
-
}
|
|
70
|
-
return AuthValidateUser.instance;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projectDashboard.d.ts","sourceRoot":"","sources":["../../../../src/services/DOFunctionService/functions/projectDashboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE;QACJ;;WAEG;QACH,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB;;;WAGG;QACH,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB;;WAEG;QACH,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB;;WAEG;QACH,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB;;WAEG;QACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B;;WAEG;QACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC,CAAC;IACF,MAAM,CAAC,EAAE;QACP;;WAEG;QACH,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;QACxB;;WAEG;QACH,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAC;QAC3C;;WAEG;QACH,sBAAsB,CAAC,EAAE,qBAAqB,EAAE,CAAC;KAClD,CAAC;IACF,MAAM,CAAC,EAAE;QACP;;WAEG;QACH,UAAU,CAAC,EAAE,mBAAmB,CAAC;QACjC;;WAEG;QACH,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;QACxB;;WAEG;QACH,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAC;QAC3C;;WAEG;QACH,sBAAsB,CAAC,EAAE,qBAAqB,EAAE,CAAC;KAClD,CAAC;IACF,MAAM,CAAC,EAAE;QACP;;WAEG;QACH,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;KACzB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,uBAAuB,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,EAAE,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC3C,sBAAsB,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAClD;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU,CACtD,qBAAqB,EACrB,sBAAsB,CACvB;IACC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA+B;IAEtD,OAAO;IAIP,MAAM,CAAC,WAAW,IAAI,gBAAgB;CAMvC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { DashboardTask, DashboardUserConfig, NonogramKatanaItem, NonogramKatanaUpgrade } from '@aneuhold/core-ts-db-lib';
|
|
2
|
-
import DOFunction from '../DOFunction.js';
|
|
3
|
-
/**
|
|
4
|
-
* The Digital Ocean function which handles all data requests for the
|
|
5
|
-
* dashboard project.
|
|
6
|
-
*/
|
|
7
|
-
export default class ProjectDashboard extends DOFunction {
|
|
8
|
-
static instance;
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
}
|
|
12
|
-
static getFunction() {
|
|
13
|
-
if (!ProjectDashboard.instance) {
|
|
14
|
-
ProjectDashboard.instance = new ProjectDashboard();
|
|
15
|
-
}
|
|
16
|
-
return ProjectDashboard.instance;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=projectDashboard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projectDashboard.js","sourceRoot":"","sources":["../../../../src/services/DOFunctionService/functions/projectDashboard.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,UAAU,MAAM,kBAAkB,CAAC;AA8F1C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAG7C;IACS,MAAM,CAAC,QAAQ,CAA+B;IAEtD;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;YAC/B,gBAAgB,CAAC,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACrD,CAAC;QACD,OAAO,gBAAgB,CAAC,QAAQ,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { DOFunctionInput, DOFunctionOutput } from '../services/DOFunctionService/DOFunction.js';
|
|
2
|
-
import DOFunction from '../services/DOFunctionService/DOFunction.js';
|
|
3
|
-
export declare const EXAMPLE_FUNCTION_URL = "https://example.com/function";
|
|
4
|
-
export declare class ExampleFunction extends DOFunction<ExampleInput, ExampleOutput> {
|
|
5
|
-
private static instance;
|
|
6
|
-
private constructor();
|
|
7
|
-
static getFunction(): ExampleFunction;
|
|
8
|
-
}
|
|
9
|
-
export interface ExampleInput extends DOFunctionInput {
|
|
10
|
-
name: string;
|
|
11
|
-
}
|
|
12
|
-
export interface ExampleOutput extends DOFunctionOutput {
|
|
13
|
-
greeting: string;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=ExampleFunction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleFunction.d.ts","sourceRoot":"","sources":["../../src/tests/ExampleFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EACjB,MAAM,6CAA6C,CAAC;AACrD,OAAO,UAAU,MAAM,6CAA6C,CAAC;AAErE,eAAO,MAAM,oBAAoB,iCAAiC,CAAC;AAEnE,qBAAa,eAAgB,SAAQ,UAAU,CAAC,YAAY,EAAE,aAAa,CAAC;IAC1E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA8B;IAErD,OAAO;IAKP,MAAM,CAAC,WAAW,IAAI,eAAe;CAMtC;AAED,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import DOFunction from '../services/DOFunctionService/DOFunction.js';
|
|
2
|
-
export const EXAMPLE_FUNCTION_URL = 'https://example.com/function';
|
|
3
|
-
export class ExampleFunction extends DOFunction {
|
|
4
|
-
static instance;
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
this.url = EXAMPLE_FUNCTION_URL;
|
|
8
|
-
}
|
|
9
|
-
static getFunction() {
|
|
10
|
-
if (!ExampleFunction.instance) {
|
|
11
|
-
ExampleFunction.instance = new ExampleFunction();
|
|
12
|
-
}
|
|
13
|
-
return ExampleFunction.instance;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=ExampleFunction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleFunction.js","sourceRoot":"","sources":["../../src/tests/ExampleFunction.ts"],"names":[],"mappings":"AAIA,OAAO,UAAU,MAAM,6CAA6C,CAAC;AAErE,MAAM,CAAC,MAAM,oBAAoB,GAAG,8BAA8B,CAAC;AAEnE,MAAM,OAAO,eAAgB,SAAQ,UAAuC;IAClE,MAAM,CAAC,QAAQ,CAA8B;IAErD;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,oBAAoB,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;YAC9B,eAAe,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;QACnD,CAAC;QACD,OAAO,eAAe,CAAC,QAAQ,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DOFunctionInput,
|
|
3
|
-
DOFunctionOutput
|
|
4
|
-
} from '../services/DOFunctionService/DOFunction.js';
|
|
5
|
-
import DOFunction from '../services/DOFunctionService/DOFunction.js';
|
|
6
|
-
|
|
7
|
-
export const EXAMPLE_FUNCTION_URL = 'https://example.com/function';
|
|
8
|
-
|
|
9
|
-
export class ExampleFunction extends DOFunction<ExampleInput, ExampleOutput> {
|
|
10
|
-
private static instance: ExampleFunction | undefined;
|
|
11
|
-
|
|
12
|
-
private constructor() {
|
|
13
|
-
super();
|
|
14
|
-
this.url = EXAMPLE_FUNCTION_URL;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static getFunction(): ExampleFunction {
|
|
18
|
-
if (!ExampleFunction.instance) {
|
|
19
|
-
ExampleFunction.instance = new ExampleFunction();
|
|
20
|
-
}
|
|
21
|
-
return ExampleFunction.instance;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface ExampleInput extends DOFunctionInput {
|
|
26
|
-
name: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface ExampleOutput extends DOFunctionOutput {
|
|
30
|
-
greeting: string;
|
|
31
|
-
}
|
package/lib/tests/TestUtil.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class TestUtil {
|
|
2
|
-
/**
|
|
3
|
-
* Mocks fetch globally to return the expected output. This should match how
|
|
4
|
-
* the output is expected to be returned from the Digital Ocean function.
|
|
5
|
-
*
|
|
6
|
-
* @param expectedOutput The expected output from the fetch call.
|
|
7
|
-
*/
|
|
8
|
-
static mockFetch(expectedOutput: object): void;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=TestUtil.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TestUtil.d.ts","sourceRoot":"","sources":["../../src/tests/TestUtil.ts"],"names":[],"mappings":"AAGA,qBAAa,QAAQ;IACnB;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM;CAMxC"}
|
package/lib/tests/TestUtil.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { BSON } from 'bson';
|
|
2
|
-
import { vi } from 'vitest';
|
|
3
|
-
export class TestUtil {
|
|
4
|
-
/**
|
|
5
|
-
* Mocks fetch globally to return the expected output. This should match how
|
|
6
|
-
* the output is expected to be returned from the Digital Ocean function.
|
|
7
|
-
*
|
|
8
|
-
* @param expectedOutput The expected output from the fetch call.
|
|
9
|
-
*/
|
|
10
|
-
static mockFetch(expectedOutput) {
|
|
11
|
-
global.fetch = vi.fn().mockResolvedValue({
|
|
12
|
-
arrayBuffer: vi.fn().mockResolvedValue(Buffer.from(BSON.serialize(expectedOutput))),
|
|
13
|
-
headers: new Map([['Content-Type', 'application/octet-stream']])
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=TestUtil.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TestUtil.js","sourceRoot":"","sources":["../../src/tests/TestUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,MAAM,OAAO,QAAQ;IACnB;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,cAAsB;QACrC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;YACvC,WAAW,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;YACnF,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,cAAc,EAAE,0BAA0B,CAAC,CAAC,CAAC;SACjE,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/lib/tests/TestUtil.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { BSON } from 'bson';
|
|
2
|
-
import { vi } from 'vitest';
|
|
3
|
-
|
|
4
|
-
export class TestUtil {
|
|
5
|
-
/**
|
|
6
|
-
* Mocks fetch globally to return the expected output. This should match how
|
|
7
|
-
* the output is expected to be returned from the Digital Ocean function.
|
|
8
|
-
*
|
|
9
|
-
* @param expectedOutput The expected output from the fetch call.
|
|
10
|
-
*/
|
|
11
|
-
static mockFetch(expectedOutput: object) {
|
|
12
|
-
global.fetch = vi.fn().mockResolvedValue({
|
|
13
|
-
arrayBuffer: vi.fn().mockResolvedValue(Buffer.from(BSON.serialize(expectedOutput))),
|
|
14
|
-
headers: new Map([['Content-Type', 'application/octet-stream']])
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|