@lafken/common 0.12.25 → 0.12.27
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.
|
@@ -4,6 +4,6 @@ export declare const primitiveTypeValues: Set<PrimitiveTypes>;
|
|
|
4
4
|
export declare const primitiveTypeofValues: Set<string>;
|
|
5
5
|
export declare const mapTypeofValueToPrimitiveType: Record<string, PrimitiveTypes>;
|
|
6
6
|
export declare const getPrimitiveType: (type: AllowedTypes) => PrimitiveTypes | undefined;
|
|
7
|
-
export declare const getEventFields: (prefix: string, target?: AllowedTypes, name?: string) => BaseFieldMetadata | undefined;
|
|
8
|
-
export declare const createFieldDecorator: <T extends FieldProps, M>({ prefix, enableInLambdaInvocation, getMetadata, }: CreateFieldDecoratorProps<T, M>) => (props?: T) => (target: any, destinationName: string) => void;
|
|
7
|
+
export declare const getEventFields: (prefix: string, target?: AllowedTypes, name?: string, disablePropertiesValidation?: boolean) => BaseFieldMetadata | undefined;
|
|
8
|
+
export declare const createFieldDecorator: <T extends FieldProps, M>({ prefix, enableInLambdaInvocation, disablePropertiesValidation, getMetadata, }: CreateFieldDecoratorProps<T, M>) => (props?: T) => (target: any, destinationName: string) => void;
|
|
9
9
|
export declare const createFieldName: (prefix: string, type: FieldProperties) => string;
|
|
@@ -25,7 +25,7 @@ const getPrimitiveType = (type) => {
|
|
|
25
25
|
return 'Boolean';
|
|
26
26
|
};
|
|
27
27
|
exports.getPrimitiveType = getPrimitiveType;
|
|
28
|
-
const getEventFields = (prefix, target, name = 'event') => {
|
|
28
|
+
const getEventFields = (prefix, target, name = 'event', disablePropertiesValidation = false) => {
|
|
29
29
|
if (!target) {
|
|
30
30
|
return undefined;
|
|
31
31
|
}
|
|
@@ -36,16 +36,17 @@ const getEventFields = (prefix, target, name = 'event') => {
|
|
|
36
36
|
type: target,
|
|
37
37
|
},
|
|
38
38
|
prefix,
|
|
39
|
+
disablePropertiesValidation,
|
|
39
40
|
});
|
|
40
41
|
};
|
|
41
42
|
exports.getEventFields = getEventFields;
|
|
42
|
-
const getObjectMetadata = (metadata, payloadClass, prefix) => {
|
|
43
|
+
const getObjectMetadata = (metadata, payloadClass, prefix, disablePropertiesValidation = false) => {
|
|
43
44
|
const payloadMetadata = (0, utils_1.getMetadataByKey)(payloadClass, (0, exports.createFieldName)(prefix, field_types_1.FieldProperties.payload)) || {
|
|
44
45
|
name: payloadClass.name,
|
|
45
46
|
id: payloadClass.name,
|
|
46
47
|
};
|
|
47
48
|
const properties = (0, utils_1.getMetadataPrototypeByKey)(payloadClass, (0, exports.createFieldName)(prefix, field_types_1.FieldProperties.field));
|
|
48
|
-
if (!properties?.length) {
|
|
49
|
+
if (!disablePropertiesValidation && !properties?.length) {
|
|
49
50
|
throw new Error(`should include Field properties in ${payloadClass.name} class`);
|
|
50
51
|
}
|
|
51
52
|
return {
|
|
@@ -56,7 +57,7 @@ const getObjectMetadata = (metadata, payloadClass, prefix) => {
|
|
|
56
57
|
};
|
|
57
58
|
};
|
|
58
59
|
const getFieldMetadata = (props) => {
|
|
59
|
-
const { fieldProps, destinationName, type, prefix } = props;
|
|
60
|
+
const { fieldProps, destinationName, type, prefix, disablePropertiesValidation } = props;
|
|
60
61
|
const metadata = {
|
|
61
62
|
destinationName,
|
|
62
63
|
name: fieldProps?.name || destinationName,
|
|
@@ -68,7 +69,7 @@ const getFieldMetadata = (props) => {
|
|
|
68
69
|
const typeHasValue = exports.mapTypeofValueToPrimitiveType[typeof fieldProps?.type];
|
|
69
70
|
if (fieldProps?.type !== undefined) {
|
|
70
71
|
if (typeof fieldProps.type === 'function' && !primitiveType) {
|
|
71
|
-
return getObjectMetadata(metadata, fieldProps.type, prefix);
|
|
72
|
+
return getObjectMetadata(metadata, fieldProps.type, prefix, disablePropertiesValidation);
|
|
72
73
|
}
|
|
73
74
|
if (Array.isArray(fieldProps.type)) {
|
|
74
75
|
const arrayPrimitiveType = (0, exports.getPrimitiveType)(fieldProps.type[0]);
|
|
@@ -85,7 +86,7 @@ const getFieldMetadata = (props) => {
|
|
|
85
86
|
items = getObjectMetadata({
|
|
86
87
|
name: 'Object',
|
|
87
88
|
destinationName: 'Object',
|
|
88
|
-
}, fieldProps.type[0], prefix);
|
|
89
|
+
}, fieldProps.type[0], prefix, disablePropertiesValidation);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
return {
|
|
@@ -109,7 +110,7 @@ const getFieldMetadata = (props) => {
|
|
|
109
110
|
type: 'Any',
|
|
110
111
|
};
|
|
111
112
|
};
|
|
112
|
-
const createFieldDecorator = ({ prefix, enableInLambdaInvocation, getMetadata, }) => (props) => (target, destinationName) => {
|
|
113
|
+
const createFieldDecorator = ({ prefix, enableInLambdaInvocation, disablePropertiesValidation, getMetadata, }) => (props) => (target, destinationName) => {
|
|
113
114
|
if (!(0, build_env_utils_1.isBuildEnvironment)() && !enableInLambdaInvocation) {
|
|
114
115
|
return;
|
|
115
116
|
}
|
|
@@ -129,6 +130,7 @@ const createFieldDecorator = ({ prefix, enableInLambdaInvocation, getMetadata, }
|
|
|
129
130
|
type: parentMetadata.forceType ?? props?.type,
|
|
130
131
|
},
|
|
131
132
|
prefix,
|
|
133
|
+
disablePropertiesValidation,
|
|
132
134
|
}),
|
|
133
135
|
},
|
|
134
136
|
];
|
|
@@ -62,6 +62,7 @@ export declare enum FieldProperties {
|
|
|
62
62
|
export interface CreateFieldDecoratorProps<P extends FieldProps, M> {
|
|
63
63
|
prefix: string;
|
|
64
64
|
enableInLambdaInvocation?: boolean;
|
|
65
|
+
disablePropertiesValidation?: boolean;
|
|
65
66
|
getMetadata: (props?: P) => Omit<M, keyof FieldMetadata> & {
|
|
66
67
|
forceType?: any;
|
|
67
68
|
};
|
|
@@ -71,4 +72,5 @@ export interface GetFieldMetadataProps {
|
|
|
71
72
|
prefix: string;
|
|
72
73
|
destinationName: string;
|
|
73
74
|
fieldProps?: FieldProps;
|
|
75
|
+
disablePropertiesValidation?: boolean;
|
|
74
76
|
}
|
package/package.json
CHANGED