@sealcode/jdd 0.3.0 → 0.3.2
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/@types/component-arguments/component-argument.d.ts +4 -4
- package/@types/component-arguments/component-arguments.d.ts +1 -0
- package/@types/component-arguments/enum.d.ts +2 -0
- package/@types/component-arguments/file.d.ts +2 -0
- package/@types/component-arguments/image.d.ts +2 -0
- package/@types/component-arguments/list.d.ts +9 -6
- package/@types/component-arguments/markdown.d.ts +3 -0
- package/@types/component-arguments/short-text.d.ts +3 -0
- package/@types/component-arguments/structured.d.ts +3 -0
- package/@types/component-arguments/table.d.ts +39 -0
- package/@types/index.d.ts +1 -1
- package/@types/utils/fix-array.d.ts +3 -0
- package/@types/utils/maybepromise.d.ts +1 -0
- package/@types/utils/util-types.d.ts +1 -0
- package/lib/component-arguments/component-argument.js.map +1 -1
- package/lib/component-arguments/component-arguments.js +15 -0
- package/lib/component-arguments/component-arguments.js.map +1 -1
- package/lib/component-arguments/enum.js +11 -0
- package/lib/component-arguments/enum.js.map +1 -1
- package/lib/component-arguments/file.js +46 -1
- package/lib/component-arguments/file.js.map +1 -1
- package/lib/component-arguments/image.js +17 -11
- package/lib/component-arguments/image.js.map +1 -1
- package/lib/component-arguments/list.js +30 -3
- package/lib/component-arguments/list.js.map +1 -1
- package/lib/component-arguments/markdown.js +9 -0
- package/lib/component-arguments/markdown.js.map +1 -1
- package/lib/component-arguments/short-text.js +10 -1
- package/lib/component-arguments/short-text.js.map +1 -1
- package/lib/component-arguments/structured.js +45 -0
- package/lib/component-arguments/structured.js.map +1 -1
- package/lib/component-arguments/table.js +150 -0
- package/lib/component-arguments/table.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/fix-array.js +16 -0
- package/lib/utils/fix-array.js.map +1 -0
- package/lib/utils/maybepromise.js +3 -0
- package/lib/utils/maybepromise.js.map +1 -0
- package/lib/utils/util-types.js +3 -0
- package/lib/utils/util-types.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { JDDContext } from "../index";
|
|
2
|
-
import {
|
|
3
|
-
export type ExtractComponentArgumentValue<C> = C extends ComponentArgument<infer T> ? T : never;
|
|
1
|
+
import { JDDContext, List } from "../index";
|
|
2
|
+
import { MaybePromise } from "../utils/util-types";
|
|
3
|
+
export type ExtractComponentArgumentValue<C> = C extends List<infer S> ? S[] : C extends ComponentArgument<infer T> ? T : never;
|
|
4
4
|
export type ExtractStructuredComponentArgumentsValues<C> = {
|
|
5
5
|
[property in keyof C]: ExtractComponentArgumentValue<C[property]>;
|
|
6
6
|
};
|
|
7
|
-
export type T = ExtractComponentArgumentValue<Structured<any>>;
|
|
8
7
|
export declare abstract class ComponentArgument<ARG> {
|
|
9
8
|
example_values: ARG[];
|
|
10
9
|
parent_argument: ComponentArgument<unknown> | null;
|
|
11
10
|
abstract getTypeName(): string;
|
|
12
11
|
abstract getEmptyValue(): ARG;
|
|
13
12
|
abstract countWords(value: ARG): number;
|
|
13
|
+
abstract parseFormInput(context: JDDContext, input: unknown, arg_name: string): MaybePromise<ARG | ARG[] | null>;
|
|
14
14
|
getExampleValue(_context: JDDContext): Promise<ARG> | ARG;
|
|
15
15
|
setExampleValues(values: ARG[]): this;
|
|
16
16
|
hasParent(type: string): boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ComponentArgument } from "./component-argument";
|
|
2
|
+
import { JDDContext } from "../jdd-context";
|
|
2
3
|
export declare class Enum<T extends string> extends ComponentArgument<T> {
|
|
3
4
|
readonly values: Readonly<T[]>;
|
|
4
5
|
constructor(values: Readonly<T[]>);
|
|
@@ -6,4 +7,5 @@ export declare class Enum<T extends string> extends ComponentArgument<T> {
|
|
|
6
7
|
getEmptyValue(): T;
|
|
7
8
|
getExampleValue(): T;
|
|
8
9
|
countWords(): number;
|
|
10
|
+
parseFormInput(_: JDDContext, input: Record<string, unknown>): T | null;
|
|
9
11
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { JDDContext } from "../index";
|
|
2
2
|
import { ComponentArgument } from "./component-argument";
|
|
3
|
+
export declare function encodeSealiousFile(context: JDDContext, maybe_file: Record<string, unknown>): Promise<string | null>;
|
|
3
4
|
export declare class File extends ComponentArgument<string | null> {
|
|
4
5
|
constructor();
|
|
5
6
|
getTypeName(): string;
|
|
6
7
|
getEmptyValue(): null;
|
|
7
8
|
getExampleValue(_context: JDDContext): Promise<string>;
|
|
8
9
|
countWords(): number;
|
|
10
|
+
parseFormInput(context: JDDContext, input: unknown): Promise<string | string[] | null>;
|
|
9
11
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { JDDContext } from "..";
|
|
2
2
|
import { File as FileArgument } from "./file";
|
|
3
3
|
export declare class Image extends FileArgument {
|
|
4
|
+
private example_image_promises;
|
|
4
5
|
getTypeName(): string;
|
|
6
|
+
setExampleImages(paths: string[]): this;
|
|
5
7
|
getExampleValue(context: JDDContext): Promise<string>;
|
|
6
8
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { JDDContext } from "..";
|
|
2
|
-
import { ComponentArgument
|
|
3
|
-
export declare class List<T extends ComponentArgument<
|
|
4
|
-
item_type: T
|
|
5
|
-
|
|
2
|
+
import { ComponentArgument } from "./component-argument";
|
|
3
|
+
export declare class List<T> extends ComponentArgument<Array<T>> {
|
|
4
|
+
item_type: ComponentArgument<T>;
|
|
5
|
+
example_count: number | null;
|
|
6
|
+
constructor(item_type: ComponentArgument<T>, example_count?: number | null);
|
|
6
7
|
getTypeName(): string;
|
|
7
8
|
getEmptyValue(): never[];
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
getExampleCount(): number;
|
|
10
|
+
getExampleValue(context: JDDContext): Promise<T[]>;
|
|
11
|
+
countWords(value: Array<T>): number;
|
|
12
|
+
parseFormInput(context: JDDContext, input: unknown, arg_name: string): Promise<T[] | null>;
|
|
10
13
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { JDDContext } from "../jdd-context";
|
|
2
|
+
import { MaybePromise } from "../utils/util-types";
|
|
1
3
|
import { ComponentArgument } from "./component-argument";
|
|
2
4
|
export declare class MarkdownArgument extends ComponentArgument<string> {
|
|
3
5
|
getTypeName(): string;
|
|
4
6
|
getEmptyValue(): string;
|
|
5
7
|
countWords(value: string): number;
|
|
6
8
|
example_values: string[];
|
|
9
|
+
parseFormInput(_: JDDContext, input: unknown): MaybePromise<string | string[] | null>;
|
|
7
10
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { JDDContext } from "..";
|
|
2
|
+
import { MaybePromise } from "../utils/util-types";
|
|
1
3
|
import { ComponentArgument } from "./component-argument";
|
|
2
4
|
export declare class ShortText extends ComponentArgument<string> {
|
|
3
5
|
example_values: string[];
|
|
4
6
|
getTypeName(): string;
|
|
5
7
|
getEmptyValue(): string;
|
|
6
8
|
countWords(value: string): number;
|
|
9
|
+
parseFormInput(_: JDDContext, input: unknown): MaybePromise<string | string[] | null>;
|
|
7
10
|
}
|
|
@@ -11,4 +11,7 @@ export declare class Structured<T extends Record<string, ComponentArgument<unkno
|
|
|
11
11
|
}): number;
|
|
12
12
|
getEmptyValue(): { [property in keyof T]: ExtractComponentArgumentValue<T[property]>; };
|
|
13
13
|
getExampleValue(context: JDDContext): Promise<{ [property in keyof T]: ExtractComponentArgumentValue<T[property]>; }>;
|
|
14
|
+
parseFormInput<SingleObject extends {
|
|
15
|
+
[property in keyof T]: ExtractComponentArgumentValue<T[property]>;
|
|
16
|
+
}>(context: JDDContext, input: unknown, arg_name: string): Promise<SingleObject | SingleObject[] | null>;
|
|
14
17
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { JDDContext } from "..";
|
|
2
|
+
import { ComponentArgument } from "./component-argument";
|
|
3
|
+
type TableHeader<HeaderType> = {
|
|
4
|
+
type: "header";
|
|
5
|
+
header_content: HeaderType;
|
|
6
|
+
};
|
|
7
|
+
type TableRegularRow<CellType> = {
|
|
8
|
+
type: "row";
|
|
9
|
+
cells: CellType[];
|
|
10
|
+
};
|
|
11
|
+
export type TableRow<CellType, HeaderType> = TableHeader<HeaderType> | TableRegularRow<CellType>;
|
|
12
|
+
export type TableData<CellType, HeaderType> = {
|
|
13
|
+
rows: TableRow<CellType, HeaderType>[];
|
|
14
|
+
};
|
|
15
|
+
export declare function isTableHeader(x: unknown): x is TableHeader<unknown>;
|
|
16
|
+
export declare function isTableRegularRow<CellType = unknown>(x: unknown): x is TableRegularRow<CellType>;
|
|
17
|
+
export declare function isTableData<CellType = unknown, HeaderType = unknown>(x: unknown): x is TableData<CellType, HeaderType>;
|
|
18
|
+
export declare class Table<CellType, HeaderType> extends ComponentArgument<TableData<CellType, HeaderType>> {
|
|
19
|
+
header_type: ComponentArgument<HeaderType>;
|
|
20
|
+
cell_type: ComponentArgument<CellType>;
|
|
21
|
+
constructor(header_type: ComponentArgument<HeaderType>, cell_type: ComponentArgument<CellType>);
|
|
22
|
+
getTypeName(): string;
|
|
23
|
+
getEmptyValue(): {
|
|
24
|
+
rows: ({
|
|
25
|
+
type: "header";
|
|
26
|
+
header_content: HeaderType;
|
|
27
|
+
cells?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
type: "row";
|
|
30
|
+
cells: CellType[];
|
|
31
|
+
header_content?: undefined;
|
|
32
|
+
})[];
|
|
33
|
+
};
|
|
34
|
+
getExampleValue(context: JDDContext): Promise<TableData<CellType, HeaderType>>;
|
|
35
|
+
countWords(value: TableData<CellType, HeaderType>): number;
|
|
36
|
+
parseFormInput(context: JDDContext, input: unknown, arg_name: string): Promise<TableData<CellType, HeaderType> | TableData<CellType, HeaderType>[] | null>;
|
|
37
|
+
getColumnsCount(value: TableData<CellType, HeaderType>): number;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
package/@types/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { JDDContext } from "./jdd-context";
|
|
|
3
3
|
import { Registry } from "./registry";
|
|
4
4
|
export * from "./component";
|
|
5
5
|
export * from "./component-arguments/component-argument";
|
|
6
|
-
export * from "./component-arguments/component-arguments";
|
|
7
6
|
export * as ComponentArguments from "./component-arguments/component-arguments";
|
|
7
|
+
export * from "./component-arguments/component-arguments";
|
|
8
8
|
export * from "./jdd-context";
|
|
9
9
|
export * from "./registry";
|
|
10
10
|
export { insert_nbsp } from "./utils/insert_nbsp";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MaybePromise<T> = Promise<T> | T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type MaybePromise<T> = Promise<T> | T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-argument.js","sourceRoot":"","sources":["../../src/component-arguments/component-argument.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"component-argument.js","sourceRoot":"","sources":["../../src/component-arguments/component-argument.ts"],"names":[],"mappings":";;;AAaA,MAAsB,iBAAiB;IAAvC;QACQ,mBAAc,GAAU,EAAE,CAAC;QAC3B,oBAAe,GAAsC,IAAI,CAAC;IA+BlE,CAAC;IArBA,eAAe,CAAC,QAAoB;QACnC,OAAO,IAAI,CAAC,cAAc,CACzB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CACtD,CAAC;IACH,CAAC;IAED,gBAAgB,CAAC,MAAa;QAC7B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,SAAS,CAAC,IAAY;QACrB,IAAI,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC;QAClC,OAAO,MAAM,EAAE;YACd,IAAI,MAAM,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE;gBACjC,OAAO,IAAI,CAAC;aACZ;YACD,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC;SAChC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAjCD,8CAiCC"}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.Structured = exports.ShortText = exports.Markdown = exports.List = exports.File = exports.Image = exports.Enum = void 0;
|
|
4
18
|
var enum_1 = require("./enum");
|
|
@@ -15,4 +29,5 @@ var short_text_1 = require("./short-text");
|
|
|
15
29
|
Object.defineProperty(exports, "ShortText", { enumerable: true, get: function () { return short_text_1.ShortText; } });
|
|
16
30
|
var structured_1 = require("./structured");
|
|
17
31
|
Object.defineProperty(exports, "Structured", { enumerable: true, get: function () { return structured_1.Structured; } });
|
|
32
|
+
__exportStar(require("./table"), exports);
|
|
18
33
|
//# sourceMappingURL=component-arguments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-arguments.js","sourceRoot":"","sources":["../../src/component-arguments/component-arguments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component-arguments.js","sourceRoot":"","sources":["../../src/component-arguments/component-arguments.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,uCAA0D;AAAjD,oGAAA,gBAAgB,OAAY;AACrC,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,0CAAwB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Enum = void 0;
|
|
4
|
+
const ts_predicates_1 = require("@sealcode/ts-predicates");
|
|
4
5
|
const component_argument_1 = require("./component-argument");
|
|
5
6
|
class Enum extends component_argument_1.ComponentArgument {
|
|
6
7
|
constructor(values) {
|
|
@@ -19,6 +20,16 @@ class Enum extends component_argument_1.ComponentArgument {
|
|
|
19
20
|
countWords() {
|
|
20
21
|
return 0;
|
|
21
22
|
}
|
|
23
|
+
parseFormInput(_, input) {
|
|
24
|
+
if ((0, ts_predicates_1.is)(input, ts_predicates_1.predicates.string) &&
|
|
25
|
+
((0, ts_predicates_1.is)(input, ts_predicates_1.predicates.enum(this.values)) ||
|
|
26
|
+
(0, ts_predicates_1.is)(input.trim(), ts_predicates_1.predicates.enum(this.values)))) {
|
|
27
|
+
return input.trim();
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
22
33
|
}
|
|
23
34
|
exports.Enum = Enum;
|
|
24
35
|
//# sourceMappingURL=enum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/component-arguments/enum.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/component-arguments/enum.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AACzD,6DAAyD;AAGzD,MAAa,IAAuB,SAAQ,sCAAoB;IAE/D,YAAY,MAAqB;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED,WAAW;QACV,OAAO,MAAM,CAAC;IACf,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,eAAe;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,UAAU;QACT,OAAO,CAAC,CAAC;IACV,CAAC;IAED,cAAc,CAAC,CAAa,EAAE,KAA8B;QAC3D,IACC,IAAA,kBAAE,EAAC,KAAK,EAAE,0BAAU,CAAC,MAAM,CAAC;YAC5B,CAAC,IAAA,kBAAE,EAAC,KAAK,EAAE,0BAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvC,IAAA,kBAAE,EAAC,KAAK,CAAC,IAAI,EAAE,EAAE,0BAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAC/C;YACD,OAAO,KAAK,CAAC,IAAI,EAAO,CAAC;SACzB;aAAM;YACN,OAAO,IAAI,CAAC;SACZ;IACF,CAAC;CACD;AAlCD,oBAkCC"}
|
|
@@ -9,8 +9,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.File = void 0;
|
|
12
|
+
exports.File = exports.encodeSealiousFile = void 0;
|
|
13
|
+
const ts_predicates_1 = require("@sealcode/ts-predicates");
|
|
13
14
|
const component_argument_1 = require("./component-argument");
|
|
15
|
+
function isSealiousFile(x) {
|
|
16
|
+
return (0, ts_predicates_1.hasShape)({
|
|
17
|
+
getDataPath: ts_predicates_1.predicates.any,
|
|
18
|
+
data: ts_predicates_1.predicates.shape({ path: ts_predicates_1.predicates.string }),
|
|
19
|
+
}, x);
|
|
20
|
+
}
|
|
21
|
+
function encodeSealiousFile(context, maybe_file) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
if (isSealiousFile(maybe_file)) {
|
|
24
|
+
return context.encode_file({
|
|
25
|
+
type: "path",
|
|
26
|
+
// asserting that this is an instance of sealious' FileFromPath
|
|
27
|
+
path: maybe_file.data.path,
|
|
28
|
+
}, false);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.encodeSealiousFile = encodeSealiousFile;
|
|
14
36
|
class File extends component_argument_1.ComponentArgument {
|
|
15
37
|
constructor() {
|
|
16
38
|
super();
|
|
@@ -29,6 +51,29 @@ class File extends component_argument_1.ComponentArgument {
|
|
|
29
51
|
countWords() {
|
|
30
52
|
return 0;
|
|
31
53
|
}
|
|
54
|
+
parseFormInput(context, input) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (!(0, ts_predicates_1.hasShape)({
|
|
57
|
+
new: ts_predicates_1.predicates.maybe(ts_predicates_1.predicates.array(ts_predicates_1.predicates.object)),
|
|
58
|
+
old: ts_predicates_1.predicates.string,
|
|
59
|
+
}, input)) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const files = (input.new || []).filter((e) => e);
|
|
63
|
+
if (files.length == 0) {
|
|
64
|
+
return input.old;
|
|
65
|
+
}
|
|
66
|
+
else if (files.length == 1) {
|
|
67
|
+
return encodeSealiousFile(context, files[0]);
|
|
68
|
+
}
|
|
69
|
+
else if (this.hasParent("list")) {
|
|
70
|
+
return (yield Promise.all(files.map((file) => encodeSealiousFile(context, file)))).filter((e) => e !== null);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
32
77
|
}
|
|
33
78
|
exports.File = File;
|
|
34
79
|
//# sourceMappingURL=file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/component-arguments/file.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/component-arguments/file.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAA+D;AAE/D,6DAAyD;AAEzD,SAAS,cAAc,CAAC,CAAU;IACjC,OAAO,IAAA,wBAAQ,EACd;QACC,WAAW,EAAE,0BAAU,CAAC,GAAG;QAC3B,IAAI,EAAE,0BAAU,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,0BAAU,CAAC,MAAM,EAAE,CAAC;KACnD,EACD,CAAC,CACD,CAAC;AACH,CAAC;AAED,SAAsB,kBAAkB,CACvC,OAAmB,EACnB,UAAmC;;QAEnC,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE;YAC/B,OAAO,OAAO,CAAC,WAAW,CACzB;gBACC,IAAI,EAAE,MAAM;gBACZ,+DAA+D;gBAC/D,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI;aAC1B,EACD,KAAK,CACL,CAAC;SACF;aAAM;YACN,OAAO,IAAI,CAAC;SACZ;IACF,CAAC;CAAA;AAhBD,gDAgBC;AAED,MAAa,IAAK,SAAQ,sCAAgC;IACzD;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAED,WAAW;QACV,OAAO,MAAM,CAAC;IACf,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;IAEK,eAAe,CAAC,QAAoB;;YACzC,OAAO,EAAE,CAAC;QACX,CAAC;KAAA;IAED,UAAU;QACT,OAAO,CAAC,CAAC;IACV,CAAC;IAEK,cAAc,CACnB,OAAmB,EACnB,KAAc;;YAEd,IACC,CAAC,IAAA,wBAAQ,EACR;gBACC,GAAG,EAAE,0BAAU,CAAC,KAAK,CAAC,0BAAU,CAAC,KAAK,CAAC,0BAAU,CAAC,MAAM,CAAC,CAAC;gBAC1D,GAAG,EAAE,0BAAU,CAAC,MAAM;aACtB,EACD,KAAK,CACL,EACA;gBACD,OAAO,IAAI,CAAC;aACZ;YACD,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;YACjD,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;gBACtB,OAAO,KAAK,CAAC,GAAG,CAAC;aACjB;iBAAM,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;gBAC7B,OAAO,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAC7C;iBAAM,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;gBAClC,OAAO,CACN,MAAM,OAAO,CAAC,GAAG,CAChB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CACtD,CACD,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAa,CAAC;aACxC;iBAAM;gBACN,OAAO,IAAI,CAAC;aACZ;QACF,CAAC;KAAA;CACD;AAnDD,oBAmDC"}
|
|
@@ -16,27 +16,33 @@ exports.Image = void 0;
|
|
|
16
16
|
const locreq_1 = __importDefault(require("locreq"));
|
|
17
17
|
const file_1 = require("./file");
|
|
18
18
|
const locreq = (0, locreq_1.default)(__dirname);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"image5.jpg": null,
|
|
24
|
-
};
|
|
19
|
+
const default_example_image_promises = Object.fromEntries(["image1.jpg", "image3.jpg", "image4.jpg", "image5.jpg"].map((key) => [
|
|
20
|
+
locreq.resolve(`resources/${key}`),
|
|
21
|
+
null,
|
|
22
|
+
]));
|
|
25
23
|
class Image extends file_1.File {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.example_image_promises = default_example_image_promises;
|
|
27
|
+
}
|
|
26
28
|
getTypeName() {
|
|
27
29
|
return "image";
|
|
28
30
|
}
|
|
31
|
+
setExampleImages(paths) {
|
|
32
|
+
this.example_image_promises = Object.fromEntries(paths.map((path) => [path, null]));
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
29
35
|
getExampleValue(context) {
|
|
30
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const keys = Object.keys(example_image_promises);
|
|
37
|
+
const keys = Object.keys(this.example_image_promises);
|
|
32
38
|
const key = keys[Math.floor(Math.random() * keys.length)];
|
|
33
|
-
if (!example_image_promises[key]) {
|
|
34
|
-
example_image_promises[key] = context.encode_file({
|
|
39
|
+
if (!this.example_image_promises[key]) {
|
|
40
|
+
this.example_image_promises[key] = context.encode_file({
|
|
35
41
|
type: "path",
|
|
36
|
-
path:
|
|
42
|
+
path: key,
|
|
37
43
|
}, true);
|
|
38
44
|
}
|
|
39
|
-
return example_image_promises[key];
|
|
45
|
+
return this.example_image_promises[key];
|
|
40
46
|
});
|
|
41
47
|
}
|
|
42
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/component-arguments/image.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA6B;AAE7B,iCAA8C;AAC9C,MAAM,MAAM,GAAG,IAAA,gBAAO,EAAC,SAAS,CAAC,CAAC;AAElC,
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/component-arguments/image.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;A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,sBA4BC"}
|
|
@@ -10,11 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.List = void 0;
|
|
13
|
+
const ts_predicates_1 = require("@sealcode/ts-predicates");
|
|
13
14
|
const component_argument_1 = require("./component-argument");
|
|
14
15
|
class List extends component_argument_1.ComponentArgument {
|
|
15
|
-
constructor(item_type) {
|
|
16
|
+
constructor(item_type, example_count = null) {
|
|
16
17
|
super();
|
|
17
18
|
this.item_type = item_type;
|
|
19
|
+
this.example_count = example_count;
|
|
18
20
|
item_type.parent_argument = this;
|
|
19
21
|
}
|
|
20
22
|
getTypeName() {
|
|
@@ -23,6 +25,14 @@ class List extends component_argument_1.ComponentArgument {
|
|
|
23
25
|
getEmptyValue() {
|
|
24
26
|
return [];
|
|
25
27
|
}
|
|
28
|
+
getExampleCount() {
|
|
29
|
+
if (this.example_count === null) {
|
|
30
|
+
return Math.floor(Math.random() * 5);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return this.example_count;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
26
36
|
getExampleValue(context) {
|
|
27
37
|
const _super = Object.create(null, {
|
|
28
38
|
getExampleValue: { get: () => super.getExampleValue }
|
|
@@ -32,18 +42,35 @@ class List extends component_argument_1.ComponentArgument {
|
|
|
32
42
|
return _super.getExampleValue.call(this, context);
|
|
33
43
|
}
|
|
34
44
|
else {
|
|
35
|
-
const count =
|
|
45
|
+
const count = this.getExampleCount();
|
|
36
46
|
const result = [];
|
|
37
47
|
for (let i = 0; i < count; i++) {
|
|
38
48
|
result.push(this.item_type.getExampleValue(context));
|
|
39
49
|
}
|
|
40
|
-
return Promise.all(result);
|
|
50
|
+
return (yield Promise.all(result));
|
|
41
51
|
}
|
|
42
52
|
});
|
|
43
53
|
}
|
|
44
54
|
countWords(value) {
|
|
45
55
|
return value.reduce((acc, item) => acc + this.item_type.countWords(item), 0);
|
|
46
56
|
}
|
|
57
|
+
parseFormInput(context, input, arg_name) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
if (!(0, ts_predicates_1.is)(input, ts_predicates_1.predicates.array(ts_predicates_1.predicates.object)) &&
|
|
60
|
+
!(0, ts_predicates_1.is)(input, ts_predicates_1.predicates.object)) {
|
|
61
|
+
throw new Error(`$.${arg_name} is not a list or object`);
|
|
62
|
+
}
|
|
63
|
+
const values = Array.isArray(input) ? input : Object.values(input);
|
|
64
|
+
let array_result = yield Promise.all(values.map((value, index) => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const result = yield this.item_type.parseFormInput(context, value, `${arg_name}[${index}]`);
|
|
66
|
+
return result;
|
|
67
|
+
})));
|
|
68
|
+
if (this.item_type.getTypeName() != "list") {
|
|
69
|
+
array_result = array_result.flat();
|
|
70
|
+
}
|
|
71
|
+
return array_result.filter((e) => e !== null);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
47
74
|
}
|
|
48
75
|
exports.List = List;
|
|
49
76
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/component-arguments/list.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/component-arguments/list.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAyD;AAGzD,6DAAyD;AAEzD,MAAa,IAAQ,SAAQ,sCAA2B;IACvD,YACQ,SAA+B,EAC/B,gBAA+B,IAAI;QAE1C,KAAK,EAAE,CAAC;QAHD,cAAS,GAAT,SAAS,CAAsB;QAC/B,kBAAa,GAAb,aAAa,CAAsB;QAG1C,SAAS,CAAC,eAAe,GAAG,IAAI,CAAC;IAClC,CAAC;IAED,WAAW;QACV,OAAO,MAAM,CAAC;IACf,CAAC;IAED,aAAa;QACZ,OAAO,EAAE,CAAC;IACX,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M,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnE,IAAI,YAAY,GAA0B,MAAM,OAAO,CAAC,GAAG,CAC1D,MAAM,CAAC,GAAG,CAAC,CAAO,KAAK,EAAE,KAAK,EAAE,EAAE;gBACjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,CACjD,OAAO,EACP,KAAK,EACL,GAAG,QAAQ,IAAI,KAAK,GAAG,CACvB,CAAC;gBACF,OAAO,MAAM,CAAC;YACf,CAAC,CAAA,CAAC,CACF,CAAC;YACF,IAAI,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,MAAM,EAAE;gBAC3C,YAAY,GAAG,YAAY,CAAC,IAAI,EAAS,CAAC;aAC1C;YACD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAQ,CAAC;QACtD,CAAC;KAAA;CACD;AAxED,oBAwEC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MarkdownArgument = void 0;
|
|
4
|
+
const ts_predicates_1 = require("@sealcode/ts-predicates");
|
|
4
5
|
const component_argument_1 = require("./component-argument");
|
|
5
6
|
class MarkdownArgument extends component_argument_1.ComponentArgument {
|
|
6
7
|
constructor() {
|
|
@@ -25,6 +26,14 @@ Pulvinar neque laoreet suspendisse interdum consectetur. Orci phasellus egestas
|
|
|
25
26
|
countWords(value) {
|
|
26
27
|
return value.toString().split(" ").length;
|
|
27
28
|
}
|
|
29
|
+
parseFormInput(_, input) {
|
|
30
|
+
if ((0, ts_predicates_1.is)(input, ts_predicates_1.predicates.string)) {
|
|
31
|
+
return input;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
28
37
|
}
|
|
29
38
|
exports.MarkdownArgument = MarkdownArgument;
|
|
30
39
|
//# sourceMappingURL=markdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/component-arguments/markdown.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AAEzD,MAAa,gBAAiB,SAAQ,sCAAyB;IAA/D;;QAaC,mBAAc,GAAG;YAChB;;oaAEka;YACla;;;;sGAIoG;SACpG,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/component-arguments/markdown.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAGzD,6DAAyD;AAEzD,MAAa,gBAAiB,SAAQ,sCAAyB;IAA/D;;QAaC,mBAAc,GAAG;YAChB;;oaAEka;YACla;;;;sGAIoG;SACpG,CAAC;IAYH,CAAC;IAjCA,WAAW;QACV,OAAO,UAAU,CAAC;IACnB,CAAC;IAED,aAAa;QACZ,OAAO,EAAE,CAAC;IACX,CAAC;IAED,UAAU,CAAC,KAAa;QACvB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,CAAC;IAaD,cAAc,CACb,CAAa,EACb,KAAc;QAEd,IAAI,IAAA,kBAAE,EAAC,KAAK,EAAE,0BAAU,CAAC,MAAM,CAAC,EAAE;YACjC,OAAO,KAAK,CAAC;SACb;aAAM;YACN,OAAO,IAAI,CAAC;SACZ;IACF,CAAC;CACD;AAlCD,4CAkCC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ShortText = void 0;
|
|
4
|
+
const ts_predicates_1 = require("@sealcode/ts-predicates");
|
|
4
5
|
const component_argument_1 = require("./component-argument");
|
|
5
6
|
class ShortText extends component_argument_1.ComponentArgument {
|
|
6
7
|
constructor() {
|
|
7
8
|
super(...arguments);
|
|
8
9
|
this.example_values = [
|
|
9
10
|
"Lorem ipsum set doloris",
|
|
10
|
-
"Main
|
|
11
|
+
"Main hippopotomonsti delos muertos",
|
|
11
12
|
"Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore",
|
|
12
13
|
"Ipsum",
|
|
13
14
|
];
|
|
@@ -21,6 +22,14 @@ class ShortText extends component_argument_1.ComponentArgument {
|
|
|
21
22
|
countWords(value) {
|
|
22
23
|
return value.toString().split(" ").length;
|
|
23
24
|
}
|
|
25
|
+
parseFormInput(_, input) {
|
|
26
|
+
if ((0, ts_predicates_1.is)(input, ts_predicates_1.predicates.string)) {
|
|
27
|
+
return input;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
24
33
|
}
|
|
25
34
|
exports.ShortText = ShortText;
|
|
26
35
|
//# sourceMappingURL=short-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"short-text.js","sourceRoot":"","sources":["../../src/component-arguments/short-text.ts"],"names":[],"mappings":";;;AAAA,6DAAyD;AAEzD,MAAa,SAAU,SAAQ,sCAAyB;IAAxD;;QACC,mBAAc,GAAG;YAChB,yBAAyB;YACzB,
|
|
1
|
+
{"version":3,"file":"short-text.js","sourceRoot":"","sources":["../../src/component-arguments/short-text.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAGzD,6DAAyD;AAEzD,MAAa,SAAU,SAAQ,sCAAyB;IAAxD;;QACC,mBAAc,GAAG;YAChB,yBAAyB;YACzB,oCAAoC;YACpC,yEAAyE;YACzE,OAAO;SACP,CAAC;IAwBH,CAAC;IAtBA,WAAW;QACV,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,aAAa;QACZ,OAAO,EAAE,CAAC;IACX,CAAC;IAED,UAAU,CAAC,KAAa;QACvB,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,CAAC;IAED,cAAc,CACb,CAAa,EACb,KAAc;QAEd,IAAI,IAAA,kBAAE,EAAC,KAAK,EAAE,0BAAU,CAAC,MAAM,CAAC,EAAE;YACjC,OAAO,KAAK,CAAC;SACb;aAAM;YACN,OAAO,IAAI,CAAC;SACZ;IACF,CAAC;CACD;AA9BD,8BA8BC"}
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Structured = void 0;
|
|
13
|
+
const ts_predicates_1 = require("@sealcode/ts-predicates");
|
|
13
14
|
const component_argument_1 = require("./component-argument");
|
|
14
15
|
class Structured extends component_argument_1.ComponentArgument {
|
|
15
16
|
constructor(structure) {
|
|
@@ -45,6 +46,50 @@ class Structured extends component_argument_1.ComponentArgument {
|
|
|
45
46
|
}))));
|
|
46
47
|
});
|
|
47
48
|
}
|
|
49
|
+
parseFormInput(context, input, arg_name) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
if (!(0, ts_predicates_1.is)(input, ts_predicates_1.predicates.object)) {
|
|
52
|
+
throw new Error(`${arg_name} is not an object`);
|
|
53
|
+
}
|
|
54
|
+
const result = {};
|
|
55
|
+
yield Promise.all(Object.entries(input).map(([obj_key, obj_value]) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const nested_arg_type = this.structure[obj_key];
|
|
57
|
+
if (!nested_arg_type) {
|
|
58
|
+
return [obj_key, null];
|
|
59
|
+
}
|
|
60
|
+
const new_value = yield nested_arg_type.parseFormInput(context, obj_value, `${arg_name}[${obj_key}]`);
|
|
61
|
+
result[obj_key] = new_value;
|
|
62
|
+
})));
|
|
63
|
+
// if we're in a list and any of the values return an array, we will multiply the object
|
|
64
|
+
if (this.hasParent("list")) {
|
|
65
|
+
const keys_with_unexpected_arrays = Object.entries(result)
|
|
66
|
+
.filter(([key, value]) => {
|
|
67
|
+
const nested_arg_type = this.structure[key];
|
|
68
|
+
return (nested_arg_type.getTypeName() !== "list" &&
|
|
69
|
+
Array.isArray(value));
|
|
70
|
+
})
|
|
71
|
+
.map(([key]) => key);
|
|
72
|
+
if (keys_with_unexpected_arrays.length > 1) {
|
|
73
|
+
throw new Error("Multiplying on more than one field at the same time is not implemented yet");
|
|
74
|
+
}
|
|
75
|
+
if (keys_with_unexpected_arrays.length == 1) {
|
|
76
|
+
const key = keys_with_unexpected_arrays[0];
|
|
77
|
+
const old_result = result;
|
|
78
|
+
const array = old_result[key];
|
|
79
|
+
if (!Array.isArray(array)) {
|
|
80
|
+
throw new Error("expected an array");
|
|
81
|
+
}
|
|
82
|
+
return array.map((value) => (Object.assign(Object.assign({}, old_result), { [key]: value })));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
48
93
|
}
|
|
49
94
|
exports.Structured = Structured;
|
|
50
95
|
//# sourceMappingURL=structured.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured.js","sourceRoot":"","sources":["../../src/component-arguments/structured.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"structured.js","sourceRoot":"","sources":["../../src/component-arguments/structured.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAyD;AAGzD,6DAG8B;AAE9B,MAAa,UAEX,SAAQ,sCAER;IACD,YAAmB,SAAY;QAC9B,KAAK,EAAE,CAAC;QADU,cAAS,GAAT,SAAS,CAAG;QAE9B,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,eAAe,GAAG,IA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B,CAAC,MAAM,IAAI,CAAC,EAAE;oBAC5C,MAAM,GAAG,GAAG,2BAA2B,CAAC,CAAC,CAAC,CAAC;oBAC3C,MAAM,UAAU,GAAG,MAAM,CAAC;oBAC1B,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;oBAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;wBAC1B,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;qBACrC;oBAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,iCACjC,UAAU,KACb,CAAC,GAAG,CAAC,EAAE,KAAK,IACX,CAAmB,CAAC;iBACtB;qBAAM;oBACN,OAAO,MAAsB,CAAC;iBAC9B;aACD;iBAAM;gBACN,OAAO,MAAsB,CAAC;aAC9B;QACF,CAAC;KAAA;CACD;AApHD,gCAoHC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Table = exports.isTableData = exports.isTableRegularRow = exports.isTableHeader = void 0;
|
|
13
|
+
const ts_predicates_1 = require("@sealcode/ts-predicates");
|
|
14
|
+
const component_argument_1 = require("./component-argument");
|
|
15
|
+
function isTableHeader(x) {
|
|
16
|
+
return (0, ts_predicates_1.hasShape)({
|
|
17
|
+
type: ts_predicates_1.predicates.const("header"),
|
|
18
|
+
header_content: ts_predicates_1.predicates.unknown,
|
|
19
|
+
}, x);
|
|
20
|
+
}
|
|
21
|
+
exports.isTableHeader = isTableHeader;
|
|
22
|
+
function isTableRegularRow(x) {
|
|
23
|
+
return (0, ts_predicates_1.hasShape)({
|
|
24
|
+
type: ts_predicates_1.predicates.const("row"),
|
|
25
|
+
cells: ts_predicates_1.predicates.array(ts_predicates_1.predicates.unknown),
|
|
26
|
+
}, x);
|
|
27
|
+
}
|
|
28
|
+
exports.isTableRegularRow = isTableRegularRow;
|
|
29
|
+
function isTableData(x) {
|
|
30
|
+
return (0, ts_predicates_1.hasShape)({
|
|
31
|
+
rows: ts_predicates_1.predicates.array(ts_predicates_1.predicates.object),
|
|
32
|
+
}, x);
|
|
33
|
+
}
|
|
34
|
+
exports.isTableData = isTableData;
|
|
35
|
+
class Table extends component_argument_1.ComponentArgument {
|
|
36
|
+
constructor(header_type, cell_type) {
|
|
37
|
+
super();
|
|
38
|
+
this.header_type = header_type;
|
|
39
|
+
this.cell_type = cell_type;
|
|
40
|
+
cell_type.parent_argument = this;
|
|
41
|
+
header_type.parent_argument = this;
|
|
42
|
+
}
|
|
43
|
+
getTypeName() {
|
|
44
|
+
return "table";
|
|
45
|
+
}
|
|
46
|
+
getEmptyValue() {
|
|
47
|
+
return {
|
|
48
|
+
rows: [
|
|
49
|
+
{
|
|
50
|
+
type: "header",
|
|
51
|
+
header_content: this.header_type.getEmptyValue(),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: "row",
|
|
55
|
+
cells: [this.cell_type.getEmptyValue()],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
getExampleValue(context) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const rows = Math.round(Math.random() * 5);
|
|
63
|
+
const columns = Math.round(Math.random() * 5);
|
|
64
|
+
const result = {
|
|
65
|
+
rows: [
|
|
66
|
+
{
|
|
67
|
+
type: "header",
|
|
68
|
+
header_content: yield this.header_type.getExampleValue(context),
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
for (let i = 0; i < rows; i++) {
|
|
73
|
+
const cells = [];
|
|
74
|
+
for (let j = 0; j < columns; j++) {
|
|
75
|
+
cells.push(yield this.cell_type.getExampleValue(context));
|
|
76
|
+
}
|
|
77
|
+
result.rows.push({ type: "row", cells });
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
countWords(value) {
|
|
83
|
+
let result = 0;
|
|
84
|
+
for (let i = 0; i < value.rows.length; i++) {
|
|
85
|
+
const row = value.rows[i];
|
|
86
|
+
if (isTableHeader(row)) {
|
|
87
|
+
result += this.header_type.countWords(row.header_content);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
for (let j = 0; j < row.cells.length; j++) {
|
|
91
|
+
result += this.cell_type.countWords(row.cells[j]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
parseFormInput(context, input, arg_name) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
if (!(0, ts_predicates_1.hasShape)({ rows: ts_predicates_1.predicates.array(ts_predicates_1.predicates.object) }, input)) {
|
|
100
|
+
return { rows: [] };
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const result = { rows: [] };
|
|
104
|
+
const row_promises = input.rows.map((row, row_index) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
let new_row;
|
|
106
|
+
if ((0, ts_predicates_1.hasShape)({ header_content: ts_predicates_1.predicates.unknown }, row)) {
|
|
107
|
+
let header_content = yield this.header_type.parseFormInput(context, row.header_content, `${arg_name}[rows][${row_index}][header_content]`);
|
|
108
|
+
if (Array.isArray(header_content)) {
|
|
109
|
+
header_content = header_content[0];
|
|
110
|
+
}
|
|
111
|
+
if (header_content == null) {
|
|
112
|
+
header_content = this.header_type.getEmptyValue();
|
|
113
|
+
}
|
|
114
|
+
new_row = {
|
|
115
|
+
type: "header",
|
|
116
|
+
header_content,
|
|
117
|
+
};
|
|
118
|
+
result.rows[row_index] = new_row;
|
|
119
|
+
}
|
|
120
|
+
else if ((0, ts_predicates_1.hasShape)({ cells: ts_predicates_1.predicates.array(ts_predicates_1.predicates.unknown) }, row)) {
|
|
121
|
+
new_row = {
|
|
122
|
+
type: "row",
|
|
123
|
+
cells: yield Promise.all(row.cells.map((cell, column_index) => __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
let value = yield this.cell_type.parseFormInput(context, cell, `${arg_name}[rows][${row_index}][cells][${column_index}]`);
|
|
125
|
+
if (value === null) {
|
|
126
|
+
return this.cell_type.getEmptyValue();
|
|
127
|
+
}
|
|
128
|
+
else if (Array.isArray(value)) {
|
|
129
|
+
return value[0];
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
}))),
|
|
135
|
+
};
|
|
136
|
+
result.rows[row_index] = new_row;
|
|
137
|
+
}
|
|
138
|
+
}));
|
|
139
|
+
yield Promise.all(row_promises);
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
getColumnsCount(value) {
|
|
145
|
+
var _a;
|
|
146
|
+
return ((((_a = value.rows.filter((row) => row.type == "row")[0]) === null || _a === void 0 ? void 0 : _a.cells) || []).length || 1);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.Table = Table;
|
|
150
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/component-arguments/table.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAmE;AAEnE,6DAAy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ib/index.js
CHANGED
|
@@ -30,8 +30,8 @@ exports.render = exports.countWords = exports.insert_nbsp = exports.ComponentArg
|
|
|
30
30
|
const tempstream_1 = require("tempstream");
|
|
31
31
|
__exportStar(require("./component"), exports);
|
|
32
32
|
__exportStar(require("./component-arguments/component-argument"), exports);
|
|
33
|
-
__exportStar(require("./component-arguments/component-arguments"), exports); // exporting this also as root elements to make it easier to auto-import those
|
|
34
33
|
exports.ComponentArguments = __importStar(require("./component-arguments/component-arguments"));
|
|
34
|
+
__exportStar(require("./component-arguments/component-arguments"), exports); // exporting this also as root elements to make it easier to auto-import those
|
|
35
35
|
__exportStar(require("./jdd-context"), exports);
|
|
36
36
|
__exportStar(require("./registry"), exports);
|
|
37
37
|
var insert_nbsp_1 = require("./utils/insert_nbsp");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AAKxC,8CAA4B;AAC5B,2EAAyD;AACzD,4EAA0D,CAAC,8EAA8E;AACzI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AAKxC,8CAA4B;AAC5B,2EAAyD;AACzD,gGAAgF;AAChF,4EAA0D,CAAC,8EAA8E;AACzI,gDAA8B;AAC9B,6CAA2B;AAC3B,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AAOpB,SAAgB,UAAU,CAAC,QAAkB,EAAE,QAAoB;IAClE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,EAAE,EAAE;QACxD,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,EAAE;YACf,OAAO,CAAC,IAAI,CACX,uCAAuC,GAAG,cAAc,CACxD,CAAC;YACF,OAAO,GAAG,GAAG,CAAC,CAAC;SACf;QAED,OAAO,GAAG,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC,EAAE,CAAC,CAAC,CAAC;AACP,CAAC;AAZD,gCAYC;AAED,SAAgB,MAAM,CACrB,QAAkB,EAClB,QAAoB,EACpB,OAAmB;IAEnB,OAAO,IAAA,uBAAU,EAAA,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,EAAE,EAAE;;QAC7D,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,EAAE;YACf,OAAO,CAAC,IAAI,CACX,uCAAuC,GAAG,cAAc,CACxD,CAAC;YACF,OAAO,EAAE,CAAC;SACV;QACD,KAAK,MAAM,QAAQ,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,YAAY,EAAE,EAAE;YACjD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE;gBAC1D,IAAI,CAAC,QAAQ,CAAC,GAAG,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CACvB,YAAY,GACb,QAAQ,CAAC,0CAAE,aAAa,EAAE,CAAC;aAC7B;SACD;QACD,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC,EAAE,CAAC;AACN,CAAC;AAtBD,wBAsBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// sometimes when we're dealing with input from HTTP form data, arrays are
|
|
3
|
+
// treated as objects with string numbers as keys. This is for helping fix that
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.fixArrays = void 0;
|
|
6
|
+
function fixArrays(object, ...keys) {
|
|
7
|
+
const result = Object.assign({}, object);
|
|
8
|
+
keys.forEach((key) => {
|
|
9
|
+
if (key in object && typeof object[key] === "object") {
|
|
10
|
+
result[key] = Object.values(object[key]);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
exports.fixArrays = fixArrays;
|
|
16
|
+
//# sourceMappingURL=fix-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-array.js","sourceRoot":"","sources":["../../src/utils/fix-array.ts"],"names":[],"mappings":";AAAA,0EAA0E;AAC1E,+EAA+E;;;AAE/E,SAAgB,SAAS,CAMvB,MAAS,EAAE,GAAG,IAAY;IAC3B,MAAM,MAAM,GAAG,kBAAK,MAAM,CAA6B,CAAC;IAExD,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACpB,IAAI,GAAG,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE;YACrD,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAC1B,MAAM,CAAC,GAAG,CAA4B,CAChB,CAAC;SACxB;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,MAAgC,CAAC;AACzC,CAAC;AAlBD,8BAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maybepromise.js","sourceRoot":"","sources":["../../src/utils/maybepromise.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util-types.js","sourceRoot":"","sources":["../../src/utils/util-types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sealcode/jdd",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "JSON-Driven Documents",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"types": "./@types/index.d.ts",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@sealcode/ts-predicates": "^0.5.3",
|
|
39
|
-
"koa-responsive-image-router": "^0.2.
|
|
39
|
+
"koa-responsive-image-router": "^0.2.19",
|
|
40
40
|
"locreq": "^2.4.1",
|
|
41
41
|
"marked": "^12.0.0",
|
|
42
42
|
"mime-types": "^2.1.35",
|