@sealcode/sealgen 0.8.9 → 0.8.10
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.
|
@@ -2,14 +2,14 @@ import { Context } from "koa";
|
|
|
2
2
|
import { Depromisify, Field, FieldOutput } from "sealious";
|
|
3
3
|
import { FormDataValue } from "../form";
|
|
4
4
|
import { FieldParseResult, FormField, FormFieldValidationResponse } from "./field";
|
|
5
|
-
export declare class CollectionField<F extends Field, Required extends boolean> extends FormField<Required, FieldOutput<F
|
|
5
|
+
export declare class CollectionField<F extends Field, Required extends boolean> extends FormField<Required, FieldOutput<F> | null> {
|
|
6
6
|
sealiousField: F;
|
|
7
7
|
constructor(required: Required, sealiousField: F);
|
|
8
8
|
predicate: (v: unknown, w: unknown) => {
|
|
9
9
|
readonly match: true;
|
|
10
10
|
readonly wildcard: unknown;
|
|
11
11
|
};
|
|
12
|
-
parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<FieldOutput<F
|
|
12
|
+
parse(ctx: Context, raw_value: FormDataValue): Promise<FieldParseResult<FieldOutput<F> | null>>;
|
|
13
13
|
isValueValid(ctx: Context, value: FieldOutput<F>): Promise<FormFieldValidationResponse>;
|
|
14
14
|
getEmptyValue(): Depromisify<ReturnType<F["decode"]>>;
|
|
15
15
|
}
|
|
@@ -10,6 +10,9 @@ class CollectionField extends field_1.FormField {
|
|
|
10
10
|
this.predicate = ts_predicates_1.predicates.unknown;
|
|
11
11
|
}
|
|
12
12
|
async parse(ctx, raw_value) {
|
|
13
|
+
if (raw_value === undefined) {
|
|
14
|
+
return { parsable: true, parsed_value: null, error: null };
|
|
15
|
+
}
|
|
13
16
|
const encoded_value = (await this.sealiousField.encode(ctx.$context, raw_value));
|
|
14
17
|
const parsed_value = (await this.sealiousField.decode(ctx.$context, encoded_value, null, {}));
|
|
15
18
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-field.js","sourceRoot":"","sources":["../../../src/forms/fields/collection-field.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AAKrD,mCAIiB;AAEjB,MAAa,eAGX,SAAQ,
|
|
1
|
+
{"version":3,"file":"collection-field.js","sourceRoot":"","sources":["../../../src/forms/fields/collection-field.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AAKrD,mCAIiB;AAEjB,MAAa,eAGX,SAAQ,iBAA0C;IACnD,YAAY,QAAkB,EAAS,aAAgB;QACtD,KAAK,CAAC,QAAQ,CAAC,CAAC;QADsB,kBAAa,GAAb,aAAa,CAAG;QAIvD,cAAS,GAAG,0BAAU,CAAC,OAAO,CAAC;IAF/B,CAAC;IAID,KAAK,CAAC,KAAK,CACV,GAAY,EACZ,SAAwB;QAExB,IAAI,SAAS,KAAK,SAAS,EAAE;YAC5B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;SAC3D;QACD,MAAM,aAAa,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CACrD,GAAG,CAAC,QAAQ,EACZ,SAAS,CACT,CAAyC,CAAC;QAC3C,MAAM,YAAY,GAAG,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CACpD,GAAG,CAAC,QAAQ,EACZ,aAAa,EACb,IAAI,EACJ,EAAE,CACF,CAAyC,CAAC;QAC3C,OAAO;YACN,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,IAAI;YACX,YAAY;SACZ,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,YAAY,CACxB,GAAY,EACZ,KAAqB;QAErB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAC5D,GAAG,CAAC,QAAQ,EACZ,KAAK,EACL,SAAS,EACT,IAAI,CACJ,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACpE,CAAC;IAEM,aAAa;QACnB,OAAO,EAAqD,CAAC;IAC9D,CAAC;CACD;AAlDD,0CAkDC"}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
export class CollectionField<
|
|
13
13
|
F extends Field,
|
|
14
14
|
Required extends boolean
|
|
15
|
-
> extends FormField<Required, FieldOutput<F
|
|
15
|
+
> extends FormField<Required, FieldOutput<F> | null> {
|
|
16
16
|
constructor(required: Required, public sealiousField: F) {
|
|
17
17
|
super(required);
|
|
18
18
|
}
|
|
@@ -22,7 +22,10 @@ export class CollectionField<
|
|
|
22
22
|
async parse(
|
|
23
23
|
ctx: Context,
|
|
24
24
|
raw_value: FormDataValue
|
|
25
|
-
): Promise<FieldParseResult<FieldOutput<F
|
|
25
|
+
): Promise<FieldParseResult<FieldOutput<F> | null>> {
|
|
26
|
+
if (raw_value === undefined) {
|
|
27
|
+
return { parsable: true, parsed_value: null, error: null };
|
|
28
|
+
}
|
|
26
29
|
const encoded_value = (await this.sealiousField.encode(
|
|
27
30
|
ctx.$context,
|
|
28
31
|
raw_value
|