quidproquo-webserver 0.1.0 → 0.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/commonjs/actions/index.d.ts +0 -1
- package/lib/commonjs/actions/index.js +0 -1
- package/lib/commonjs/config/settings/defineAdminSettings/defineAdminSettings.js +1 -1
- package/lib/commonjs/services/webSocketQueue/logic/webSocket/messageProcessors/askProcessOnAuthenticate.js +27 -20
- package/lib/commonjs/utils/httpEventUtils.d.ts +1 -0
- package/lib/commonjs/utils/httpEventUtils.js +9 -1
- package/lib/commonjs/utils/networkRequestUtils.js +1 -1
- package/lib/esm/actions/index.d.ts +0 -1
- package/lib/esm/actions/index.js +0 -1
- package/lib/esm/config/settings/defineAdminSettings/defineAdminSettings.js +1 -1
- package/lib/esm/services/webSocketQueue/logic/webSocket/messageProcessors/askProcessOnAuthenticate.js +31 -24
- package/lib/esm/utils/httpEventUtils.d.ts +1 -0
- package/lib/esm/utils/httpEventUtils.js +7 -0
- package/lib/esm/utils/networkRequestUtils.js +1 -1
- package/package.json +3 -3
- package/lib/commonjs/actions/extract/ExtractActionType.d.ts +0 -3
- package/lib/commonjs/actions/extract/ExtractActionType.js +0 -7
- package/lib/commonjs/actions/extract/ExtractExpenseActionRequester.d.ts +0 -10
- package/lib/commonjs/actions/extract/ExtractExpenseActionRequester.js +0 -23
- package/lib/commonjs/actions/extract/ExtractExpenseActionTypes.d.ts +0 -40
- package/lib/commonjs/actions/extract/ExtractExpenseActionTypes.js +0 -2
- package/lib/commonjs/actions/extract/index.d.ts +0 -3
- package/lib/commonjs/actions/extract/index.js +0 -19
- package/lib/esm/actions/extract/ExtractActionType.d.ts +0 -3
- package/lib/esm/actions/extract/ExtractActionType.js +0 -4
- package/lib/esm/actions/extract/ExtractExpenseActionRequester.d.ts +0 -10
- package/lib/esm/actions/extract/ExtractExpenseActionRequester.js +0 -19
- package/lib/esm/actions/extract/ExtractExpenseActionTypes.d.ts +0 -40
- package/lib/esm/actions/extract/ExtractExpenseActionTypes.js +0 -1
- package/lib/esm/actions/extract/index.d.ts +0 -3
- package/lib/esm/actions/extract/index.js +0 -3
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./admin"), exports);
|
|
18
18
|
__exportStar(require("./apiKeyValidation"), exports);
|
|
19
19
|
__exportStar(require("./dns"), exports);
|
|
20
|
-
__exportStar(require("./extract"), exports);
|
|
21
20
|
__exportStar(require("./genericDataResource"), exports);
|
|
22
21
|
__exportStar(require("./openApiSpec"), exports);
|
|
23
22
|
__exportStar(require("./routeAuthValidation"), exports);
|
|
@@ -33,7 +33,7 @@ const defineAdminSettings = (logServiceName, rootDomain, advancedSettings) => {
|
|
|
33
33
|
(0, quidproquo_core_1.defineEventBus)('qpq-admin-wsq', {
|
|
34
34
|
owner: { module: logServiceName },
|
|
35
35
|
}),
|
|
36
|
-
(0, quidproquo_core_1.defineQueue)('
|
|
36
|
+
(0, quidproquo_core_1.defineQueue)('qpqadmin-wscfg', {
|
|
37
37
|
[WebSocketQueueQpqAdminClientMessageEventType_1.WebsocketAdminClientMessageEventType.ConfigSyncRequest]: {
|
|
38
38
|
basePath: __dirname,
|
|
39
39
|
functionName: 'onConfigSyncRequest',
|
|
@@ -14,28 +14,35 @@ function isWebSocketAuthenticateMessage(event) {
|
|
|
14
14
|
}
|
|
15
15
|
function* askProcessOnAuthenticate(connectionId, accessToken) {
|
|
16
16
|
const connection = yield* data_1.webSocketConnectionData.askGetById(connectionId);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
// No connection record (e.g. the connect event hasn't been processed yet) —
|
|
18
|
+
// tell the client rather than dropping the request silently, so it can
|
|
19
|
+
// distinguish "not authenticated" from "no reply".
|
|
20
|
+
if (!connection) {
|
|
21
|
+
yield* (0, askSendMessage_1.askSendMessage)(connectionId, {
|
|
22
|
+
type: types_1.WebSocketQueueServerMessageEventType.Unauthenticated,
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const apiName = yield* (0, context_1.askWebsocketReadApiNameOrThrow)();
|
|
27
|
+
const userDirectoryName = yield* (0, quidproquo_core_1.askConfigGetGlobal)((0, config_1.getWebSocketQueueGlobalConfigKeyForUserDirectoryName)(apiName));
|
|
28
|
+
if (userDirectoryName) {
|
|
29
|
+
const result = yield* (0, quidproquo_core_1.askCatch)((0, quidproquo_core_1.askUserDirectorySetAccessToken)(userDirectoryName, accessToken));
|
|
30
|
+
if (!result.success) {
|
|
30
31
|
yield* (0, askSendMessage_1.askSendMessage)(connectionId, {
|
|
31
|
-
type: types_1.WebSocketQueueServerMessageEventType.
|
|
32
|
+
type: types_1.WebSocketQueueServerMessageEventType.Unauthenticated,
|
|
32
33
|
});
|
|
33
|
-
|
|
34
|
-
const webSocketQueueClientEventMessageAuthenticate = {
|
|
35
|
-
type: types_1.WebSocketQueueClientMessageEventType.Authenticate,
|
|
36
|
-
payload: {},
|
|
37
|
-
};
|
|
38
|
-
yield* (0, askBroadcastUnknownMessage_1.askBroadcastUnknownMessage)(webSocketQueueClientEventMessageAuthenticate);
|
|
34
|
+
return;
|
|
39
35
|
}
|
|
36
|
+
const decodedAccessToken = result.result;
|
|
37
|
+
yield* data_1.webSocketConnectionData.askUpsert(Object.assign(Object.assign({}, connection), { userId: decodedAccessToken.userId, accessToken }));
|
|
38
|
+
yield* (0, askSendMessage_1.askSendMessage)(connectionId, {
|
|
39
|
+
type: types_1.WebSocketQueueServerMessageEventType.Authenticated,
|
|
40
|
+
});
|
|
41
|
+
// Send a websocket message to the event buss WITHOUT an access token
|
|
42
|
+
const webSocketQueueClientEventMessageAuthenticate = {
|
|
43
|
+
type: types_1.WebSocketQueueClientMessageEventType.Authenticate,
|
|
44
|
+
payload: {},
|
|
45
|
+
};
|
|
46
|
+
yield* (0, askBroadcastUnknownMessage_1.askBroadcastUnknownMessage)(webSocketQueueClientEventMessageAuthenticate);
|
|
40
47
|
}
|
|
41
48
|
}
|
|
@@ -4,6 +4,7 @@ import { HTTPEvent, HTTPEventResponse } from '../types/HTTPEvent';
|
|
|
4
4
|
export declare const rawFromJsonEventRequest: (httpJsonEvent: HTTPEvent) => string | undefined;
|
|
5
5
|
export declare const fromJsonEventRequest: <T>(httpJsonEvent: HTTPEvent) => T;
|
|
6
6
|
export declare function askFromJsonEventRequest<T>(httpJsonEvent: HTTPEvent): AskResponse<T>;
|
|
7
|
+
export declare const readUriQueryParamFromEvent: (event: HTTPEvent, paramName: string) => string | undefined;
|
|
7
8
|
export declare const toJsonEventResponse: (item: any, status?: number) => HTTPEventResponse;
|
|
8
9
|
export declare const toHtmlResponse: (html: string, status?: number) => HTTPEventResponse;
|
|
9
10
|
export declare const toTextResponse: (text: string, status?: number) => HTTPEventResponse;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toCdnResponse = exports.toMovedTemporarilyRedirectResponse = exports.toMovedPermanentlyRedirectResponse = exports.toTextResponse = exports.toHtmlResponse = exports.toJsonEventResponse = exports.fromJsonEventRequest = exports.rawFromJsonEventRequest = void 0;
|
|
3
|
+
exports.toCdnResponse = exports.toMovedTemporarilyRedirectResponse = exports.toMovedPermanentlyRedirectResponse = exports.toTextResponse = exports.toHtmlResponse = exports.toJsonEventResponse = exports.readUriQueryParamFromEvent = exports.fromJsonEventRequest = exports.rawFromJsonEventRequest = void 0;
|
|
4
4
|
exports.askFromJsonEventRequest = askFromJsonEventRequest;
|
|
5
5
|
const quidproquo_core_1 = require("quidproquo-core");
|
|
6
6
|
const rawFromJsonEventRequest = (httpJsonEvent) => {
|
|
@@ -39,6 +39,14 @@ function* askFromJsonEventRequest(httpJsonEvent) {
|
|
|
39
39
|
return yield* (0, quidproquo_core_1.askThrowError)(quidproquo_core_1.ErrorTypeEnum.BadRequest, 'Unable to parse incoming json from HTTPEvent.');
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
const readUriQueryParamFromEvent = (event, paramName) => {
|
|
43
|
+
const rawValue = event.query[paramName];
|
|
44
|
+
if (!rawValue) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return Array.isArray(rawValue) ? rawValue[0] : rawValue;
|
|
48
|
+
};
|
|
49
|
+
exports.readUriQueryParamFromEvent = readUriQueryParamFromEvent;
|
|
42
50
|
const toJsonEventResponse = (item, status = 200) => {
|
|
43
51
|
return {
|
|
44
52
|
status,
|
|
@@ -22,7 +22,7 @@ const isAbsoluteUrl = (url) => /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
|
22
22
|
// Join basePath + url like axios' combineURLs (path concatenation), NOT URL
|
|
23
23
|
// resolution. `new URL('/v1/x', 'http://host/api/svc')` drops the base path
|
|
24
24
|
// because a leading-slash url is root-absolute; we want '.../api/svc/v1/x'.
|
|
25
|
-
const combineUrls = (basePath, url) => url ? `${basePath.replace(/\/+$/, '')}/${url.replace(/^\/+/, '')}` : basePath;
|
|
25
|
+
const combineUrls = (basePath, url) => (url ? `${basePath.replace(/\/+$/, '')}/${url.replace(/^\/+/, '')}` : basePath);
|
|
26
26
|
const buildRequestUrl = (payload) => {
|
|
27
27
|
const fullUrl = payload.basePath && !isAbsoluteUrl(payload.url) ? combineUrls(payload.basePath, payload.url) : payload.url;
|
|
28
28
|
const url = new URL(fullUrl);
|
package/lib/esm/actions/index.js
CHANGED
|
@@ -28,7 +28,7 @@ export const defineAdminSettings = (logServiceName, rootDomain, advancedSettings
|
|
|
28
28
|
defineEventBus('qpq-admin-wsq', {
|
|
29
29
|
owner: { module: logServiceName },
|
|
30
30
|
}),
|
|
31
|
-
defineQueue('
|
|
31
|
+
defineQueue('qpqadmin-wscfg', {
|
|
32
32
|
[WebsocketAdminClientMessageEventType.ConfigSyncRequest]: {
|
|
33
33
|
basePath: __dirname,
|
|
34
34
|
functionName: 'onConfigSyncRequest',
|
|
@@ -10,32 +10,39 @@ export function isWebSocketAuthenticateMessage(event) {
|
|
|
10
10
|
}
|
|
11
11
|
export function* askProcessOnAuthenticate(connectionId, accessToken) {
|
|
12
12
|
const connection = yield* webSocketConnectionData.askGetById(connectionId);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
userId: decodedAccessToken.userId,
|
|
28
|
-
accessToken,
|
|
29
|
-
});
|
|
13
|
+
// No connection record (e.g. the connect event hasn't been processed yet) —
|
|
14
|
+
// tell the client rather than dropping the request silently, so it can
|
|
15
|
+
// distinguish "not authenticated" from "no reply".
|
|
16
|
+
if (!connection) {
|
|
17
|
+
yield* askSendMessage(connectionId, {
|
|
18
|
+
type: WebSocketQueueServerMessageEventType.Unauthenticated,
|
|
19
|
+
});
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const apiName = yield* askWebsocketReadApiNameOrThrow();
|
|
23
|
+
const userDirectoryName = yield* askConfigGetGlobal(getWebSocketQueueGlobalConfigKeyForUserDirectoryName(apiName));
|
|
24
|
+
if (userDirectoryName) {
|
|
25
|
+
const result = yield* askCatch(askUserDirectorySetAccessToken(userDirectoryName, accessToken));
|
|
26
|
+
if (!result.success) {
|
|
30
27
|
yield* askSendMessage(connectionId, {
|
|
31
|
-
type: WebSocketQueueServerMessageEventType.
|
|
28
|
+
type: WebSocketQueueServerMessageEventType.Unauthenticated,
|
|
32
29
|
});
|
|
33
|
-
|
|
34
|
-
const webSocketQueueClientEventMessageAuthenticate = {
|
|
35
|
-
type: WebSocketQueueClientMessageEventType.Authenticate,
|
|
36
|
-
payload: {},
|
|
37
|
-
};
|
|
38
|
-
yield* askBroadcastUnknownMessage(webSocketQueueClientEventMessageAuthenticate);
|
|
30
|
+
return;
|
|
39
31
|
}
|
|
32
|
+
const decodedAccessToken = result.result;
|
|
33
|
+
yield* webSocketConnectionData.askUpsert({
|
|
34
|
+
...connection,
|
|
35
|
+
userId: decodedAccessToken.userId,
|
|
36
|
+
accessToken,
|
|
37
|
+
});
|
|
38
|
+
yield* askSendMessage(connectionId, {
|
|
39
|
+
type: WebSocketQueueServerMessageEventType.Authenticated,
|
|
40
|
+
});
|
|
41
|
+
// Send a websocket message to the event buss WITHOUT an access token
|
|
42
|
+
const webSocketQueueClientEventMessageAuthenticate = {
|
|
43
|
+
type: WebSocketQueueClientMessageEventType.Authenticate,
|
|
44
|
+
payload: {},
|
|
45
|
+
};
|
|
46
|
+
yield* askBroadcastUnknownMessage(webSocketQueueClientEventMessageAuthenticate);
|
|
40
47
|
}
|
|
41
48
|
}
|
|
@@ -4,6 +4,7 @@ import { HTTPEvent, HTTPEventResponse } from '../types/HTTPEvent';
|
|
|
4
4
|
export declare const rawFromJsonEventRequest: (httpJsonEvent: HTTPEvent) => string | undefined;
|
|
5
5
|
export declare const fromJsonEventRequest: <T>(httpJsonEvent: HTTPEvent) => T;
|
|
6
6
|
export declare function askFromJsonEventRequest<T>(httpJsonEvent: HTTPEvent): AskResponse<T>;
|
|
7
|
+
export declare const readUriQueryParamFromEvent: (event: HTTPEvent, paramName: string) => string | undefined;
|
|
7
8
|
export declare const toJsonEventResponse: (item: any, status?: number) => HTTPEventResponse;
|
|
8
9
|
export declare const toHtmlResponse: (html: string, status?: number) => HTTPEventResponse;
|
|
9
10
|
export declare const toTextResponse: (text: string, status?: number) => HTTPEventResponse;
|
|
@@ -33,6 +33,13 @@ export function* askFromJsonEventRequest(httpJsonEvent) {
|
|
|
33
33
|
return yield* askThrowError(ErrorTypeEnum.BadRequest, 'Unable to parse incoming json from HTTPEvent.');
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
export const readUriQueryParamFromEvent = (event, paramName) => {
|
|
37
|
+
const rawValue = event.query[paramName];
|
|
38
|
+
if (!rawValue) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return Array.isArray(rawValue) ? rawValue[0] : rawValue;
|
|
42
|
+
};
|
|
36
43
|
export const toJsonEventResponse = (item, status = 200) => {
|
|
37
44
|
return {
|
|
38
45
|
status,
|
|
@@ -10,7 +10,7 @@ const isAbsoluteUrl = (url) => /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
|
10
10
|
// Join basePath + url like axios' combineURLs (path concatenation), NOT URL
|
|
11
11
|
// resolution. `new URL('/v1/x', 'http://host/api/svc')` drops the base path
|
|
12
12
|
// because a leading-slash url is root-absolute; we want '.../api/svc/v1/x'.
|
|
13
|
-
const combineUrls = (basePath, url) => url ? `${basePath.replace(/\/+$/, '')}/${url.replace(/^\/+/, '')}` : basePath;
|
|
13
|
+
const combineUrls = (basePath, url) => (url ? `${basePath.replace(/\/+$/, '')}/${url.replace(/^\/+/, '')}` : basePath);
|
|
14
14
|
const buildRequestUrl = (payload) => {
|
|
15
15
|
const fullUrl = payload.basePath && !isAbsoluteUrl(payload.url) ? combineUrls(payload.basePath, payload.url) : payload.url;
|
|
16
16
|
const url = new URL(fullUrl);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-webserver",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"homepage": "https://github.com/joe-coady/quidproquo#readme",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@anthropic-ai/sdk": "^0.19.1",
|
|
36
|
-
"quidproquo-core": "0.1.
|
|
36
|
+
"quidproquo-core": "0.1.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"quidproquo-tsconfig": "0.1.
|
|
39
|
+
"quidproquo-tsconfig": "0.1.2",
|
|
40
40
|
"typescript": "^5.8.2"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtractActionType = void 0;
|
|
4
|
-
var ExtractActionType;
|
|
5
|
-
(function (ExtractActionType) {
|
|
6
|
-
ExtractActionType["Expense"] = "@quidproquo-webserver/Extract/Expense";
|
|
7
|
-
})(ExtractActionType || (exports.ExtractActionType = ExtractActionType = {}));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ExtractExpenseActionRequester } from './ExtractExpenseActionTypes';
|
|
2
|
-
export declare const ExtractExpenseErrorTypeEnum: {
|
|
3
|
-
FileNotFound: string;
|
|
4
|
-
UnsupportedFormat: string;
|
|
5
|
-
InvalidParameter: string;
|
|
6
|
-
RateLimited: string;
|
|
7
|
-
InvalidStorageClass: string;
|
|
8
|
-
AccessDenied: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function askExtractExpense(storageDriveName: string, filePath: string): ExtractExpenseActionRequester;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtractExpenseErrorTypeEnum = void 0;
|
|
4
|
-
exports.askExtractExpense = askExtractExpense;
|
|
5
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
6
|
-
const ExtractActionType_1 = require("./ExtractActionType");
|
|
7
|
-
exports.ExtractExpenseErrorTypeEnum = (0, quidproquo_core_1.createErrorEnumForAction)(ExtractActionType_1.ExtractActionType.Expense, [
|
|
8
|
-
'FileNotFound',
|
|
9
|
-
'UnsupportedFormat',
|
|
10
|
-
'InvalidParameter',
|
|
11
|
-
'RateLimited',
|
|
12
|
-
'InvalidStorageClass',
|
|
13
|
-
'AccessDenied',
|
|
14
|
-
]);
|
|
15
|
-
function* askExtractExpense(storageDriveName, filePath) {
|
|
16
|
-
return yield {
|
|
17
|
-
type: ExtractActionType_1.ExtractActionType.Expense,
|
|
18
|
-
payload: {
|
|
19
|
-
storageDriveName,
|
|
20
|
-
filePath,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Action, ActionProcessor, ActionRequester } from 'quidproquo-core';
|
|
2
|
-
import { ExtractActionType } from './ExtractActionType';
|
|
3
|
-
type ExtractedExpenseDocument = {
|
|
4
|
-
metadata: {
|
|
5
|
-
merchantName?: string;
|
|
6
|
-
merchantAddress?: string;
|
|
7
|
-
date?: string;
|
|
8
|
-
currency?: string;
|
|
9
|
-
paymentMethod?: string;
|
|
10
|
-
subtotal?: number;
|
|
11
|
-
tax?: number;
|
|
12
|
-
total?: number;
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
};
|
|
15
|
-
lineItems?: Array<{
|
|
16
|
-
description: string;
|
|
17
|
-
quantity?: number;
|
|
18
|
-
unitPrice?: number;
|
|
19
|
-
total?: number;
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
}>;
|
|
22
|
-
rawText?: string;
|
|
23
|
-
source: {
|
|
24
|
-
storageDrive: string;
|
|
25
|
-
filePath: string;
|
|
26
|
-
textractJobId?: string;
|
|
27
|
-
};
|
|
28
|
-
_raw?: any;
|
|
29
|
-
};
|
|
30
|
-
export interface ExtractExpenseActionPayload {
|
|
31
|
-
storageDriveName: string;
|
|
32
|
-
filePath: string;
|
|
33
|
-
}
|
|
34
|
-
export interface ExtractExpenseAction extends Action<ExtractExpenseActionPayload> {
|
|
35
|
-
type: ExtractActionType.Expense;
|
|
36
|
-
payload: ExtractExpenseActionPayload;
|
|
37
|
-
}
|
|
38
|
-
export type ExtractExpenseActionProcessor = ActionProcessor<ExtractExpenseAction, ExtractedExpenseDocument>;
|
|
39
|
-
export type ExtractExpenseActionRequester = ActionRequester<ExtractExpenseAction, ExtractedExpenseDocument>;
|
|
40
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./ExtractActionType"), exports);
|
|
18
|
-
__exportStar(require("./ExtractExpenseActionRequester"), exports);
|
|
19
|
-
__exportStar(require("./ExtractExpenseActionTypes"), exports);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ExtractExpenseActionRequester } from './ExtractExpenseActionTypes';
|
|
2
|
-
export declare const ExtractExpenseErrorTypeEnum: {
|
|
3
|
-
FileNotFound: string;
|
|
4
|
-
UnsupportedFormat: string;
|
|
5
|
-
InvalidParameter: string;
|
|
6
|
-
RateLimited: string;
|
|
7
|
-
InvalidStorageClass: string;
|
|
8
|
-
AccessDenied: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function askExtractExpense(storageDriveName: string, filePath: string): ExtractExpenseActionRequester;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createErrorEnumForAction } from 'quidproquo-core';
|
|
2
|
-
import { ExtractActionType } from './ExtractActionType';
|
|
3
|
-
export const ExtractExpenseErrorTypeEnum = createErrorEnumForAction(ExtractActionType.Expense, [
|
|
4
|
-
'FileNotFound',
|
|
5
|
-
'UnsupportedFormat',
|
|
6
|
-
'InvalidParameter',
|
|
7
|
-
'RateLimited',
|
|
8
|
-
'InvalidStorageClass',
|
|
9
|
-
'AccessDenied',
|
|
10
|
-
]);
|
|
11
|
-
export function* askExtractExpense(storageDriveName, filePath) {
|
|
12
|
-
return yield {
|
|
13
|
-
type: ExtractActionType.Expense,
|
|
14
|
-
payload: {
|
|
15
|
-
storageDriveName,
|
|
16
|
-
filePath,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Action, ActionProcessor, ActionRequester } from 'quidproquo-core';
|
|
2
|
-
import { ExtractActionType } from './ExtractActionType';
|
|
3
|
-
type ExtractedExpenseDocument = {
|
|
4
|
-
metadata: {
|
|
5
|
-
merchantName?: string;
|
|
6
|
-
merchantAddress?: string;
|
|
7
|
-
date?: string;
|
|
8
|
-
currency?: string;
|
|
9
|
-
paymentMethod?: string;
|
|
10
|
-
subtotal?: number;
|
|
11
|
-
tax?: number;
|
|
12
|
-
total?: number;
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
};
|
|
15
|
-
lineItems?: Array<{
|
|
16
|
-
description: string;
|
|
17
|
-
quantity?: number;
|
|
18
|
-
unitPrice?: number;
|
|
19
|
-
total?: number;
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
}>;
|
|
22
|
-
rawText?: string;
|
|
23
|
-
source: {
|
|
24
|
-
storageDrive: string;
|
|
25
|
-
filePath: string;
|
|
26
|
-
textractJobId?: string;
|
|
27
|
-
};
|
|
28
|
-
_raw?: any;
|
|
29
|
-
};
|
|
30
|
-
export interface ExtractExpenseActionPayload {
|
|
31
|
-
storageDriveName: string;
|
|
32
|
-
filePath: string;
|
|
33
|
-
}
|
|
34
|
-
export interface ExtractExpenseAction extends Action<ExtractExpenseActionPayload> {
|
|
35
|
-
type: ExtractActionType.Expense;
|
|
36
|
-
payload: ExtractExpenseActionPayload;
|
|
37
|
-
}
|
|
38
|
-
export type ExtractExpenseActionProcessor = ActionProcessor<ExtractExpenseAction, ExtractedExpenseDocument>;
|
|
39
|
-
export type ExtractExpenseActionRequester = ActionRequester<ExtractExpenseAction, ExtractedExpenseDocument>;
|
|
40
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|