oak-domain 1.1.6 → 1.1.8
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/actions/action.d.ts +2 -0
- package/lib/actions/action.js +2 -1
- package/lib/base-app-domain/Modi/Schema.d.ts +1 -1
- package/lib/base-app-domain/User/Schema.d.ts +3 -3
- package/lib/base-app-domain/User/Storage.js +1 -1
- package/lib/compiler/schemalBuilder.js +55 -20
- package/lib/types/Connector.d.ts +2 -2
- package/lib/utils/SimpleConnector.d.ts +3 -3
- package/lib/utils/SimpleConnector.js +19 -9
- package/package.json +1 -1
package/lib/actions/action.d.ts
CHANGED
|
@@ -4,11 +4,13 @@ export declare type AppendOnlyAction = ReadOnlyAction | 'create';
|
|
|
4
4
|
export declare type ExcludeUpdateAction = AppendOnlyAction | 'remove';
|
|
5
5
|
export declare type ExcludeRemoveAction = AppendOnlyAction | 'update';
|
|
6
6
|
export declare type GenericAction = 'update' | ExcludeUpdateAction;
|
|
7
|
+
export declare type RelationAction = 'grant' | 'revoke';
|
|
7
8
|
export declare const readOnlyActions: string[];
|
|
8
9
|
export declare const appendOnlyActions: string[];
|
|
9
10
|
export declare const excludeUpdateActions: string[];
|
|
10
11
|
export declare const exludeRemoveActions: string[];
|
|
11
12
|
export declare const genericActions: string[];
|
|
13
|
+
export declare const relationActions: string[];
|
|
12
14
|
export declare type AbleAction = 'enable' | 'disable';
|
|
13
15
|
export declare type AbleState = 'enabled' | 'disabled';
|
|
14
16
|
export declare const makeAbleActionDef: (initialState?: AbleState) => ActionDef<AbleAction, AbleState>;
|
package/lib/actions/action.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeAbleActionDef = exports.genericActions = exports.exludeRemoveActions = exports.excludeUpdateActions = exports.appendOnlyActions = exports.readOnlyActions = void 0;
|
|
3
|
+
exports.makeAbleActionDef = exports.relationActions = exports.genericActions = exports.exludeRemoveActions = exports.excludeUpdateActions = exports.appendOnlyActions = exports.readOnlyActions = void 0;
|
|
4
4
|
exports.readOnlyActions = ['count', 'stat', 'download', 'select'];
|
|
5
5
|
exports.appendOnlyActions = exports.readOnlyActions.concat('create');
|
|
6
6
|
exports.excludeUpdateActions = exports.appendOnlyActions.concat('remove');
|
|
7
7
|
exports.exludeRemoveActions = exports.appendOnlyActions.concat('update');
|
|
8
8
|
exports.genericActions = exports.excludeUpdateActions.concat('update');
|
|
9
|
+
exports.relationActions = ['grant', 'revoke'];
|
|
9
10
|
var makeAbleActionDef = function (initialState) { return ({
|
|
10
11
|
stm: {
|
|
11
12
|
enable: ['disabled', 'enabled'],
|
|
@@ -141,7 +141,7 @@ export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
|
|
|
141
141
|
modiEntitys$modi?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "modi" | "modiId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "modi" | "modiId">>>;
|
|
142
142
|
operEntitys$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
143
143
|
};
|
|
144
|
-
export declare type UpdateOperation = OakOperation<
|
|
144
|
+
export declare type UpdateOperation = OakOperation<"update" | ParticularAction | string, UpdateOperationData, Filter, Sorter>;
|
|
145
145
|
export declare type RemoveOperationData = {};
|
|
146
146
|
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
147
147
|
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
|
|
@@ -3,7 +3,7 @@ import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey }
|
|
|
3
3
|
import { OneOf } from "../../types/Polyfill";
|
|
4
4
|
import * as SubQuery from "../_SubQuery";
|
|
5
5
|
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
|
6
|
-
import { GenericAction } from "../../actions/action";
|
|
6
|
+
import { GenericAction, RelationAction } from "../../actions/action";
|
|
7
7
|
import * as Oper from "../Oper/Schema";
|
|
8
8
|
import * as OperEntity from "../OperEntity/Schema";
|
|
9
9
|
import * as ModiEntity from "../ModiEntity/Schema";
|
|
@@ -118,7 +118,7 @@ export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
|
|
|
118
118
|
operEntitys$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
119
119
|
modiEntitys$entity?: OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId">>>;
|
|
120
120
|
};
|
|
121
|
-
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
121
|
+
export declare type UpdateOperation = OakOperation<"update" | RelationAction | string, UpdateOperationData, Filter, Sorter>;
|
|
122
122
|
export declare type RemoveOperationData = {};
|
|
123
123
|
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
124
124
|
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
|
|
@@ -128,7 +128,7 @@ export declare type FullAttr = NativeAttr | `opers$${number}.${Oper.NativeAttr}`
|
|
|
128
128
|
export declare type EntityDef = {
|
|
129
129
|
Schema: Schema;
|
|
130
130
|
OpSchema: OpSchema;
|
|
131
|
-
Action: OakMakeAction<GenericAction> | string;
|
|
131
|
+
Action: OakMakeAction<GenericAction | RelationAction> | string;
|
|
132
132
|
Selection: Selection;
|
|
133
133
|
Operation: Operation;
|
|
134
134
|
Create: CreateOperation;
|
|
@@ -24,6 +24,7 @@ var ActionImportStatements = function () { return [
|
|
|
24
24
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("ReadOnlyAction")),
|
|
25
25
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("ExcludeUpdateAction")),
|
|
26
26
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("ExcludeRemoveAction")),
|
|
27
|
+
factory.createImportSpecifier(false, undefined, factory.createIdentifier("RelationAction")),
|
|
27
28
|
])), factory.createStringLiteral((0, env_1.ACTION_CONSTANT_IN_OAK_DOMAIN)()), undefined)
|
|
28
29
|
]; };
|
|
29
30
|
var ActionAsts = {};
|
|
@@ -201,7 +202,7 @@ function getStringTextFromUnionStringLiterals(moduleName, filename, node, progra
|
|
|
201
202
|
return [action];
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
|
-
var RESERVED_ACTION_NAMES = ['GenericAction', 'ParticularAction', 'ExcludeRemoveAction', 'ExcludeUpdateAction', 'ReadOnlyAction', 'AppendOnlyAction'];
|
|
205
|
+
var RESERVED_ACTION_NAMES = ['GenericAction', 'ParticularAction', 'ExcludeRemoveAction', 'ExcludeUpdateAction', 'ReadOnlyAction', 'AppendOnlyAction', 'RelationAction'];
|
|
205
206
|
var action_1 = require("../actions/action");
|
|
206
207
|
var DataType_1 = require("../types/DataType");
|
|
207
208
|
var Entity_1 = require("../types/Entity");
|
|
@@ -212,8 +213,11 @@ var OriginActionDict = {
|
|
|
212
213
|
'appendOnly': 'AppendOnlyAction',
|
|
213
214
|
'readOnly': 'ReadOnlyAction',
|
|
214
215
|
};
|
|
215
|
-
function dealWithActions(moduleName, filename, node, program, sourceFile) {
|
|
216
|
+
function dealWithActions(moduleName, filename, node, program, sourceFile, hasRelationDef) {
|
|
216
217
|
var actionTexts = action_1.genericActions.map(function (ele) { return ele; });
|
|
218
|
+
if (hasRelationDef) {
|
|
219
|
+
actionTexts.push.apply(actionTexts, tslib_1.__spreadArray([], tslib_1.__read(action_1.relationActions), false));
|
|
220
|
+
}
|
|
217
221
|
if (ts.isUnionTypeNode(node)) {
|
|
218
222
|
var actionNames = node.types.map(function (ele) {
|
|
219
223
|
if (ts.isTypeReferenceNode(ele) && ts.isIdentifier(ele.typeName)) {
|
|
@@ -494,13 +498,18 @@ function analyzeEntity(filename, path, program) {
|
|
|
494
498
|
hasActionDef = true;
|
|
495
499
|
var modifiers = [factory.createModifier(ts.SyntaxKind.ExportKeyword)];
|
|
496
500
|
pushStatementIntoActionAst(moduleName, factory.updateTypeAliasDeclaration(node, node.decorators, modifiers, factory.createIdentifier('ParticularAction'), node.typeParameters, node.type), sourceFile);
|
|
497
|
-
|
|
501
|
+
var actionDefNodes = [
|
|
498
502
|
factory.createTypeReferenceNode(OriginActionDict[actionType], undefined),
|
|
499
503
|
factory.createTypeReferenceNode('ParticularAction', undefined)
|
|
500
|
-
]
|
|
501
|
-
|
|
504
|
+
];
|
|
505
|
+
if (hasRelationDef || moduleName === 'User') {
|
|
506
|
+
actionDefNodes.push(factory.createTypeReferenceNode('RelationAction', undefined));
|
|
507
|
+
}
|
|
508
|
+
pushStatementIntoActionAst(moduleName, factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("Action"), undefined, factory.createUnionTypeNode(actionDefNodes)), sourceFile);
|
|
509
|
+
dealWithActions(moduleName, filename, node.type, program, sourceFile, hasRelationDef || moduleName === 'User');
|
|
502
510
|
}
|
|
503
511
|
else if (node.name.text === 'Relation') {
|
|
512
|
+
(0, assert_1.default)(!hasActionDef, "\u3010".concat(filename, "\u3011action\u5B9A\u4E49\u987B\u5728Relation\u4E4B\u540E"));
|
|
504
513
|
(0, assert_1.default)(!localeDef, "\u3010".concat(filename, "\u3011locale\u5B9A\u4E49\u987B\u5728Relation\u4E4B\u540E"));
|
|
505
514
|
// 增加userXXX对象的描述
|
|
506
515
|
if (ts.isLiteralTypeNode(node.type)) {
|
|
@@ -783,6 +792,7 @@ function analyzeEntity(filename, path, program) {
|
|
|
783
792
|
toModi: toModi,
|
|
784
793
|
actionType: actionType,
|
|
785
794
|
static: _static,
|
|
795
|
+
hasRelationDef: hasRelationDef,
|
|
786
796
|
};
|
|
787
797
|
if (hasFulltextIndex) {
|
|
788
798
|
(0, lodash_1.assign)(schema, {
|
|
@@ -2244,12 +2254,13 @@ function constructActions(statements, entity) {
|
|
|
2244
2254
|
}
|
|
2245
2255
|
statements.push(factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("UpdateOperationData"), undefined, factory.createIntersectionTypeNode(adNodes)));
|
|
2246
2256
|
// UpdateOperation
|
|
2247
|
-
var actionTypeNodes =
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2257
|
+
var actionTypeNodes = [factory.createLiteralTypeNode(factory.createStringLiteral("update"))];
|
|
2258
|
+
if (ActionAsts[entity]) {
|
|
2259
|
+
actionTypeNodes.push(factory.createTypeReferenceNode('ParticularAction'));
|
|
2260
|
+
}
|
|
2261
|
+
if (Schema[entity].hasRelationDef || entity === 'User') {
|
|
2262
|
+
actionTypeNodes.push(factory.createTypeReferenceNode('RelationAction'));
|
|
2263
|
+
}
|
|
2253
2264
|
if (process.env.COMPLING_AS_LIB) {
|
|
2254
2265
|
actionTypeNodes.push(factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));
|
|
2255
2266
|
}
|
|
@@ -2603,7 +2614,9 @@ function outputSchema(outputDir, printer) {
|
|
|
2603
2614
|
])), moduleSpecifier, undefined));
|
|
2604
2615
|
}
|
|
2605
2616
|
}
|
|
2606
|
-
statements.push(factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports(localActions.map(function (ele) { return factory.createImportSpecifier(false, undefined, factory.createIdentifier(ele)); }))), factory.createStringLiteral('./Action'), undefined)
|
|
2617
|
+
statements.push(factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports(localActions.map(function (ele) { return factory.createImportSpecifier(false, undefined, factory.createIdentifier(ele)); }))), factory.createStringLiteral('./Action'), undefined), factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
|
|
2618
|
+
factory.createImportSpecifier(false, undefined, factory.createIdentifier("RelationAction")),
|
|
2619
|
+
])), factory.createStringLiteral((0, env_1.ACTION_CONSTANT_IN_OAK_DOMAIN)()), undefined));
|
|
2607
2620
|
}
|
|
2608
2621
|
else {
|
|
2609
2622
|
statements.push(factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
|
|
@@ -2612,6 +2625,7 @@ function outputSchema(outputDir, printer) {
|
|
|
2612
2625
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("ReadOnlyAction")),
|
|
2613
2626
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("ExcludeUpdateAction")),
|
|
2614
2627
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("ExcludeRemoveAction")),
|
|
2628
|
+
factory.createImportSpecifier(false, undefined, factory.createIdentifier("RelationAction")),
|
|
2615
2629
|
])), factory.createStringLiteral((0, env_1.ACTION_CONSTANT_IN_OAK_DOMAIN)()), undefined));
|
|
2616
2630
|
}
|
|
2617
2631
|
constructSchema(statements, entity);
|
|
@@ -2621,9 +2635,17 @@ function outputSchema(outputDir, printer) {
|
|
|
2621
2635
|
constructActions(statements, entity);
|
|
2622
2636
|
constructQuery(statements, entity);
|
|
2623
2637
|
constructFullAttrs(statements, entity);
|
|
2624
|
-
var
|
|
2625
|
-
|
|
2626
|
-
|
|
2638
|
+
var makeActionArguments = [];
|
|
2639
|
+
if (ActionAsts[entity]) {
|
|
2640
|
+
makeActionArguments.push(factory.createTypeReferenceNode('Action'));
|
|
2641
|
+
}
|
|
2642
|
+
else {
|
|
2643
|
+
makeActionArguments.push(factory.createTypeReferenceNode(OriginActionDict[Schema[entity].actionType]));
|
|
2644
|
+
}
|
|
2645
|
+
if (Schema[entity].hasRelationDef || entity === 'User') {
|
|
2646
|
+
makeActionArguments.push(factory.createTypeReferenceNode('RelationAction'));
|
|
2647
|
+
}
|
|
2648
|
+
var actionTypeNode = factory.createTypeReferenceNode(factory.createIdentifier('OakMakeAction'), makeActionArguments.length === 1 ? makeActionArguments : [factory.createUnionTypeNode(makeActionArguments)]);
|
|
2627
2649
|
var EntityDefAttrs = [
|
|
2628
2650
|
factory.createPropertySignature(undefined, factory.createIdentifier("Schema"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("Schema"), undefined)),
|
|
2629
2651
|
factory.createPropertySignature(undefined, factory.createIdentifier("OpSchema"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("OpSchema"), undefined)),
|
|
@@ -2906,17 +2928,18 @@ function outputStorage(outputDir, printer) {
|
|
|
2906
2928
|
factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, undefined, factory.createIdentifier("StorageDesc"))])), factory.createStringLiteral("".concat((0, env_1.TYPE_PATH_IN_OAK_DOMAIN)(), "Storage")), undefined),
|
|
2907
2929
|
factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, undefined, factory.createIdentifier("OpSchema"))])), factory.createStringLiteral("./Schema"), undefined)
|
|
2908
2930
|
];
|
|
2931
|
+
var needImportActions = [];
|
|
2909
2932
|
switch (actionType) {
|
|
2910
2933
|
case 'readOnly': {
|
|
2911
|
-
|
|
2934
|
+
needImportActions.push(factory.createImportSpecifier(false, factory.createIdentifier("readOnlyActions"), factory.createIdentifier("actions")));
|
|
2912
2935
|
break;
|
|
2913
2936
|
}
|
|
2914
2937
|
case 'appendOnly': {
|
|
2915
|
-
|
|
2938
|
+
needImportActions.push(factory.createImportSpecifier(false, factory.createIdentifier("appendOnlyActions"), factory.createIdentifier("actions")));
|
|
2916
2939
|
break;
|
|
2917
2940
|
}
|
|
2918
2941
|
case 'excludeUpdate': {
|
|
2919
|
-
|
|
2942
|
+
needImportActions.push(factory.createImportSpecifier(false, factory.createIdentifier("excludeUpdateActions"), factory.createIdentifier("actions")));
|
|
2920
2943
|
break;
|
|
2921
2944
|
}
|
|
2922
2945
|
default: {
|
|
@@ -2924,10 +2947,16 @@ function outputStorage(outputDir, printer) {
|
|
|
2924
2947
|
statements.push(factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, undefined, factory.createIdentifier("actions"))])), factory.createStringLiteral("./Action"), undefined));
|
|
2925
2948
|
}
|
|
2926
2949
|
else {
|
|
2927
|
-
|
|
2950
|
+
needImportActions.push(factory.createImportSpecifier(false, factory.createIdentifier("genericActions"), factory.createIdentifier("actions")));
|
|
2928
2951
|
}
|
|
2929
2952
|
}
|
|
2930
2953
|
}
|
|
2954
|
+
if (Schema[entity].hasRelationDef || entity === 'User') {
|
|
2955
|
+
needImportActions.push(factory.createImportSpecifier(false, undefined, factory.createIdentifier("relationActions")));
|
|
2956
|
+
}
|
|
2957
|
+
if (needImportActions.length > 0) {
|
|
2958
|
+
statements.push(factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports(needImportActions)), factory.createStringLiteral((0, env_1.ACTION_CONSTANT_IN_OAK_DOMAIN)()), undefined));
|
|
2959
|
+
}
|
|
2931
2960
|
var propertyAssignments = [];
|
|
2932
2961
|
var attributes = constructAttributes(entity);
|
|
2933
2962
|
propertyAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("attributes"), factory.createObjectLiteralExpression(attributes, true)));
|
|
@@ -2943,7 +2972,13 @@ function outputStorage(outputDir, printer) {
|
|
|
2943
2972
|
if (_static || actionType === 'readOnly') {
|
|
2944
2973
|
propertyAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("static"), factory.createTrue()));
|
|
2945
2974
|
}
|
|
2946
|
-
propertyAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("actionType"), factory.createStringLiteral(actionType))
|
|
2975
|
+
propertyAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("actionType"), factory.createStringLiteral(actionType)));
|
|
2976
|
+
if (Schema[entity].hasRelationDef || entity === 'User') {
|
|
2977
|
+
propertyAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("actions"), factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("actions"), factory.createIdentifier("concat")), undefined, [factory.createIdentifier("relationActions")])));
|
|
2978
|
+
}
|
|
2979
|
+
else {
|
|
2980
|
+
propertyAssignments.push(factory.createShorthandPropertyAssignment(factory.createIdentifier("actions"), undefined));
|
|
2981
|
+
}
|
|
2947
2982
|
if (indexExpressions.length > 0) {
|
|
2948
2983
|
propertyAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("indexes"), factory.createArrayLiteralExpression(indexExpressions, true)));
|
|
2949
2984
|
}
|
package/lib/types/Connector.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ export declare abstract class Connector<ED extends EntityDict, Cxt extends Conte
|
|
|
10
10
|
opRecords: OpRecord<ED>[];
|
|
11
11
|
}>;
|
|
12
12
|
abstract getRouter(): string;
|
|
13
|
-
abstract parseRequest(headers: IncomingHttpHeaders, body: any, store: RowStore<ED, Cxt>): {
|
|
13
|
+
abstract parseRequest(headers: IncomingHttpHeaders, body: any, store: RowStore<ED, Cxt>): Promise<{
|
|
14
14
|
name: string;
|
|
15
15
|
params: any;
|
|
16
16
|
context: Cxt;
|
|
17
|
-
}
|
|
17
|
+
}>;
|
|
18
18
|
abstract serializeResult(result: any, context: Cxt, headers: IncomingHttpHeaders, body: any): {
|
|
19
19
|
body: any;
|
|
20
20
|
headers?: Record<string, any>;
|
|
@@ -7,17 +7,17 @@ export declare class SimpleConnector<ED extends EntityDict, Cxt extends Universa
|
|
|
7
7
|
private serverUrl;
|
|
8
8
|
private makeException;
|
|
9
9
|
private contextBuilder;
|
|
10
|
-
constructor(serverUrl: string, makeException: (exceptionData: any) => OakException, contextBuilder: (str: string | undefined) => (store: RowStore<ED, Cxt>) => Cxt);
|
|
10
|
+
constructor(serverUrl: string, makeException: (exceptionData: any) => OakException, contextBuilder: (str: string | undefined) => (store: RowStore<ED, Cxt>) => Promise<Cxt>);
|
|
11
11
|
callAspect(name: string, params: any, context: Cxt): Promise<{
|
|
12
12
|
result: any;
|
|
13
13
|
opRecords: OpRecord<ED>[];
|
|
14
14
|
}>;
|
|
15
15
|
getRouter(): string;
|
|
16
|
-
parseRequest(headers: IncomingHttpHeaders, body: any, store: RowStore<ED, Cxt>): {
|
|
16
|
+
parseRequest(headers: IncomingHttpHeaders, body: any, store: RowStore<ED, Cxt>): Promise<{
|
|
17
17
|
name: string;
|
|
18
18
|
params: any;
|
|
19
19
|
context: Cxt;
|
|
20
|
-
}
|
|
20
|
+
}>;
|
|
21
21
|
serializeResult(result: any, context: Cxt, headers: IncomingHttpHeaders, body: any): {
|
|
22
22
|
body: any;
|
|
23
23
|
headers?: Record<string, any> | undefined;
|
|
@@ -61,15 +61,25 @@ var SimpleConnector = /** @class */ (function (_super) {
|
|
|
61
61
|
return SimpleConnector.ROUTER;
|
|
62
62
|
};
|
|
63
63
|
SimpleConnector.prototype.parseRequest = function (headers, body, store) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var oakCxtStr, aspectName, context;
|
|
66
|
+
return tslib_1.__generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
oakCxtStr = headers["oak-cxt"], aspectName = headers["oak-aspect"];
|
|
70
|
+
(0, assert_1.default)(typeof oakCxtStr === 'string' || oakCxtStr === undefined);
|
|
71
|
+
(0, assert_1.default)(typeof aspectName === 'string');
|
|
72
|
+
return [4 /*yield*/, this.contextBuilder(oakCxtStr)(store)];
|
|
73
|
+
case 1:
|
|
74
|
+
context = _a.sent();
|
|
75
|
+
return [2 /*return*/, {
|
|
76
|
+
name: aspectName,
|
|
77
|
+
params: body,
|
|
78
|
+
context: context,
|
|
79
|
+
}];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
73
83
|
};
|
|
74
84
|
SimpleConnector.prototype.serializeResult = function (result, context, headers, body) {
|
|
75
85
|
return {
|