@mpfrontend/ftg-core 0.0.0-stage → 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,24 @@
1
- # Temporary Holding Version
1
+ # @mpfrontend/ftg-core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Local development package. Runtime: universal. Public API is exported from src/index.ts and compiled
4
+ into dist. Nx owns build, typecheck, lint and test targets. Consumer applications install packed artifacts.
5
+ See ../../docs/IMPLEMENTATION-STATUS.md for observed evidence and remaining work.
6
+
7
+ Request selections are explicit: the default is a required finite closed JSON object. The opt-in
8
+ `body: "none"` profile only accepts operations with no own OpenAPI requestBody property; it produces
9
+ no schema or fields and means the consumer will send no payload. The distinct opt-in
10
+ `body: "optional-json"` profile requires a present, non-required JSON request body and produces a
11
+ schema value plus `undefined`; it supports a finite closed object or an exact null/object union.
12
+ Optional JSON, nullable JSON and an operation with no request body remain different contracts. Read
13
+ contracts still require an explicit JSON success schema.
14
+ See [request profiles](../../docs/R4-GENERATED-REQUESTS.md).
15
+
16
+ ## List protocol
17
+
18
+ A `ListProtocol` declares, as data, how one list operation of a backend pages (a page number from 0 or 1, or an
19
+ offset), sizes, sorts (`field,direction`, `signed` or a separate direction parameter) and filters, and where its
20
+ answer holds the rows and the total. `checkListProtocol(contract, protocol)` checks it against the operation of the
21
+ captured contract: a parameter the operation does not declare in its query, a type or limit it does not accept, a
22
+ sort value outside its enumeration, a required query parameter that is not sent, and rows or a total that are not
23
+ where the protocol says are problems. `listSearchParams(protocol, state)` sends only the declared parameters and
24
+ refuses a state the protocol does not allow (`INVALID_LIST_STATE`); `listPage` reads the rows and the total.
@@ -0,0 +1,106 @@
1
+ export type JsonSchema = {
2
+ type?: string | readonly string[];
3
+ $ref?: string;
4
+ properties?: Record<string, JsonSchema>;
5
+ items?: JsonSchema;
6
+ required?: readonly string[];
7
+ enum?: readonly unknown[];
8
+ format?: string;
9
+ readOnly?: boolean;
10
+ writeOnly?: boolean;
11
+ additionalProperties?: boolean | JsonSchema;
12
+ nullable?: boolean;
13
+ allOf?: readonly JsonSchema[];
14
+ oneOf?: readonly JsonSchema[];
15
+ anyOf?: readonly JsonSchema[];
16
+ title?: string;
17
+ description?: string;
18
+ default?: unknown;
19
+ examples?: readonly unknown[];
20
+ minLength?: number;
21
+ maxLength?: number;
22
+ pattern?: string;
23
+ minimum?: number;
24
+ maximum?: number;
25
+ exclusiveMinimum?: number;
26
+ exclusiveMaximum?: number;
27
+ multipleOf?: number;
28
+ minItems?: number;
29
+ maxItems?: number;
30
+ uniqueItems?: boolean;
31
+ minProperties?: number;
32
+ maxProperties?: number;
33
+ };
34
+ export type FieldModel = Readonly<{
35
+ key: string;
36
+ type: string;
37
+ nullable: boolean;
38
+ required: boolean;
39
+ format?: string;
40
+ values?: readonly unknown[];
41
+ editable: boolean;
42
+ }>;
43
+ export type ResourceModel = Readonly<{
44
+ name: string;
45
+ operationId: string;
46
+ path: string;
47
+ method: string;
48
+ fields: readonly FieldModel[];
49
+ }> & (Readonly<{
50
+ body: 'none';
51
+ responseStatus: '204';
52
+ schema?: never;
53
+ }> | Readonly<{
54
+ body?: 'json';
55
+ responseStatus?: '200' | '201' | '202';
56
+ schema: JsonSchema;
57
+ }>);
58
+ export type ResourceSelection = Readonly<{
59
+ name: string;
60
+ operationId: string;
61
+ }> & (Readonly<{
62
+ body: 'none';
63
+ responseStatus: '204';
64
+ responsePath?: never;
65
+ }> | Readonly<{
66
+ body?: never;
67
+ responsePath?: readonly string[];
68
+ responseStatus?: '200' | '201' | '202';
69
+ }>);
70
+ export type RequestSelection = Readonly<{
71
+ name: string;
72
+ operationId: string;
73
+ }> & (Readonly<{
74
+ body: 'none' | 'optional-json';
75
+ }> | Readonly<{
76
+ body?: never;
77
+ }>);
78
+ export type RequestModel = Readonly<{
79
+ name: string;
80
+ operationId: string;
81
+ path: string;
82
+ method: string;
83
+ fields: readonly FieldModel[];
84
+ }> & (Readonly<{
85
+ body: 'none';
86
+ schema?: never;
87
+ }> | Readonly<{
88
+ body: 'optional-json';
89
+ schema: JsonSchema;
90
+ }> | Readonly<{
91
+ body?: 'json';
92
+ schema: JsonSchema;
93
+ }>);
94
+ export type OpenApiDocument = {
95
+ openapi: string;
96
+ paths: Record<string, Record<string, unknown>>;
97
+ components?: {
98
+ schemas?: Record<string, JsonSchema>;
99
+ };
100
+ };
101
+ export declare function resolveSchema(schema: JsonSchema, document: OpenApiDocument, seen?: readonly string[]): JsonSchema;
102
+ export declare function fieldsFor(schema: JsonSchema, document: OpenApiDocument, direction?: 'read' | 'request'): readonly FieldModel[];
103
+ export declare function normalizeRequests(document: OpenApiDocument, selections: readonly RequestSelection[]): readonly RequestModel[];
104
+ export declare function normalizeResources(document: OpenApiDocument, selections: readonly ResourceSelection[]): readonly ResourceModel[];
105
+ export declare function validateRead(value: unknown, schema: JsonSchema, document: OpenApiDocument, depth?: number): boolean;
106
+ export { checkListProtocol, validListState, listSearchParams, listPage, type ListProtocol, type ListSort, type ListState } from './list-protocol.js';
package/dist/index.js ADDED
@@ -0,0 +1,188 @@
1
+ export function resolveSchema(schema, document, seen = []) {
2
+ if (!schema.$ref)
3
+ return schema;
4
+ const prefix = '#/components/schemas/';
5
+ if (!schema.$ref.startsWith(prefix) || seen.includes(schema.$ref))
6
+ throw new Error('UNSUPPORTED_SCHEMA_REFERENCE');
7
+ const name = schema.$ref.slice(prefix.length).replace(/~1/g, '/').replace(/~0/g, '~');
8
+ const value = document.components?.schemas?.[name];
9
+ if (!value)
10
+ throw new Error('MISSING_SCHEMA_REFERENCE');
11
+ if (Object.keys(schema).some(key => !['$ref', 'title', 'description', 'readOnly', 'writeOnly'].includes(key)))
12
+ throw new Error('UNSUPPORTED_SCHEMA_REFERENCE_SIBLINGS');
13
+ return { ...resolveSchema(value, document, [...seen, schema.$ref]),
14
+ ...(schema.readOnly !== undefined ? { readOnly: schema.readOnly } : {}), ...(schema.writeOnly !== undefined ? { writeOnly: schema.writeOnly } : {}) };
15
+ }
16
+ export function fieldsFor(schema, document, direction = 'read') {
17
+ const resolved = resolveSchema(schema, document);
18
+ if (resolved.type !== 'object' || !resolved.properties || resolved.allOf || resolved.oneOf || resolved.anyOf)
19
+ throw new Error('UNSUPPORTED_OBJECT_SCHEMA');
20
+ return Object.entries(resolved.properties).sort(([a], [b]) => a.localeCompare(b, 'en')).filter(([, raw]) => {
21
+ const s = resolveSchema(raw, document);
22
+ return direction === 'read' ? !s.writeOnly : !s.readOnly;
23
+ }).map(([key, raw]) => {
24
+ const s = resolveSchema(raw, document);
25
+ if (s.oneOf || s.anyOf || s.allOf)
26
+ throw new Error('UNSUPPORTED_FIELD_UNION');
27
+ const types = Array.isArray(s.type) ? s.type : [s.type];
28
+ const effective = types.filter(t => t !== 'null');
29
+ if (effective.length !== 1 || !['string', 'number', 'integer', 'boolean', 'array', 'object'].includes(effective[0] ?? ''))
30
+ throw new Error('UNSUPPORTED_FIELD_TYPE');
31
+ return { key, type: effective[0], required: resolved.required?.includes(key) ?? false,
32
+ nullable: types.includes('null') || s.nullable === true, editable: direction === 'request',
33
+ ...(s.format ? { format: s.format } : {}), ...(s.enum ? { values: s.enum } : {}) };
34
+ });
35
+ }
36
+ function optionalJsonObject(schema, document) {
37
+ const resolved = resolveSchema(schema, document);
38
+ if (!resolved.oneOf) {
39
+ if (Array.isArray(resolved.type)) {
40
+ const effective = resolved.type.filter(type => type !== 'null');
41
+ if (!resolved.type.includes('null') || effective.length !== 1 || effective[0] !== 'object')
42
+ throw new Error('UNSUPPORTED_OPTIONAL_JSON_SCHEMA');
43
+ return { ...resolved, type: 'object' };
44
+ }
45
+ return resolved;
46
+ }
47
+ if (resolved.anyOf || resolved.allOf || resolved.oneOf.length !== 2)
48
+ throw new Error('UNSUPPORTED_OPTIONAL_JSON_SCHEMA');
49
+ const branches = resolved.oneOf.map(branch => resolveSchema(branch, document));
50
+ const nulls = branches.filter(branch => branch.type === 'null');
51
+ if (nulls.length !== 1)
52
+ throw new Error('UNSUPPORTED_OPTIONAL_JSON_SCHEMA');
53
+ const object = branches.find(branch => branch.type !== 'null');
54
+ if (!object || object.oneOf || object.anyOf || object.allOf)
55
+ throw new Error('UNSUPPORTED_OPTIONAL_JSON_SCHEMA');
56
+ return object;
57
+ }
58
+ export function normalizeRequests(document, selections) {
59
+ const operations = new Map();
60
+ for (const [path, item] of Object.entries(document.paths))
61
+ for (const [method, value] of Object.entries(item)) {
62
+ if (!['get', 'post', 'put', 'patch', 'delete', 'head', 'options'].includes(method))
63
+ continue;
64
+ const op = value;
65
+ if (typeof op.operationId !== 'string' || operations.has(op.operationId))
66
+ throw new Error('MISSING_OR_DUPLICATE_OPERATION_ID');
67
+ operations.set(op.operationId, { path, method, op });
68
+ }
69
+ const names = new Set();
70
+ return selections.map(selection => {
71
+ if (!/^[a-z][a-z0-9-]*$/.test(selection.name) || names.has(selection.name))
72
+ throw new Error('INVALID_REQUEST_NAME');
73
+ names.add(selection.name);
74
+ const operation = operations.get(selection.operationId);
75
+ if (!operation)
76
+ throw new Error('UNKNOWN_OPERATION_ID');
77
+ if (!['post', 'put', 'patch', 'delete'].includes(operation.method))
78
+ throw new Error('REQUEST_REQUIRES_MUTATION_OPERATION');
79
+ if (selection.body !== undefined && !['none', 'optional-json'].includes(selection.body))
80
+ throw new Error('UNSUPPORTED_REQUEST_BODY_PROFILE');
81
+ if (selection.body === 'none') {
82
+ // No requestBody in the contract is not a guessed empty object or an optional JSON payload.
83
+ if (Object.hasOwn(operation.op, 'requestBody'))
84
+ throw new Error('BODY_PROFILE_MISMATCH');
85
+ return { name: selection.name, operationId: selection.operationId, path: operation.path, method: operation.method, body: 'none', fields: [] };
86
+ }
87
+ const body = operation.op.requestBody;
88
+ if (!body?.content?.['application/json']?.schema)
89
+ throw new Error('MISSING_JSON_REQUEST');
90
+ if (selection.body === 'optional-json') {
91
+ if (body.required === true)
92
+ throw new Error('OPTIONAL_REQUEST_BODY_PROFILE_MISMATCH');
93
+ const schema = resolveSchema(body.content['application/json'].schema, document);
94
+ return { name: selection.name, operationId: selection.operationId, path: operation.path, method: operation.method, body: 'optional-json', schema, fields: fieldsFor(optionalJsonObject(schema, document), document, 'request') };
95
+ }
96
+ if (body.required !== true)
97
+ throw new Error('OPTIONAL_REQUEST_BODY_NOT_SUPPORTED');
98
+ const schema = resolveSchema(body.content['application/json'].schema, document);
99
+ return { name: selection.name, operationId: selection.operationId, path: operation.path, method: operation.method, schema, fields: fieldsFor(schema, document, 'request') };
100
+ });
101
+ }
102
+ export function normalizeResources(document, selections) {
103
+ const operations = new Map();
104
+ for (const [path, pathItem] of Object.entries(document.paths))
105
+ for (const [method, value] of Object.entries(pathItem)) {
106
+ if (!['get', 'post', 'put', 'patch', 'delete', 'head', 'options'].includes(method))
107
+ continue;
108
+ const op = value;
109
+ if (typeof op.operationId !== 'string' || operations.has(op.operationId))
110
+ throw new Error('MISSING_OR_DUPLICATE_OPERATION_ID');
111
+ operations.set(op.operationId, { path, method, op });
112
+ }
113
+ const names = new Set();
114
+ return selections.map(selection => {
115
+ if (!/^[a-z][a-z0-9-]*$/.test(selection.name) || names.has(selection.name))
116
+ throw new Error('INVALID_RESOURCE_NAME');
117
+ names.add(selection.name);
118
+ const operation = operations.get(selection.operationId);
119
+ if (!operation)
120
+ throw new Error('UNKNOWN_OPERATION_ID');
121
+ const responses = operation.op.responses;
122
+ const responseStatus = selection.responseStatus ?? '200';
123
+ if (selection.body !== undefined && selection.body !== 'none')
124
+ throw new Error('UNSUPPORTED_RESPONSE_BODY_PROFILE');
125
+ if (selection.body === 'none') {
126
+ if (responseStatus !== '204')
127
+ throw new Error('EMPTY_RESPONSE_REQUIRES_204');
128
+ if (selection.responsePath?.length)
129
+ throw new Error('EMPTY_RESPONSE_PATH_NOT_SUPPORTED');
130
+ const response = responses?.['204'];
131
+ if (!response)
132
+ throw new Error('MISSING_EMPTY_RESPONSE');
133
+ if (Object.hasOwn(response, 'content'))
134
+ throw new Error('RESPONSE_BODY_PROFILE_MISMATCH');
135
+ return { name: selection.name, operationId: selection.operationId, path: operation.path, method: operation.method, responseStatus: '204', body: 'none', fields: [] };
136
+ }
137
+ if (responseStatus === '204')
138
+ throw new Error('RESPONSE_BODY_PROFILE_MISMATCH');
139
+ if (!['200', '201', '202'].includes(responseStatus))
140
+ throw new Error('UNSUPPORTED_JSON_SUCCESS_STATUS');
141
+ let schema = responses?.[responseStatus]?.content?.['application/json']?.schema;
142
+ if (!schema)
143
+ throw new Error('MISSING_JSON_RESPONSE');
144
+ for (const key of selection.responsePath ?? []) {
145
+ schema = resolveSchema(schema, document).properties?.[key];
146
+ if (!schema)
147
+ throw new Error('INVALID_RESPONSE_PATH');
148
+ }
149
+ schema = resolveSchema(schema, document);
150
+ if (schema.type === 'array') {
151
+ if (!schema.items)
152
+ throw new Error('MISSING_ARRAY_ITEMS');
153
+ schema = resolveSchema(schema.items, document);
154
+ }
155
+ return { name: selection.name, operationId: selection.operationId, path: operation.path, method: operation.method, responseStatus, schema, fields: fieldsFor(schema, document) };
156
+ });
157
+ }
158
+ export function validateRead(value, schema, document, depth = 0) {
159
+ if (depth > 32)
160
+ return false;
161
+ const s = resolveSchema(schema, document);
162
+ if (value === null)
163
+ return s.nullable === true || (Array.isArray(s.type) && s.type.includes('null'));
164
+ const type = Array.isArray(s.type) ? s.type.find(t => t !== 'null') : s.type;
165
+ if (s.enum && !s.enum.some(v => Object.is(v, value)))
166
+ return false;
167
+ if (type === 'string')
168
+ return typeof value === 'string';
169
+ if (type === 'number' || type === 'integer')
170
+ return typeof value === 'number' && Number.isFinite(value) && (type !== 'integer' || Number.isInteger(value));
171
+ if (type === 'boolean')
172
+ return typeof value === 'boolean';
173
+ if (type === 'array')
174
+ return Array.isArray(value) && !!s.items && value.every(v => validateRead(v, s.items, document, depth + 1));
175
+ if (type === 'object') {
176
+ if (!value || typeof value !== 'object' || Array.isArray(value))
177
+ return false;
178
+ const data = value;
179
+ if (s.required?.some(key => !(key in data)))
180
+ return false;
181
+ if (s.additionalProperties === false && Object.keys(data).some(key => !s.properties?.[key]))
182
+ return false;
183
+ return Object.entries(s.properties ?? {}).every(([key, child]) => !(key in data) || validateRead(data[key], child, document, depth + 1));
184
+ }
185
+ return false;
186
+ }
187
+ export { checkListProtocol, validListState, listSearchParams, listPage } from './list-protocol.js';
188
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,aAAa,CAAC,MAAkB,EAAE,QAAyB,EAAE,OAA0B,EAAE;IACvG,IAAI,CAAC,MAAM,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC;IAChC,MAAM,MAAM,GAAG,uBAAuB,CAAC;IACvC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACnH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACtF,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACxD,IAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAA,EAAE,CAAA,CAAC,CAAC,MAAM,EAAC,OAAO,EAAC,aAAa,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C,CAAC,EAAC,CAAC,CAAC,KAAM,EAAC,QAAQ,EAAC,KAAK,GAAC,CAAC,CAAC,CAAC,CAAC;IAC9H,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC9E,MAAM,IAAI,GAAG,KAA+B,CAAC;QAC7C,IAAI,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAC1D,IAAI,CAAC,CAAC,oBAAoB,KAAK,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAC1G,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAC,KAAK,EAAC,QAAQ,EAAC,KAAK,GAAC,CAAC,CAAC,CAAC,CAAC;IACtI,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AACD,OAAO,EAAC,iBAAiB,EAAC,cAAc,EAAC,gBAAgB,EAAC,QAAQ,EAAgD,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { type OpenApiDocument } from './index.js';
2
+ /**
3
+ * How one backend list operation encodes paging, sorting and filtering, and where its answer holds the rows and the
4
+ * total. It is data that a consumer declares for an operation, and checkListProtocol checks it against the
5
+ * operation of the captured contract, so that a request sends only parameters the operation declares.
6
+ */
7
+ export type ListProtocol = Readonly<{
8
+ operationId: string;
9
+ /** A page number counted from `first`, or an offset of rows. */
10
+ page: Readonly<{
11
+ param: string;
12
+ encoding: 'number';
13
+ first: 0 | 1;
14
+ }> | Readonly<{
15
+ param: string;
16
+ encoding: 'offset';
17
+ }>;
18
+ size: Readonly<{
19
+ param: string;
20
+ max: number;
21
+ }>;
22
+ /** `field,direction` (name,asc), `signed` (name or -name), or `separate` (a field and a direction parameter). */
23
+ sort?: Readonly<{
24
+ param: string;
25
+ fields: readonly string[];
26
+ encoding: 'field,direction' | 'signed';
27
+ }> | Readonly<{
28
+ param: string;
29
+ fields: readonly string[];
30
+ encoding: 'separate';
31
+ directionParam: string;
32
+ }>;
33
+ /** Filters by name: the parameter each one is sent as, its length limit and the row field it filters, if any. */
34
+ filters?: Readonly<Record<string, Readonly<{
35
+ param: string;
36
+ maxLength: number;
37
+ field?: string;
38
+ }>>>;
39
+ /** The path of the rows array in the answer, and of the total number of rows when the backend reports one. */
40
+ rows: readonly string[];
41
+ total?: readonly string[];
42
+ }>;
43
+ export type ListSort = Readonly<{
44
+ field: string;
45
+ direction: 'asc' | 'desc';
46
+ }>;
47
+ /** One request of a list: the page counted from 1, the page size, the sort and the filter values. */
48
+ export type ListState = Readonly<{
49
+ page: number;
50
+ size: number;
51
+ sort?: ListSort | undefined;
52
+ filters?: Readonly<Record<string, string>>;
53
+ }>;
54
+ /**
55
+ * The problems of a protocol against the operation of the captured contract: an unknown operation, a parameter the
56
+ * operation does not declare in its query, a type or limit the operation does not accept, a required query parameter
57
+ * the protocol does not send, and rows or a total that the answer does not hold where the protocol says.
58
+ */
59
+ export declare function checkListProtocol(document: OpenApiDocument, protocol: ListProtocol): string[];
60
+ /** Whether a state fits the protocol: a page from 1, a size up to the maximum, a declared sort and declared filters. */
61
+ export declare function validListState(protocol: ListProtocol, state: ListState): boolean;
62
+ /** The query of one request: only the parameters the protocol declares, encoded its way. Throws INVALID_LIST_STATE. */
63
+ export declare function listSearchParams(protocol: ListProtocol, state: ListState): URLSearchParams;
64
+ /** The rows and the total of an answer, where the protocol says they are. Throws INVALID_LIST_RESPONSE. */
65
+ export declare function listPage(protocol: ListProtocol, body: unknown): Readonly<{
66
+ rows: readonly unknown[];
67
+ total: number | undefined;
68
+ }>;
@@ -0,0 +1,169 @@
1
+ import { resolveSchema } from './index.js';
2
+ const METHODS = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options'];
3
+ function operation(document, operationId) {
4
+ for (const pathItem of Object.values(document.paths))
5
+ for (const [method, value] of Object.entries(pathItem)) {
6
+ if (METHODS.includes(method) && value.operationId === operationId)
7
+ return { pathItem: pathItem, op: value };
8
+ }
9
+ return undefined;
10
+ }
11
+ function parameter(document, value) {
12
+ if (typeof value.$ref !== 'string')
13
+ return value;
14
+ const prefix = '#/components/parameters/';
15
+ const parameters = document.components?.parameters;
16
+ const target = value.$ref.startsWith(prefix) ? parameters?.[value.$ref.slice(prefix.length)] : undefined;
17
+ if (!target || typeof target.$ref === 'string')
18
+ throw new Error('UNSUPPORTED_PARAMETER_REFERENCE');
19
+ return target;
20
+ }
21
+ function typeOf(schema, document) {
22
+ if (!schema)
23
+ return undefined;
24
+ const resolved = resolveSchema(schema, document);
25
+ const types = Array.isArray(resolved.type) ? resolved.type.filter(type => type !== 'null') : [resolved.type];
26
+ return types.length === 1 ? types[0] : undefined;
27
+ }
28
+ function at(schema, path, document) {
29
+ let current = schema;
30
+ for (const key of path)
31
+ current = current ? resolveSchema(current, document).properties?.[key] : undefined;
32
+ return current ? resolveSchema(current, document) : undefined;
33
+ }
34
+ function sortValues(protocol) {
35
+ const sort = protocol.sort;
36
+ if (!sort)
37
+ return [];
38
+ return sort.fields.flatMap(field => sort.encoding === 'field,direction' ? [field + ',asc', field + ',desc'] : sort.encoding === 'signed' ? [field, '-' + field] : [field]);
39
+ }
40
+ /**
41
+ * The problems of a protocol against the operation of the captured contract: an unknown operation, a parameter the
42
+ * operation does not declare in its query, a type or limit the operation does not accept, a required query parameter
43
+ * the protocol does not send, and rows or a total that the answer does not hold where the protocol says.
44
+ */
45
+ export function checkListProtocol(document, protocol) {
46
+ const found = operation(document, protocol.operationId);
47
+ if (!found)
48
+ return ['UNKNOWN_OPERATION:' + protocol.operationId];
49
+ const problems = [];
50
+ const query = new Map();
51
+ for (const raw of [...(found.pathItem.parameters ?? []), ...(found.op.parameters ?? [])]) {
52
+ const value = parameter(document, raw);
53
+ if (value.in === 'query' && typeof value.name === 'string')
54
+ query.set(value.name, value);
55
+ }
56
+ const sent = new Map([[protocol.page.param, 'integer'], [protocol.size.param, 'integer']]);
57
+ if (protocol.sort) {
58
+ sent.set(protocol.sort.param, 'string');
59
+ if (protocol.sort.encoding === 'separate')
60
+ sent.set(protocol.sort.directionParam, 'string');
61
+ }
62
+ for (const filter of Object.values(protocol.filters ?? {}))
63
+ sent.set(filter.param, 'string');
64
+ const count = [protocol.page.param, protocol.size.param, ...(protocol.sort ? [protocol.sort.param] : []),
65
+ ...(protocol.sort?.encoding === 'separate' ? [protocol.sort.directionParam] : []), ...Object.values(protocol.filters ?? {}).map(filter => filter.param)];
66
+ for (const name of new Set(count.filter((name, index) => count.indexOf(name) !== index)))
67
+ problems.push('DUPLICATE_PARAMETER:' + name);
68
+ for (const [name, type] of sent) {
69
+ const declared = query.get(name);
70
+ if (!declared) {
71
+ problems.push('UNDECLARED_PARAMETER:' + name);
72
+ continue;
73
+ }
74
+ if (typeOf(declared.schema, document) !== type)
75
+ problems.push('PARAMETER_TYPE:' + name);
76
+ }
77
+ for (const [name, declared] of query)
78
+ if (declared.required === true && !sent.has(name))
79
+ problems.push('REQUIRED_PARAMETER_NOT_SENT:' + name);
80
+ const schemaOf = (name) => { const declared = query.get(name); return declared?.schema ? resolveSchema(declared.schema, document) : undefined; };
81
+ const size = schemaOf(protocol.size.param);
82
+ if (!Number.isInteger(protocol.size.max) || protocol.size.max < 1 || (size?.maximum !== undefined && protocol.size.max > size.maximum))
83
+ problems.push('SIZE_ABOVE_MAXIMUM');
84
+ const page = schemaOf(protocol.page.param), lowest = protocol.page.encoding === 'number' ? protocol.page.first : 0;
85
+ if (page?.minimum !== undefined && lowest < page.minimum)
86
+ problems.push('PAGE_BELOW_MINIMUM');
87
+ const sortSchema = protocol.sort ? schemaOf(protocol.sort.param) : undefined;
88
+ if (sortSchema?.enum)
89
+ for (const value of sortValues(protocol))
90
+ if (!sortSchema.enum.includes(value))
91
+ problems.push('SORT_VALUE_NOT_ALLOWED:' + value);
92
+ if (protocol.sort?.encoding === 'separate') {
93
+ const direction = schemaOf(protocol.sort.directionParam);
94
+ if (direction?.enum && !['asc', 'desc'].every(value => direction.enum.includes(value)))
95
+ problems.push('SORT_DIRECTION_NOT_ALLOWED');
96
+ }
97
+ for (const [name, filter] of Object.entries(protocol.filters ?? {})) {
98
+ const schema = schemaOf(filter.param);
99
+ if (!Number.isInteger(filter.maxLength) || filter.maxLength < 1 || (schema?.maxLength !== undefined && filter.maxLength > schema.maxLength))
100
+ problems.push('FILTER_ABOVE_MAXIMUM:' + name);
101
+ }
102
+ const answer = found.op.responses?.['200']?.content?.['application/json']?.schema;
103
+ if (!answer)
104
+ return [...problems, 'MISSING_JSON_RESPONSE'];
105
+ const rows = at(answer, protocol.rows, document);
106
+ if (!rows || typeOf(rows, document) !== 'array' || !rows.items)
107
+ problems.push('ROWS_NOT_ARRAY');
108
+ else {
109
+ const item = resolveSchema(rows.items, document);
110
+ for (const field of protocol.sort?.fields ?? [])
111
+ if (!item.properties?.[field])
112
+ problems.push('SORT_FIELD_NOT_IN_ROWS:' + field);
113
+ for (const [name, filter] of Object.entries(protocol.filters ?? {}))
114
+ if (filter.field !== undefined && !item.properties?.[filter.field])
115
+ problems.push('FILTER_FIELD_NOT_IN_ROWS:' + name);
116
+ }
117
+ if (protocol.total && typeOf(at(answer, protocol.total, document), document) !== 'integer')
118
+ problems.push('TOTAL_NOT_INTEGER');
119
+ return problems;
120
+ }
121
+ /** Whether a state fits the protocol: a page from 1, a size up to the maximum, a declared sort and declared filters. */
122
+ export function validListState(protocol, state) {
123
+ if (!Number.isSafeInteger(state.page) || state.page < 1 || !Number.isInteger(state.size) || state.size < 1 || state.size > protocol.size.max)
124
+ return false;
125
+ if (state.sort && (!protocol.sort || !protocol.sort.fields.includes(state.sort.field) || !['asc', 'desc'].includes(state.sort.direction)))
126
+ return false;
127
+ return Object.entries(state.filters ?? {}).every(([name, value]) => {
128
+ const filter = protocol.filters?.[name];
129
+ return filter !== undefined && typeof value === 'string' && value.length <= filter.maxLength;
130
+ });
131
+ }
132
+ /** The query of one request: only the parameters the protocol declares, encoded its way. Throws INVALID_LIST_STATE. */
133
+ export function listSearchParams(protocol, state) {
134
+ if (!validListState(protocol, state))
135
+ throw new Error('INVALID_LIST_STATE');
136
+ const params = new URLSearchParams();
137
+ params.set(protocol.page.param, String(protocol.page.encoding === 'number' ? state.page - 1 + protocol.page.first : (state.page - 1) * state.size));
138
+ params.set(protocol.size.param, String(state.size));
139
+ const sort = protocol.sort;
140
+ if (sort && state.sort) {
141
+ const { field, direction } = state.sort;
142
+ if (sort.encoding === 'separate') {
143
+ params.set(sort.param, field);
144
+ params.set(sort.directionParam, direction);
145
+ }
146
+ else if (sort.encoding === 'signed')
147
+ params.set(sort.param, direction === 'desc' ? '-' + field : field);
148
+ else
149
+ params.set(sort.param, field + ',' + direction);
150
+ }
151
+ for (const [name, value] of Object.entries(state.filters ?? {}))
152
+ if (value !== '')
153
+ params.set(protocol.filters[name].param, value);
154
+ return params;
155
+ }
156
+ /** The rows and the total of an answer, where the protocol says they are. Throws INVALID_LIST_RESPONSE. */
157
+ export function listPage(protocol, body) {
158
+ const read = (path) => path.reduce((value, key) => value && typeof value === 'object' && !Array.isArray(value) && Object.hasOwn(value, key) ? value[key] : undefined, body);
159
+ const rows = read(protocol.rows);
160
+ if (!Array.isArray(rows))
161
+ throw new Error('INVALID_LIST_RESPONSE');
162
+ if (!protocol.total)
163
+ return { rows, total: undefined };
164
+ const total = read(protocol.total);
165
+ if (!Number.isSafeInteger(total) || total < 0)
166
+ throw new Error('INVALID_LIST_RESPONSE');
167
+ return { rows, total: total };
168
+ }
169
+ //# sourceMappingURL=list-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-protocol.js","sourceRoot":"","sources":["../src/list-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAsC,MAAM,YAAY,CAAC;AA0B9E,MAAM,OAAO,GAAC,CAAC,KAAK,EAAC,MAAM,EAAC,KAAK,EAAC,OAAO,EAAC,QAAQ,EAAC,MAAM,EAAC,SAAS,CAAC,CAAC;AAErE,SAAS,SAAS,CAAC,QAAwB,EAAC,WAAkB;IAC5D,KAAI,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAC,KAAI,MAAM,CAAC,MAAM,EAAC,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAC,CAAC;YACxG,IAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAG,KAAgC,CAAC,WAAW,KAAG,WAAW;gBACtF,OAAO,EAAC,QAAQ,EAAC,QAAqC,EAAC,EAAE,EAAC,KAA2G,EAAC,CAAC;QAC3K,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,SAAS,SAAS,CAAC,QAAwB,EAAC,KAAe;IACzD,IAAG,OAAO,KAAK,CAAC,IAAI,KAAG,QAAQ;QAAC,OAAO,KAAK,CAAC;IAC7C,MAAM,MAAM,GAAC,0BAA0B,CAAC;IACxC,MAAM,UAAU,GAAE,QAAQ,CAAC,UAA+D,EAAE,UAAU,CAAC;IACvG,MAAM,MAAM,GAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA,CAAC,CAAA,UAAU,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,C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AAQ,CAAC,KAAK;QAAC,OAAO,EAAC,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,CAAC;IACjD,MAAM,KAAK,GAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjC,IAAG,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAG,KAAgB,GAAC,CAAC;QAAC,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC9F,OAAO,EAAC,IAAI,EAAC,KAAK,EAAC,KAAe,EAAC,CAAC;AACtC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@mpfrontend/ftg-core",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "license": "Apache-2.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/panahister/mpfrontend.git",
8
+ "directory": "packages/ftg-core"
9
+ },
10
+ "type": "module",
11
+ "main": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "provenance": true
26
+ },
27
+ "dependencies": {}
6
28
  }