@bleedingdev/modern-js-bff-core 3.9.0-ultramodern.4 → 3.9.0-ultramodern.6
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/dist/cjs/client/generateClient.js +67 -138
- package/dist/cjs/index.js +25 -101
- package/dist/esm/client/generateClient.mjs +65 -139
- package/dist/esm/index.mjs +0 -4
- package/dist/esm-node/client/generateClient.mjs +65 -139
- package/dist/esm-node/index.mjs +0 -4
- package/dist/types/client/generateClient.d.ts +24 -1
- package/dist/types/index.d.ts +0 -4
- package/package.json +5 -12
- package/dist/cjs/adapter-kit/index.js +0 -144
- package/dist/cjs/adapter-kit/parity-scenarios/cross-project-denial.js +0 -55
- package/dist/cjs/adapter-kit/parity-scenarios/envelope.js +0 -128
- package/dist/cjs/adapter-kit/parity-scenarios/operation-context.js +0 -152
- package/dist/cjs/adapter-kit/parity-scenarios/schema.js +0 -109
- package/dist/cjs/adapter-kit/parity-scenarios/shared.js +0 -71
- package/dist/cjs/adapter-kit/parity.js +0 -204
- package/dist/cjs/security/crossProjectPolicy.js +0 -309
- package/dist/cjs/security/operationContracts.js +0 -183
- package/dist/cjs/security/resolveCrossProjectPolicy.js +0 -65
- package/dist/esm/adapter-kit/index.mjs +0 -79
- package/dist/esm/adapter-kit/parity-scenarios/cross-project-denial.mjs +0 -17
- package/dist/esm/adapter-kit/parity-scenarios/envelope.mjs +0 -90
- package/dist/esm/adapter-kit/parity-scenarios/operation-context.mjs +0 -111
- package/dist/esm/adapter-kit/parity-scenarios/schema.mjs +0 -71
- package/dist/esm/adapter-kit/parity-scenarios/shared.mjs +0 -21
- package/dist/esm/adapter-kit/parity.mjs +0 -148
- package/dist/esm/security/crossProjectPolicy.mjs +0 -259
- package/dist/esm/security/operationContracts.mjs +0 -127
- package/dist/esm/security/resolveCrossProjectPolicy.mjs +0 -27
- package/dist/esm-node/adapter-kit/index.mjs +0 -80
- package/dist/esm-node/adapter-kit/parity-scenarios/cross-project-denial.mjs +0 -18
- package/dist/esm-node/adapter-kit/parity-scenarios/envelope.mjs +0 -91
- package/dist/esm-node/adapter-kit/parity-scenarios/operation-context.mjs +0 -112
- package/dist/esm-node/adapter-kit/parity-scenarios/schema.mjs +0 -72
- package/dist/esm-node/adapter-kit/parity-scenarios/shared.mjs +0 -22
- package/dist/esm-node/adapter-kit/parity.mjs +0 -149
- package/dist/esm-node/security/crossProjectPolicy.mjs +0 -260
- package/dist/esm-node/security/operationContracts.mjs +0 -130
- package/dist/esm-node/security/resolveCrossProjectPolicy.mjs +0 -28
- package/dist/types/adapter-kit/index.d.ts +0 -90
- package/dist/types/adapter-kit/parity-scenarios/cross-project-denial.d.ts +0 -2
- package/dist/types/adapter-kit/parity-scenarios/envelope.d.ts +0 -2
- package/dist/types/adapter-kit/parity-scenarios/operation-context.d.ts +0 -3
- package/dist/types/adapter-kit/parity-scenarios/schema.d.ts +0 -2
- package/dist/types/adapter-kit/parity-scenarios/shared.d.ts +0 -32
- package/dist/types/adapter-kit/parity.d.ts +0 -43
- package/dist/types/security/crossProjectPolicy.d.ts +0 -110
- package/dist/types/security/operationContracts.d.ts +0 -84
- package/dist/types/security/resolveCrossProjectPolicy.d.ts +0 -39
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
-
var define = (defs, kind)=>{
|
|
6
|
-
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
[kind]: defs[key]
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
define(getters, "get");
|
|
12
|
-
define(values, "value");
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
(()=>{
|
|
16
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
-
})();
|
|
18
|
-
(()=>{
|
|
19
|
-
__webpack_require__.r = (exports1)=>{
|
|
20
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
-
value: 'Module'
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
-
value: true
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
})();
|
|
28
|
-
var __webpack_exports__ = {};
|
|
29
|
-
__webpack_require__.r(__webpack_exports__);
|
|
30
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
createOperationContextDenialScenarios: ()=>createOperationContextDenialScenarios,
|
|
32
|
-
createOperationContextSuccessScenarios: ()=>createOperationContextSuccessScenarios
|
|
33
|
-
});
|
|
34
|
-
const external_shared_js_namespaceObject = require("./shared.js");
|
|
35
|
-
const createOperationContextSuccessScenarios = ({ helloContract, validEnvelope, validOperationId })=>[
|
|
36
|
-
{
|
|
37
|
-
name: 'policy pass with full operation context',
|
|
38
|
-
policy: true,
|
|
39
|
-
request: {
|
|
40
|
-
method: 'get',
|
|
41
|
-
path: '/hello',
|
|
42
|
-
headers: {
|
|
43
|
-
'x-modernjs-bff-envelope': validEnvelope,
|
|
44
|
-
'x-operation-id': validOperationId,
|
|
45
|
-
'x-modernjs-bff-operation-context': (0, external_shared_js_namespaceObject.detailHeader)({
|
|
46
|
-
requestId: external_shared_js_namespaceObject.PARITY_PRODUCER_REQUEST_ID,
|
|
47
|
-
method: 'GET',
|
|
48
|
-
routePath: '/hello',
|
|
49
|
-
schemaHash: helloContract.schemaHash,
|
|
50
|
-
operationVersion: helloContract.operationVersion
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
expected: {
|
|
55
|
-
kind: 'payload',
|
|
56
|
-
status: 200,
|
|
57
|
-
payload: {
|
|
58
|
-
message: 'hello'
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
];
|
|
63
|
-
const getMismatchedOperationVersion = (contract)=>{
|
|
64
|
-
const operationVersion = contract.operationVersion;
|
|
65
|
-
if ('number' != typeof operationVersion) throw new Error('Adapter parity hello contract requires operationVersion');
|
|
66
|
-
return operationVersion + 1;
|
|
67
|
-
};
|
|
68
|
-
const createOperationContextDenialScenarios = ({ helloContract, validEnvelope, validOperationId })=>[
|
|
69
|
-
(0, external_shared_js_namespaceObject.deniedScenario)('policy denies missing operation context', 'missing_operation_context', {
|
|
70
|
-
'x-modernjs-bff-envelope': validEnvelope
|
|
71
|
-
}),
|
|
72
|
-
(0, external_shared_js_namespaceObject.deniedScenario)('policy denies operation context mismatch', 'operation_context_mismatch', {
|
|
73
|
-
'x-modernjs-bff-envelope': validEnvelope,
|
|
74
|
-
'x-operation-id': 'someone-else:parity'
|
|
75
|
-
}),
|
|
76
|
-
(0, external_shared_js_namespaceObject.deniedScenario)('policy denies missing operation context details', 'missing_operation_context_details', {
|
|
77
|
-
'x-modernjs-bff-envelope': validEnvelope,
|
|
78
|
-
'x-operation-id': validOperationId
|
|
79
|
-
}),
|
|
80
|
-
(0, external_shared_js_namespaceObject.deniedScenario)('policy denies JSON-array operation context details', 'invalid_operation_context_details', {
|
|
81
|
-
'x-modernjs-bff-envelope': validEnvelope,
|
|
82
|
-
'x-operation-id': validOperationId,
|
|
83
|
-
'x-modernjs-bff-operation-context': '[]'
|
|
84
|
-
}),
|
|
85
|
-
(0, external_shared_js_namespaceObject.deniedScenario)('policy denies invalid operation context details', 'invalid_operation_context_details', {
|
|
86
|
-
'x-modernjs-bff-envelope': validEnvelope,
|
|
87
|
-
'x-operation-id': validOperationId,
|
|
88
|
-
'x-modernjs-bff-operation-context': 'not-json'
|
|
89
|
-
}),
|
|
90
|
-
(0, external_shared_js_namespaceObject.deniedScenario)('policy denies detail requestId mismatch', 'operation_context_details_request_id_mismatch', {
|
|
91
|
-
'x-modernjs-bff-envelope': validEnvelope,
|
|
92
|
-
'x-operation-id': validOperationId,
|
|
93
|
-
'x-modernjs-bff-operation-context': (0, external_shared_js_namespaceObject.detailHeader)({
|
|
94
|
-
requestId: 'crm.producer-b',
|
|
95
|
-
method: 'GET',
|
|
96
|
-
routePath: '/hello',
|
|
97
|
-
schemaHash: helloContract.schemaHash,
|
|
98
|
-
operationVersion: helloContract.operationVersion
|
|
99
|
-
})
|
|
100
|
-
}),
|
|
101
|
-
(0, external_shared_js_namespaceObject.deniedScenario)('policy denies missing operation schema hash', 'missing_operation_schema_hash', {
|
|
102
|
-
'x-modernjs-bff-envelope': validEnvelope,
|
|
103
|
-
'x-operation-id': validOperationId,
|
|
104
|
-
'x-modernjs-bff-operation-context': (0, external_shared_js_namespaceObject.detailHeader)({
|
|
105
|
-
requestId: external_shared_js_namespaceObject.PARITY_PRODUCER_REQUEST_ID,
|
|
106
|
-
method: 'GET',
|
|
107
|
-
routePath: '/hello',
|
|
108
|
-
operationVersion: helloContract.operationVersion
|
|
109
|
-
})
|
|
110
|
-
}),
|
|
111
|
-
(0, external_shared_js_namespaceObject.deniedScenario)('policy denies missing operation version', 'missing_operation_version', {
|
|
112
|
-
'x-modernjs-bff-envelope': validEnvelope,
|
|
113
|
-
'x-operation-id': validOperationId,
|
|
114
|
-
'x-modernjs-bff-operation-context': (0, external_shared_js_namespaceObject.detailHeader)({
|
|
115
|
-
requestId: external_shared_js_namespaceObject.PARITY_PRODUCER_REQUEST_ID,
|
|
116
|
-
method: 'GET',
|
|
117
|
-
routePath: '/hello',
|
|
118
|
-
schemaHash: helloContract.schemaHash
|
|
119
|
-
})
|
|
120
|
-
}),
|
|
121
|
-
(0, external_shared_js_namespaceObject.deniedScenario)('policy denies operation schema hash mismatch', 'operation_schema_hash_mismatch', {
|
|
122
|
-
'x-modernjs-bff-envelope': validEnvelope,
|
|
123
|
-
'x-operation-id': validOperationId,
|
|
124
|
-
'x-modernjs-bff-operation-context': (0, external_shared_js_namespaceObject.detailHeader)({
|
|
125
|
-
requestId: external_shared_js_namespaceObject.PARITY_PRODUCER_REQUEST_ID,
|
|
126
|
-
method: 'GET',
|
|
127
|
-
routePath: '/hello',
|
|
128
|
-
schemaHash: 'deadbeef',
|
|
129
|
-
operationVersion: helloContract.operationVersion
|
|
130
|
-
})
|
|
131
|
-
}),
|
|
132
|
-
(0, external_shared_js_namespaceObject.deniedScenario)('policy denies operation version mismatch', 'operation_version_mismatch', {
|
|
133
|
-
'x-modernjs-bff-envelope': validEnvelope,
|
|
134
|
-
'x-operation-id': validOperationId,
|
|
135
|
-
'x-modernjs-bff-operation-context': (0, external_shared_js_namespaceObject.detailHeader)({
|
|
136
|
-
requestId: external_shared_js_namespaceObject.PARITY_PRODUCER_REQUEST_ID,
|
|
137
|
-
method: 'GET',
|
|
138
|
-
routePath: '/hello',
|
|
139
|
-
schemaHash: helloContract.schemaHash,
|
|
140
|
-
operationVersion: getMismatchedOperationVersion(helloContract)
|
|
141
|
-
})
|
|
142
|
-
})
|
|
143
|
-
];
|
|
144
|
-
exports.createOperationContextDenialScenarios = __webpack_exports__.createOperationContextDenialScenarios;
|
|
145
|
-
exports.createOperationContextSuccessScenarios = __webpack_exports__.createOperationContextSuccessScenarios;
|
|
146
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
147
|
-
"createOperationContextDenialScenarios",
|
|
148
|
-
"createOperationContextSuccessScenarios"
|
|
149
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
150
|
-
Object.defineProperty(exports, '__esModule', {
|
|
151
|
-
value: true
|
|
152
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
-
var define = (defs, kind)=>{
|
|
6
|
-
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
[kind]: defs[key]
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
define(getters, "get");
|
|
12
|
-
define(values, "value");
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
(()=>{
|
|
16
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
-
})();
|
|
18
|
-
(()=>{
|
|
19
|
-
__webpack_require__.r = (exports1)=>{
|
|
20
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
-
value: 'Module'
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
-
value: true
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
})();
|
|
28
|
-
var __webpack_exports__ = {};
|
|
29
|
-
__webpack_require__.r(__webpack_exports__);
|
|
30
|
-
const createSchemaParityScenarios = ()=>[
|
|
31
|
-
{
|
|
32
|
-
name: 'schema handler success',
|
|
33
|
-
policy: false,
|
|
34
|
-
request: {
|
|
35
|
-
method: 'patch',
|
|
36
|
-
path: '/schema',
|
|
37
|
-
headers: {
|
|
38
|
-
'content-type': 'application/json'
|
|
39
|
-
},
|
|
40
|
-
body: {
|
|
41
|
-
id: 777
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
expected: {
|
|
45
|
-
kind: 'payload',
|
|
46
|
-
status: 200,
|
|
47
|
-
payload: {
|
|
48
|
-
type: 'HandleSuccess',
|
|
49
|
-
value: {
|
|
50
|
-
id: 777
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'schema handler input validation error',
|
|
57
|
-
policy: false,
|
|
58
|
-
request: {
|
|
59
|
-
method: 'patch',
|
|
60
|
-
path: '/schema',
|
|
61
|
-
headers: {
|
|
62
|
-
'content-type': 'application/json'
|
|
63
|
-
},
|
|
64
|
-
body: {
|
|
65
|
-
id: 'aaa'
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
expected: {
|
|
69
|
-
kind: 'payload',
|
|
70
|
-
status: 200,
|
|
71
|
-
payload: {
|
|
72
|
-
type: 'InputValidationError',
|
|
73
|
-
message: 'invalid input'
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: 'schema handler output validation error',
|
|
79
|
-
policy: false,
|
|
80
|
-
request: {
|
|
81
|
-
method: 'patch',
|
|
82
|
-
path: '/schema',
|
|
83
|
-
headers: {
|
|
84
|
-
'content-type': 'application/json'
|
|
85
|
-
},
|
|
86
|
-
body: {
|
|
87
|
-
id: 'boom'
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
expected: {
|
|
91
|
-
kind: 'payload',
|
|
92
|
-
status: 200,
|
|
93
|
-
payload: {
|
|
94
|
-
type: 'OutputValidationError',
|
|
95
|
-
message: 'invalid output'
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
];
|
|
100
|
-
__webpack_require__.d(__webpack_exports__, {}, {
|
|
101
|
-
createSchemaParityScenarios: createSchemaParityScenarios
|
|
102
|
-
});
|
|
103
|
-
exports.createSchemaParityScenarios = __webpack_exports__.createSchemaParityScenarios;
|
|
104
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
105
|
-
"createSchemaParityScenarios"
|
|
106
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
107
|
-
Object.defineProperty(exports, '__esModule', {
|
|
108
|
-
value: true
|
|
109
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
-
var define = (defs, kind)=>{
|
|
6
|
-
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
[kind]: defs[key]
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
define(getters, "get");
|
|
12
|
-
define(values, "value");
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
(()=>{
|
|
16
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
-
})();
|
|
18
|
-
(()=>{
|
|
19
|
-
__webpack_require__.r = (exports1)=>{
|
|
20
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
-
value: 'Module'
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
-
value: true
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
})();
|
|
28
|
-
var __webpack_exports__ = {};
|
|
29
|
-
__webpack_require__.r(__webpack_exports__);
|
|
30
|
-
const PARITY_REQUEST_ID = 'crm';
|
|
31
|
-
const PARITY_PRODUCER_REQUEST_ID = 'crm.producer-a';
|
|
32
|
-
const envelopeHeader = (requestId)=>JSON.stringify(void 0 === requestId ? {} : {
|
|
33
|
-
requestId
|
|
34
|
-
});
|
|
35
|
-
const detailHeader = (details)=>JSON.stringify(details);
|
|
36
|
-
const deniedScenario = (name, reason, headers)=>({
|
|
37
|
-
name,
|
|
38
|
-
policy: true,
|
|
39
|
-
request: {
|
|
40
|
-
method: 'get',
|
|
41
|
-
path: '/hello',
|
|
42
|
-
headers
|
|
43
|
-
},
|
|
44
|
-
expected: {
|
|
45
|
-
kind: 'denied',
|
|
46
|
-
status: 403,
|
|
47
|
-
reason
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
__webpack_require__.d(__webpack_exports__, {}, {
|
|
51
|
-
PARITY_PRODUCER_REQUEST_ID: PARITY_PRODUCER_REQUEST_ID,
|
|
52
|
-
PARITY_REQUEST_ID: PARITY_REQUEST_ID,
|
|
53
|
-
deniedScenario: deniedScenario,
|
|
54
|
-
detailHeader: detailHeader,
|
|
55
|
-
envelopeHeader: envelopeHeader
|
|
56
|
-
});
|
|
57
|
-
exports.PARITY_PRODUCER_REQUEST_ID = __webpack_exports__.PARITY_PRODUCER_REQUEST_ID;
|
|
58
|
-
exports.PARITY_REQUEST_ID = __webpack_exports__.PARITY_REQUEST_ID;
|
|
59
|
-
exports.deniedScenario = __webpack_exports__.deniedScenario;
|
|
60
|
-
exports.detailHeader = __webpack_exports__.detailHeader;
|
|
61
|
-
exports.envelopeHeader = __webpack_exports__.envelopeHeader;
|
|
62
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
63
|
-
"PARITY_PRODUCER_REQUEST_ID",
|
|
64
|
-
"PARITY_REQUEST_ID",
|
|
65
|
-
"deniedScenario",
|
|
66
|
-
"detailHeader",
|
|
67
|
-
"envelopeHeader"
|
|
68
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
69
|
-
Object.defineProperty(exports, '__esModule', {
|
|
70
|
-
value: true
|
|
71
|
-
});
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
-
var define = (defs, kind)=>{
|
|
6
|
-
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
[kind]: defs[key]
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
define(getters, "get");
|
|
12
|
-
define(values, "value");
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
(()=>{
|
|
16
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
-
})();
|
|
18
|
-
(()=>{
|
|
19
|
-
__webpack_require__.r = (exports1)=>{
|
|
20
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
-
value: 'Module'
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
-
value: true
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
})();
|
|
28
|
-
var __webpack_exports__ = {};
|
|
29
|
-
__webpack_require__.r(__webpack_exports__);
|
|
30
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
PARITY_PRODUCER_REQUEST_ID: ()=>shared_js_namespaceObject.PARITY_PRODUCER_REQUEST_ID,
|
|
32
|
-
PARITY_REQUEST_ID: ()=>shared_js_namespaceObject.PARITY_REQUEST_ID,
|
|
33
|
-
assertParityResult: ()=>assertParityResult,
|
|
34
|
-
createAdapterParityScenarios: ()=>createAdapterParityScenarios,
|
|
35
|
-
createParityApiHandlerInfos: ()=>createParityApiHandlerInfos,
|
|
36
|
-
createParityBffConfig: ()=>createParityBffConfig,
|
|
37
|
-
toParityResult: ()=>toParityResult
|
|
38
|
-
});
|
|
39
|
-
const operationContracts_js_namespaceObject = require("../security/operationContracts.js");
|
|
40
|
-
const external_types_js_namespaceObject = require("../types.js");
|
|
41
|
-
const cross_project_denial_js_namespaceObject = require("./parity-scenarios/cross-project-denial.js");
|
|
42
|
-
const envelope_js_namespaceObject = require("./parity-scenarios/envelope.js");
|
|
43
|
-
const operation_context_js_namespaceObject = require("./parity-scenarios/operation-context.js");
|
|
44
|
-
const schema_js_namespaceObject = require("./parity-scenarios/schema.js");
|
|
45
|
-
const shared_js_namespaceObject = require("./parity-scenarios/shared.js");
|
|
46
|
-
const PARITY_FIXTURE_FILENAME = 'bff-core/adapter-kit/parity-fixture.ts';
|
|
47
|
-
const HANDLER_WITH_SCHEMA = 'HANDLER_WITH_SCHEMA';
|
|
48
|
-
const isRecord = (value)=>Boolean(value) && 'object' == typeof value;
|
|
49
|
-
const createSchemaFixtureHandler = ()=>{
|
|
50
|
-
const handler = (input)=>{
|
|
51
|
-
const data = isRecord(input) && isRecord(input.data) ? input.data : void 0;
|
|
52
|
-
const id = data?.id;
|
|
53
|
-
if ('number' == typeof id) return {
|
|
54
|
-
type: 'HandleSuccess',
|
|
55
|
-
value: {
|
|
56
|
-
id
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
if ('boom' === id) return {
|
|
60
|
-
type: 'OutputValidationError',
|
|
61
|
-
message: 'invalid output'
|
|
62
|
-
};
|
|
63
|
-
return {
|
|
64
|
-
type: 'InputValidationError',
|
|
65
|
-
message: 'invalid input'
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
return Object.assign(handler, {
|
|
69
|
-
[HANDLER_WITH_SCHEMA]: true
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
const createParityApiHandlerInfos = ()=>[
|
|
73
|
-
{
|
|
74
|
-
name: 'getHello',
|
|
75
|
-
httpMethod: external_types_js_namespaceObject.HttpMethod.Get,
|
|
76
|
-
routeName: '/hello',
|
|
77
|
-
routePath: '/hello',
|
|
78
|
-
filename: PARITY_FIXTURE_FILENAME,
|
|
79
|
-
handler: ()=>({
|
|
80
|
-
message: 'hello'
|
|
81
|
-
})
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: 'postHello',
|
|
85
|
-
httpMethod: external_types_js_namespaceObject.HttpMethod.Post,
|
|
86
|
-
routeName: '/hello',
|
|
87
|
-
routePath: '/hello',
|
|
88
|
-
filename: PARITY_FIXTURE_FILENAME,
|
|
89
|
-
handler: ()=>'hello'
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: 'getNothing',
|
|
93
|
-
httpMethod: external_types_js_namespaceObject.HttpMethod.Get,
|
|
94
|
-
routeName: '/nothing',
|
|
95
|
-
routePath: '/nothing',
|
|
96
|
-
filename: PARITY_FIXTURE_FILENAME,
|
|
97
|
-
handler: ()=>void 0
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
name: 'postEcho',
|
|
101
|
-
httpMethod: external_types_js_namespaceObject.HttpMethod.Post,
|
|
102
|
-
routeName: '/echo',
|
|
103
|
-
routePath: '/echo',
|
|
104
|
-
filename: PARITY_FIXTURE_FILENAME,
|
|
105
|
-
handler: (input)=>{
|
|
106
|
-
const normalized = isRecord(input) ? input : {};
|
|
107
|
-
return {
|
|
108
|
-
data: normalized.data ?? null,
|
|
109
|
-
query: normalized.query ?? {},
|
|
110
|
-
cookie: normalized.cookies ?? null
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
name: 'getItem',
|
|
116
|
-
httpMethod: external_types_js_namespaceObject.HttpMethod.Get,
|
|
117
|
-
routeName: '/items/:id',
|
|
118
|
-
routePath: '/items/:id',
|
|
119
|
-
filename: PARITY_FIXTURE_FILENAME,
|
|
120
|
-
handler: (id, input)=>({
|
|
121
|
-
id,
|
|
122
|
-
query: isRecord(input) ? input.query ?? {} : {}
|
|
123
|
-
})
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: 'patchSchema',
|
|
127
|
-
httpMethod: external_types_js_namespaceObject.HttpMethod.Patch,
|
|
128
|
-
routeName: '/schema',
|
|
129
|
-
routePath: '/schema',
|
|
130
|
-
filename: PARITY_FIXTURE_FILENAME,
|
|
131
|
-
handler: createSchemaFixtureHandler()
|
|
132
|
-
}
|
|
133
|
-
];
|
|
134
|
-
const createParityBffConfig = ()=>({
|
|
135
|
-
requestId: shared_js_namespaceObject.PARITY_PRODUCER_REQUEST_ID,
|
|
136
|
-
crossProjectPolicy: {
|
|
137
|
-
enabled: true,
|
|
138
|
-
allowedNamespaces: [
|
|
139
|
-
shared_js_namespaceObject.PARITY_REQUEST_ID
|
|
140
|
-
],
|
|
141
|
-
allowClientAssertedNamespace: true
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
const getParityContracts = ()=>(0, operationContracts_js_namespaceObject.buildOperationContractMap)({
|
|
145
|
-
handlers: createParityApiHandlerInfos(),
|
|
146
|
-
requestId: shared_js_namespaceObject.PARITY_PRODUCER_REQUEST_ID
|
|
147
|
-
});
|
|
148
|
-
const createAdapterParityScenarios = ()=>{
|
|
149
|
-
const contracts = getParityContracts();
|
|
150
|
-
const helloContract = contracts['GET:/hello'];
|
|
151
|
-
const validEnvelope = (0, shared_js_namespaceObject.envelopeHeader)(shared_js_namespaceObject.PARITY_PRODUCER_REQUEST_ID);
|
|
152
|
-
const validOperationId = helloContract.operationId;
|
|
153
|
-
const context = {
|
|
154
|
-
helloContract,
|
|
155
|
-
validEnvelope,
|
|
156
|
-
validOperationId
|
|
157
|
-
};
|
|
158
|
-
return [
|
|
159
|
-
...(0, envelope_js_namespaceObject.createEnvelopeParityScenarios)(),
|
|
160
|
-
...(0, schema_js_namespaceObject.createSchemaParityScenarios)(),
|
|
161
|
-
...(0, operation_context_js_namespaceObject.createOperationContextSuccessScenarios)(context),
|
|
162
|
-
...(0, cross_project_denial_js_namespaceObject.createCrossProjectDenialScenarios)(),
|
|
163
|
-
...(0, operation_context_js_namespaceObject.createOperationContextDenialScenarios)(context)
|
|
164
|
-
];
|
|
165
|
-
};
|
|
166
|
-
const toParityResult = (res)=>({
|
|
167
|
-
status: res.status,
|
|
168
|
-
payload: res.type.includes('json') ? res.body : '' === res.text ? void 0 : res.text
|
|
169
|
-
});
|
|
170
|
-
const formatValue = (value)=>JSON.stringify(value);
|
|
171
|
-
const assertParityResult = (scenario, res)=>{
|
|
172
|
-
const result = toParityResult(res);
|
|
173
|
-
const failures = [];
|
|
174
|
-
const { expected } = scenario;
|
|
175
|
-
if (result.status !== expected.status) failures.push(`status: expected ${expected.status}, received ${result.status}`);
|
|
176
|
-
if ('payload' === expected.kind) {
|
|
177
|
-
if (formatValue(result.payload) !== formatValue(expected.payload)) failures.push(`payload: expected ${formatValue(expected.payload)}, received ${formatValue(result.payload)}`);
|
|
178
|
-
} else {
|
|
179
|
-
const payload = isRecord(result.payload) ? result.payload : {};
|
|
180
|
-
if ('BFF_CROSS_PROJECT_POLICY_DENIED' !== payload.code) failures.push(`denial code: expected "BFF_CROSS_PROJECT_POLICY_DENIED", received ${formatValue(payload.code)}`);
|
|
181
|
-
if (payload.reason !== expected.reason) failures.push(`denial reason: expected "${expected.reason}", received ${formatValue(payload.reason)}`);
|
|
182
|
-
if ('string' != typeof payload.message || 0 === payload.message.length) failures.push(`denial message: expected non-empty string, received ${formatValue(payload.message)}`);
|
|
183
|
-
}
|
|
184
|
-
if (failures.length > 0) throw new Error(`Adapter parity scenario "${scenario.name}" failed:\n- ${failures.join('\n- ')}`);
|
|
185
|
-
};
|
|
186
|
-
exports.PARITY_PRODUCER_REQUEST_ID = __webpack_exports__.PARITY_PRODUCER_REQUEST_ID;
|
|
187
|
-
exports.PARITY_REQUEST_ID = __webpack_exports__.PARITY_REQUEST_ID;
|
|
188
|
-
exports.assertParityResult = __webpack_exports__.assertParityResult;
|
|
189
|
-
exports.createAdapterParityScenarios = __webpack_exports__.createAdapterParityScenarios;
|
|
190
|
-
exports.createParityApiHandlerInfos = __webpack_exports__.createParityApiHandlerInfos;
|
|
191
|
-
exports.createParityBffConfig = __webpack_exports__.createParityBffConfig;
|
|
192
|
-
exports.toParityResult = __webpack_exports__.toParityResult;
|
|
193
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
194
|
-
"PARITY_PRODUCER_REQUEST_ID",
|
|
195
|
-
"PARITY_REQUEST_ID",
|
|
196
|
-
"assertParityResult",
|
|
197
|
-
"createAdapterParityScenarios",
|
|
198
|
-
"createParityApiHandlerInfos",
|
|
199
|
-
"createParityBffConfig",
|
|
200
|
-
"toParityResult"
|
|
201
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
202
|
-
Object.defineProperty(exports, '__esModule', {
|
|
203
|
-
value: true
|
|
204
|
-
});
|