@raytio/core 11.6.0 → 11.8.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/README.md +29 -0
- package/dist/schema/expandSchema/index.d.ts +1 -0
- package/dist/schema/expandSchema/index.js +1 -0
- package/dist/schema/expandSchema/removePrivateFields.d.ts +10 -2
- package/dist/schema/expandSchema/resolveSchemaExtensions.d.ts +15 -0
- package/dist/schema/expandSchema/resolveSchemaExtensions.js +54 -0
- package/dist/schema/expandSchema/unwrapSchema.d.ts +1 -1
- package/dist/schema/expandSchema/unwrapSchema.js +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -145,6 +145,7 @@ If you wish to use `@raytio/core` directly, an example of configuring polyfills
|
|
|
145
145
|
- [pemToBytes](#pemtobytes)
|
|
146
146
|
- [repairDate](#repairdate)
|
|
147
147
|
- [requiresLocalSecret](#requireslocalsecret)
|
|
148
|
+
- [resolveSchemaExtensions](#resolveschemaextensions)
|
|
148
149
|
- [setArgon2Module](#setargon2module)
|
|
149
150
|
- [signData](#signdata)
|
|
150
151
|
- [signText](#signtext)
|
|
@@ -2024,6 +2025,34 @@ true if LocalSecret is required
|
|
|
2024
2025
|
|
|
2025
2026
|
___
|
|
2026
2027
|
|
|
2028
|
+
### resolveSchemaExtensions
|
|
2029
|
+
|
|
2030
|
+
▸ **resolveSchemaExtensions**(`schemas`): `WrappedSchema`[]
|
|
2031
|
+
|
|
2032
|
+
Resolves schema extensions by deep-merging base schemas into extension schemas.
|
|
2033
|
+
|
|
2034
|
+
When a schema has `extends_schema_name` set, the base schema is looked up
|
|
2035
|
+
from the already-fetched schemas and deep-merged with the extension.
|
|
2036
|
+
The extension wins on conflict.
|
|
2037
|
+
|
|
2038
|
+
Design constraints:
|
|
2039
|
+
- Single-level only: a base schema must not itself be an extension
|
|
2040
|
+
- Same tenant only: enforced at DB level
|
|
2041
|
+
- `extends_schema_version`: if set, matches against `schema_version`;
|
|
2042
|
+
if null, the base's `version_current` entry is used (already in the list)
|
|
2043
|
+
|
|
2044
|
+
#### Parameters
|
|
2045
|
+
|
|
2046
|
+
| Name | Type |
|
|
2047
|
+
| :------ | :------ |
|
|
2048
|
+
| `schemas` | `WrappedSchema`[] |
|
|
2049
|
+
|
|
2050
|
+
#### Returns
|
|
2051
|
+
|
|
2052
|
+
`WrappedSchema`[]
|
|
2053
|
+
|
|
2054
|
+
___
|
|
2055
|
+
|
|
2027
2056
|
### setArgon2Module
|
|
2028
2057
|
|
|
2029
2058
|
▸ **setArgon2Module**(`module`): `void`
|
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.findSuitableLocale = void 0;
|
|
18
18
|
__exportStar(require("./expandSchema"), exports);
|
|
19
|
+
__exportStar(require("./resolveSchemaExtensions"), exports);
|
|
19
20
|
__exportStar(require("./sortSchemaProperties"), exports);
|
|
20
21
|
__exportStar(require("./constants"), exports);
|
|
21
22
|
var i18n_1 = require("./i18n");
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { Schema } from "@raytio/types";
|
|
2
2
|
export declare const removePrivateFields: (schema: Schema) => {
|
|
3
3
|
properties: Record<string, Omit<import("@raytio/types").SchemaField, "$id" | "allOf" | "$schema" | "definitions">>;
|
|
4
|
+
id: never;
|
|
5
|
+
start_date: string;
|
|
6
|
+
end_date: string;
|
|
7
|
+
active: boolean;
|
|
8
|
+
metadata: unknown;
|
|
9
|
+
row_version?: number;
|
|
10
|
+
resource_group?: string;
|
|
11
|
+
resource_name?: string;
|
|
12
|
+
resource_url?: string;
|
|
13
|
+
tenant_id?: string;
|
|
4
14
|
title: string;
|
|
5
15
|
description: string;
|
|
6
16
|
description_decorator?: "md";
|
|
@@ -159,8 +169,6 @@ export declare const removePrivateFields: (schema: Schema) => {
|
|
|
159
169
|
verified_fields?: (string | import("@raytio/types").ConditionallyRequired)[];
|
|
160
170
|
required?: (string | import("@raytio/types").ConditionallyRequired)[];
|
|
161
171
|
wasExpandedByClient?: boolean;
|
|
162
|
-
start_date?: string;
|
|
163
|
-
end_date?: string;
|
|
164
172
|
database?: {
|
|
165
173
|
table?: string;
|
|
166
174
|
primary_key: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { WrappedSchema } from "@raytio/types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves schema extensions by deep-merging base schemas into extension schemas.
|
|
4
|
+
*
|
|
5
|
+
* When a schema has `extends_schema_name` set, the base schema is looked up
|
|
6
|
+
* from the already-fetched schemas and deep-merged with the extension.
|
|
7
|
+
* The extension wins on conflict.
|
|
8
|
+
*
|
|
9
|
+
* Design constraints:
|
|
10
|
+
* - Single-level only: a base schema must not itself be an extension
|
|
11
|
+
* - Same tenant only: enforced at DB level
|
|
12
|
+
* - `extends_schema_version`: if set, matches against `schema_version`;
|
|
13
|
+
* if null, the base's `version_current` entry is used (already in the list)
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveSchemaExtensions(schemas: WrappedSchema[]): WrappedSchema[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveSchemaExtensions = resolveSchemaExtensions;
|
|
4
|
+
const ramda_1 = require("ramda");
|
|
5
|
+
/**
|
|
6
|
+
* Resolves schema extensions by deep-merging base schemas into extension schemas.
|
|
7
|
+
*
|
|
8
|
+
* When a schema has `extends_schema_name` set, the base schema is looked up
|
|
9
|
+
* from the already-fetched schemas and deep-merged with the extension.
|
|
10
|
+
* The extension wins on conflict.
|
|
11
|
+
*
|
|
12
|
+
* Design constraints:
|
|
13
|
+
* - Single-level only: a base schema must not itself be an extension
|
|
14
|
+
* - Same tenant only: enforced at DB level
|
|
15
|
+
* - `extends_schema_version`: if set, matches against `schema_version`;
|
|
16
|
+
* if null, the base's `version_current` entry is used (already in the list)
|
|
17
|
+
*/
|
|
18
|
+
function resolveSchemaExtensions(schemas) {
|
|
19
|
+
return schemas.map(schema => {
|
|
20
|
+
var _a, _b, _c, _d;
|
|
21
|
+
if (!schema.extends_schema_name) {
|
|
22
|
+
return schema;
|
|
23
|
+
}
|
|
24
|
+
const baseSchema = schemas.find(s => {
|
|
25
|
+
if (s.schema_name !== schema.extends_schema_name)
|
|
26
|
+
return false;
|
|
27
|
+
if (schema.extends_schema_version) {
|
|
28
|
+
return s.schema_version === schema.extends_schema_version;
|
|
29
|
+
}
|
|
30
|
+
return true; // version_current filtering already applied by the API query
|
|
31
|
+
});
|
|
32
|
+
if (!baseSchema) {
|
|
33
|
+
const versionNote = schema.extends_schema_version
|
|
34
|
+
? ` (version ${schema.extends_schema_version})`
|
|
35
|
+
: "";
|
|
36
|
+
// eslint-disable-next-line no-console -- Warn when base schema is missing for extension
|
|
37
|
+
console.warn(`[resolveSchemaExtensions] Base schema "${schema.extends_schema_name}"${versionNote} not found for extension "${schema.schema_name}". Skipping merge.`);
|
|
38
|
+
return schema;
|
|
39
|
+
}
|
|
40
|
+
// Deep-merge the inner schema objects: base first, extension overrides
|
|
41
|
+
const mergedInnerSchema = (0, ramda_1.mergeDeepRight)(baseSchema.schema, schema.schema);
|
|
42
|
+
// Merge required arrays: union of base and extension required fields
|
|
43
|
+
const baseRequired = (_a = baseSchema.schema.required) !== null && _a !== void 0 ? _a : [];
|
|
44
|
+
const extRequired = (_b = schema.schema.required) !== null && _b !== void 0 ? _b : [];
|
|
45
|
+
const mergedRequired = [...new Set([...baseRequired, ...extRequired])];
|
|
46
|
+
// Merge verified_fields arrays: union of base and extension
|
|
47
|
+
const baseVerified = (_c = baseSchema.schema.verified_fields) !== null && _c !== void 0 ? _c : [];
|
|
48
|
+
const extVerified = (_d = schema.schema.verified_fields) !== null && _d !== void 0 ? _d : [];
|
|
49
|
+
const mergedVerified = [...new Set([...baseVerified, ...extVerified])];
|
|
50
|
+
return Object.assign(Object.assign({}, schema), { schema: Object.assign(Object.assign(Object.assign({}, mergedInnerSchema), (mergedRequired.length > 0 ? { required: mergedRequired } : {})), (mergedVerified.length > 0
|
|
51
|
+
? { verified_fields: mergedVerified }
|
|
52
|
+
: {})) });
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Schema, WrappedSchema } from "@raytio/types";
|
|
2
|
-
export declare function unwrapSchema(wrapped: WrappedSchema): WrappedSchema["schema"] & Pick<WrappedSchema, "start_date" | "end_date" | "schema_type"> & Pick<Schema, "name" | "version">;
|
|
2
|
+
export declare function unwrapSchema(wrapped: WrappedSchema): WrappedSchema["schema"] & Pick<WrappedSchema, "start_date" | "end_date" | "schema_type" | "active" | "resource_group" | "resource_name"> & Pick<Schema, "name" | "version" | "id" | "metadata">;
|
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unwrapSchema = unwrapSchema;
|
|
4
4
|
function unwrapSchema(wrapped) {
|
|
5
|
-
return Object.assign(Object.assign({}, wrapped.schema), { name: wrapped.schema_name, start_date: wrapped.start_date, end_date: wrapped.end_date, version: wrapped.schema_version, schema_type: wrapped.schema_type
|
|
5
|
+
return Object.assign(Object.assign({}, wrapped.schema), { name: wrapped.schema_name, start_date: wrapped.start_date, end_date: wrapped.end_date, version: wrapped.schema_version, schema_type: wrapped.schema_type, active: wrapped.active, resource_group: wrapped.resource_group, resource_name: wrapped.resource_name,
|
|
6
|
+
// schemas are identified by `name`, not `id`; CommonFields-aligned but unused
|
|
7
|
+
id: undefined, metadata: undefined });
|
|
6
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raytio/core",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "index",
|
|
6
6
|
"types": "index",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@raytio/maxcryptor": "3.1.0",
|
|
21
|
-
"@raytio/types": "8.
|
|
21
|
+
"@raytio/types": "8.3.0",
|
|
22
22
|
"openpgp": "^6.1.0",
|
|
23
23
|
"ramda": "0.30.1"
|
|
24
24
|
},
|