Skip to content

Commit cc94b3a

Browse files
committed
js-core-1.4.0 - functions overrides will already be merged with base. deprecated field renamed
1 parent 5c7f731 commit cc94b3a

5 files changed

Lines changed: 16 additions & 12 deletions

File tree

javascript/json-transform-core/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript/json-transform-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nlighten/json-transform-core",
33
"description": "Core types and utilities for handling JSON transformers",
4-
"version": "1.3.4",
4+
"version": "1.4.0",
55
"main": "dist/json-transform-core.js",
66
"umd:main": "dist/json-transform-core.umd.js",
77
"module": "dist/json-transform-core.module.js",

javascript/json-transform-core/src/functions/functionsParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class FunctionsParser {
137137
if (func.overrides) {
138138
for (const override of func.overrides) {
139139
if (override.if.every(c => args[c.argument]?.toString().toUpperCase() === c.equals)) {
140-
func = { ...func, ...override.then }; // replace func instance based on args
140+
func = override.then; // replace func instance based on args
141141
break;
142142
}
143143
}
@@ -164,7 +164,7 @@ class FunctionsParser {
164164
if (func.overrides) {
165165
for (const override of func.overrides) {
166166
if (override.if.every(c => data[c.argument]?.toString().toUpperCase() === c.equals)) {
167-
func = { ...func, ...override.then }; // replace func instance based on args
167+
func = override.then; // replace func instance based on args
168168
break;
169169
}
170170
}

javascript/json-transform-core/src/functions/parseSchemas.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ function parseSchemas<T extends string>(
1414
func.custom = true;
1515
}
1616
if (Array.isArray(func.overrides)) {
17-
func.overrides.forEach(o => {
18-
if (o.then.outputSchema) {
19-
o.then.parsedOutputSchema = JSONSchemaUtils.parse(o.then.outputSchema);
20-
}
21-
});
17+
for (let i = 0; i < func.overrides.length; i++) {
18+
const schemaOverride = func.overrides[i].then.outputSchema;
19+
func.overrides[i] = {
20+
...func,
21+
overrides: null,
22+
parsedOutputSchema: schemaOverride && JSONSchemaUtils.parse(schemaOverride),
23+
};
24+
}
2225
}
2326
}
2427
return functions;

javascript/json-transform-core/src/functions/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export type ArgumentCondition = {
103103

104104
export type ConditionalOverrides = {
105105
if: ArgumentCondition[]; // AND relationship
106-
then: Partial<FunctionDescriptor>;
106+
then: FunctionDescriptor;
107107
};
108108

109109
export type FunctionDescriptor = {
@@ -116,7 +116,8 @@ export type FunctionDescriptor = {
116116
overrides?: ConditionalOverrides[];
117117
/** For documentation purposes when output schema is calculated */
118118
outputSchemaTemplate?: TypeSchema;
119-
deprecated?: string;
119+
/** should specify the alternative function that should be used instead **/
120+
deprecatedInFavorOf?: string;
120121
/** If set, this function does not alter the type of its primary argument */
121122
pipedType?: boolean;
122123
custom?: boolean;

0 commit comments

Comments
 (0)