@duplojs/lang 0.0.1-beta.5 → 0.0.1-beta.7
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/dist/common/constraint/cast/string.d.ts +6 -2
- package/dist/common/constraint/infer/string.d.ts +3 -2
- package/dist/common/types/json.d.ts +1 -1
- package/dist/dataStructure/constraint/base.cjs +18 -2
- package/dist/dataStructure/constraint/base.d.ts +5 -0
- package/dist/dataStructure/constraint/base.mjs +18 -3
- package/dist/dataStructure/constraint/defaults/index.d.ts +1 -0
- package/dist/dataStructure/constraint/defaults/segmentPath.cjs +13 -0
- package/dist/dataStructure/constraint/defaults/segmentPath.d.ts +10 -0
- package/dist/dataStructure/constraint/defaults/segmentPath.mjs +12 -0
- package/dist/dataStructure/constraint/types/constraints.d.ts +2 -1
- package/dist/dataStructure/helpers/index.d.ts +1 -0
- package/dist/dataStructure/helpers/segmentPath.cjs +7 -0
- package/dist/dataStructure/helpers/segmentPath.d.ts +2 -0
- package/dist/dataStructure/helpers/segmentPath.mjs +7 -0
- package/dist/dataStructure/index.cjs +10 -0
- package/dist/dataStructure/index.mjs +8 -2
- package/dist/modeling/entity/base.d.ts +2 -2
- package/dist/modeling/entity/namespace.cjs +1 -1
- package/dist/modeling/entity/namespace.mjs +2 -2
- package/dist/modeling/index.cjs +2 -2
- package/dist/modeling/index.mjs +3 -3
- package/dist/modeling/newType/helper.cjs +2 -2
- package/dist/modeling/newType/helper.d.ts +1 -1
- package/dist/modeling/newType/helper.mjs +2 -2
- package/dist/modeling/taggedObject/base.cjs +64 -1
- package/dist/modeling/taggedObject/base.d.ts +19 -1
- package/dist/modeling/taggedObject/base.mjs +64 -1
- package/dist/modeling/taggedObject/helper.cjs +7 -2
- package/dist/modeling/taggedObject/helper.d.ts +1 -0
- package/dist/modeling/taggedObject/helper.mjs +7 -2
- package/dist/path/constraints/index.d.ts +2 -1
- package/dist/path/constraints/segment.d.ts +3 -0
- package/dist/path/getBaseName.cjs +3 -1
- package/dist/path/getBaseName.d.ts +2 -2
- package/dist/path/getBaseName.mjs +3 -1
- package/dist/path/getExtensionName.cjs +3 -1
- package/dist/path/getExtensionName.d.ts +2 -2
- package/dist/path/getExtensionName.mjs +3 -1
- package/dist/path/getParentFolderPath.cjs +6 -2
- package/dist/path/getParentFolderPath.d.ts +1 -1
- package/dist/path/getParentFolderPath.mjs +6 -2
- package/dist/path/index.cjs +3 -0
- package/dist/path/index.d.ts +1 -0
- package/dist/path/index.mjs +3 -1
- package/dist/path/isSegment.cjs +6 -0
- package/dist/path/isSegment.d.ts +4 -0
- package/dist/path/isSegment.mjs +6 -0
- package/dist/path/resolveFrom.d.ts +2 -2
- package/dist/path/resolveRelative.d.ts +3 -3
- package/dist/path/types/index.d.ts +2 -0
- package/dist/path/types/isLiteralSegmentPath.d.ts +9 -0
- package/dist/path/types/requireLiteralSegmentPath.d.ts +3 -0
- package/dist/tuple/from.cjs +6 -0
- package/dist/tuple/from.d.ts +8 -0
- package/dist/tuple/from.mjs +6 -0
- package/dist/tuple/index.cjs +6 -1
- package/dist/tuple/index.d.ts +1 -0
- package/dist/tuple/index.mjs +6 -2
- package/package.json +1 -1
|
@@ -9,10 +9,14 @@ export interface ComputeCastConstraintStringRule<GenericValue extends string, Ge
|
|
|
9
9
|
lengthEqual: GenericExpectedConstraint extends DString.LengthEqual<number> ? DCommon.NeverCoalescing<(DString.ComputeLengthEqualCompatibility<GenericValue, GenericExpectedConstraint, unknown> extends infer InferredResult extends CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends CompatibilityConstraintResult<true> ? unknown : CastError<`Impossible to cast on LengthEqual<${InferredResult["to"]}> because constraint LengthEqual<${InferredResult["from"]}> from the value is not equal.`, GenericValue, GenericExpectedConstraint> : never), CastError<"Impossible to cast on LengthEqual because value does not have LengthEqual constraint.", GenericValue, GenericExpectedConstraint>> : never;
|
|
10
10
|
path: DCommon.IsExtends<GenericExpectedConstraint, DPath.Path> extends true ? DCommon.Or<[
|
|
11
11
|
DPath.IsLiteralPath<GenericValue>,
|
|
12
|
-
DCommon.IsExtends<GenericValue, DPath.Path | DPath.Absolute>
|
|
12
|
+
DCommon.IsExtends<GenericValue, DPath.Path | DPath.Absolute | DPath.Segment>
|
|
13
13
|
]> extends true ? unknown : CastError<`Impossible to cast on Path because value ${GenericValue} is not path.`, GenericValue, GenericExpectedConstraint> : never;
|
|
14
14
|
absolutePath: DCommon.IsExtends<GenericExpectedConstraint, DPath.Absolute> extends true ? DCommon.Or<[
|
|
15
15
|
DPath.IsLiteralAbsolutePath<GenericValue>,
|
|
16
16
|
DCommon.IsExtends<GenericValue, DPath.Absolute>
|
|
17
|
-
]> extends true ? unknown : CastError<`Impossible to cast on
|
|
17
|
+
]> extends true ? unknown : CastError<`Impossible to cast on AbsolutePath because value ${GenericValue} is not absolute path.`, GenericValue, GenericExpectedConstraint> : never;
|
|
18
|
+
segment: DCommon.IsExtends<GenericExpectedConstraint, DPath.Segment> extends true ? DCommon.Or<[
|
|
19
|
+
DPath.IsLiteralSegmentPath<GenericValue>,
|
|
20
|
+
DCommon.IsExtends<GenericValue, DPath.Segment>
|
|
21
|
+
]> extends true ? unknown : CastError<`Impossible to cast on SegmentPath because value ${GenericValue} is not segment path.`, GenericValue, GenericExpectedConstraint> : never;
|
|
18
22
|
}
|
|
@@ -5,6 +5,7 @@ export interface ComputeInferConstraintStringRule<GenericInput extends string, G
|
|
|
5
5
|
maxCharacters: DString.ComputeMaxCharactersCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? DString.MaxCharacters<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on MaxCharacters<${InferredResult["to"]}> because constraint MaxCharacters<${InferredResult["from"]}> from the value is more than.`> : never;
|
|
6
6
|
minCharacters: DString.ComputeMinCharactersCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? DString.MinCharacters<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on MinCharacters<${InferredResult["to"]}> because constraint MinCharacters<${InferredResult["from"]}> from the value is less than.`> : never;
|
|
7
7
|
lengthEqual: DString.ComputeLengthEqualCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? DString.LengthEqual<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on LengthEqual<${InferredResult["to"]}> because constraint LengthEqual<${InferredResult["from"]}> from the value is not equal.`> : never;
|
|
8
|
-
path: DCommon.IsExtends<GenericOutput, DPath.Path
|
|
9
|
-
absolutePath: DCommon.IsExtends<GenericOutput, DPath.Absolute> extends true ? DPath.IsLiteralAbsolutePath<GenericInput> extends true ? DPath.Absolute : DCommon.ComputedTypeError<`Impossible to cast on
|
|
8
|
+
path: DCommon.IsExtends<GenericOutput, DPath.Path> extends true ? DPath.IsLiteralPath<GenericInput> extends true ? DPath.Path : DCommon.ComputedTypeError<`Impossible to cast on Path because value ${GenericInput} is not path.`> : never;
|
|
9
|
+
absolutePath: DCommon.IsExtends<GenericOutput, DPath.Absolute> extends true ? DPath.IsLiteralAbsolutePath<GenericInput> extends true ? DPath.Absolute : DCommon.ComputedTypeError<`Impossible to cast on AbsolutePath because value ${GenericInput} is not absolute path.`> : never;
|
|
10
|
+
segment: DCommon.IsExtends<GenericOutput, DPath.Segment> extends true ? DPath.IsLiteralSegmentPath<GenericInput> extends true ? DPath.Segment : DCommon.ComputedTypeError<`Impossible to cast on SegmentPath because value ${GenericInput} is not segment path.`> : never;
|
|
10
11
|
}
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
const require_bindPrototypeMethods = require("../../common/bindPrototypeMethods.cjs");
|
|
1
2
|
const require_simpleClone = require("../../common/simpleClone.cjs");
|
|
2
3
|
//#region scripts/dataStructure/constraint/base.ts
|
|
3
4
|
const constraintKind = require("../kind.cjs").createKind("constraint");
|
|
5
|
+
var ConstraintBase = class ConstraintBase {
|
|
6
|
+
constructor() {}
|
|
7
|
+
static init(params) {
|
|
8
|
+
const self = new ConstraintBase();
|
|
9
|
+
require_bindPrototypeMethods.bindPrototypeMethods(self);
|
|
10
|
+
for (const key in params) self[key] = params[key];
|
|
11
|
+
return self;
|
|
12
|
+
}
|
|
13
|
+
static addToPrototype(prop, value) {
|
|
14
|
+
ConstraintBase.prototype[prop] = typeof value === "function" ? function(...args) {
|
|
15
|
+
return value(this, ...args);
|
|
16
|
+
} : value;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
4
19
|
function createConstraint(kindHandler, createConstructor) {
|
|
5
20
|
const init = (definition, { executeCheck, isAsynchronous }) => {
|
|
6
|
-
const self = {
|
|
21
|
+
const self = ConstraintBase.init({
|
|
7
22
|
definition,
|
|
8
23
|
executeCheck: (data) => executeCheck(self, data),
|
|
9
24
|
isAsynchronous: () => isAsynchronous(self),
|
|
@@ -20,11 +35,12 @@ function createConstraint(kindHandler, createConstructor) {
|
|
|
20
35
|
},
|
|
21
36
|
[constraintKind.runTimeKey]: null,
|
|
22
37
|
[kindHandler.runTimeKey]: null
|
|
23
|
-
};
|
|
38
|
+
});
|
|
24
39
|
return self;
|
|
25
40
|
};
|
|
26
41
|
return createConstructor({ init });
|
|
27
42
|
}
|
|
28
43
|
//#endregion
|
|
44
|
+
exports.ConstraintBase = ConstraintBase;
|
|
29
45
|
exports.constraintKind = constraintKind;
|
|
30
46
|
exports.createConstraint = createConstraint;
|
|
@@ -19,6 +19,11 @@ export interface CreateConstraintInitParams<GenericConstraint extends Constraint
|
|
|
19
19
|
executeCheck(self: GenericConstraint, data: Parameters<GenericConstraint["executeCheck"]>[0]): DCommon.MaybePromise<SuccessSymbol | ErrorSymbol>;
|
|
20
20
|
isAsynchronous(self: GenericConstraint): boolean;
|
|
21
21
|
}
|
|
22
|
+
export declare class ConstraintBase {
|
|
23
|
+
private constructor();
|
|
24
|
+
static init(params: DKind.Remove<Constraint>): Constraint;
|
|
25
|
+
static addToPrototype<GenericProp extends keyof Constraint>(prop: GenericProp, value: Constraint[GenericProp] extends infer InferredValue ? InferredValue extends DCommon.AnyFunction ? (self: Constraint, ...rest: Parameters<InferredValue>) => ReturnType<InferredValue> : Constraint[GenericProp] : never): void;
|
|
26
|
+
}
|
|
22
27
|
export interface CreateConstraintConstructorParams<GenericKindHandler extends DKind.Handler = DKind.Handler> {
|
|
23
28
|
init<GenericConstraint extends (Constraint & DKind.Kind<GenericKindHandler>)>(definition: GenericConstraint["definition"], params: CreateConstraintInitParams<GenericConstraint>): GenericConstraint;
|
|
24
29
|
}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
import { bindPrototypeMethods } from "../../common/bindPrototypeMethods.mjs";
|
|
1
2
|
import { simpleClone } from "../../common/simpleClone.mjs";
|
|
2
3
|
import { createKind } from "../kind.mjs";
|
|
3
4
|
//#region scripts/dataStructure/constraint/base.ts
|
|
4
5
|
const constraintKind = createKind("constraint");
|
|
6
|
+
var ConstraintBase = class ConstraintBase {
|
|
7
|
+
constructor() {}
|
|
8
|
+
static init(params) {
|
|
9
|
+
const self = new ConstraintBase();
|
|
10
|
+
bindPrototypeMethods(self);
|
|
11
|
+
for (const key in params) self[key] = params[key];
|
|
12
|
+
return self;
|
|
13
|
+
}
|
|
14
|
+
static addToPrototype(prop, value) {
|
|
15
|
+
ConstraintBase.prototype[prop] = typeof value === "function" ? function(...args) {
|
|
16
|
+
return value(this, ...args);
|
|
17
|
+
} : value;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
5
20
|
function createConstraint(kindHandler, createConstructor) {
|
|
6
21
|
const init = (definition, { executeCheck, isAsynchronous }) => {
|
|
7
|
-
const self = {
|
|
22
|
+
const self = ConstraintBase.init({
|
|
8
23
|
definition,
|
|
9
24
|
executeCheck: (data) => executeCheck(self, data),
|
|
10
25
|
isAsynchronous: () => isAsynchronous(self),
|
|
@@ -21,10 +36,10 @@ function createConstraint(kindHandler, createConstructor) {
|
|
|
21
36
|
},
|
|
22
37
|
[constraintKind.runTimeKey]: null,
|
|
23
38
|
[kindHandler.runTimeKey]: null
|
|
24
|
-
};
|
|
39
|
+
});
|
|
25
40
|
return self;
|
|
26
41
|
};
|
|
27
42
|
return createConstructor({ init });
|
|
28
43
|
}
|
|
29
44
|
//#endregion
|
|
30
|
-
export { constraintKind, createConstraint };
|
|
45
|
+
export { ConstraintBase, constraintKind, createConstraint };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_kind = require("../../kind.cjs");
|
|
2
|
+
const require_resultSymbol = require("../../common/resultSymbol.cjs");
|
|
3
|
+
const require_base = require("../base.cjs");
|
|
4
|
+
const require_isSegment = require("../../../path/isSegment.cjs");
|
|
5
|
+
//#region scripts/dataStructure/constraint/defaults/segmentPath.ts
|
|
6
|
+
const segmentPathConstraintKind = require_kind.createKind("segment-path-constraint");
|
|
7
|
+
const SegmentPathConstraint = require_base.createConstraint(segmentPathConstraintKind, ({ init }) => () => init({}, {
|
|
8
|
+
executeCheck: (_self, data) => require_isSegment.isSegment(data) ? require_resultSymbol.SuccessSymbol : require_resultSymbol.ErrorSymbol,
|
|
9
|
+
isAsynchronous: () => false
|
|
10
|
+
}));
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.SegmentPathConstraint = SegmentPathConstraint;
|
|
13
|
+
exports.segmentPathConstraintKind = segmentPathConstraintKind;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConstraintDefinition, Constraint } from '../base';
|
|
2
|
+
import type * as DCommon from '../../../common';
|
|
3
|
+
import type * as DKind from '../../../kind';
|
|
4
|
+
import * as DPath from '../../../path';
|
|
5
|
+
export declare const segmentPathConstraintKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/segment-path-constraint", unknown>>;
|
|
6
|
+
export interface SegmentPathConstraintDefinition extends ConstraintDefinition {
|
|
7
|
+
}
|
|
8
|
+
export interface SegmentPathConstraint extends DCommon.Forward<Constraint<string, string & DPath.Segment, SegmentPathConstraintDefinition> & DKind.Kind<typeof segmentPathConstraintKind>> {
|
|
9
|
+
}
|
|
10
|
+
export declare const SegmentPathConstraint: () => SegmentPathConstraint;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createKind } from "../../kind.mjs";
|
|
2
|
+
import { ErrorSymbol, SuccessSymbol } from "../../common/resultSymbol.mjs";
|
|
3
|
+
import { createConstraint } from "../base.mjs";
|
|
4
|
+
import { isSegment } from "../../../path/isSegment.mjs";
|
|
5
|
+
//#region scripts/dataStructure/constraint/defaults/segmentPath.ts
|
|
6
|
+
const segmentPathConstraintKind = createKind("segment-path-constraint");
|
|
7
|
+
const SegmentPathConstraint = createConstraint(segmentPathConstraintKind, ({ init }) => () => init({}, {
|
|
8
|
+
executeCheck: (_self, data) => isSegment(data) ? SuccessSymbol : ErrorSymbol,
|
|
9
|
+
isAsynchronous: () => false
|
|
10
|
+
}));
|
|
11
|
+
//#endregion
|
|
12
|
+
export { SegmentPathConstraint, segmentPathConstraintKind };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Constraint } from '../base';
|
|
2
2
|
import type * as DDefaults from "../defaults";
|
|
3
3
|
export interface ConstraintsStore {
|
|
4
|
-
absolutePath: DDefaults.AbsolutePathConstraint;
|
|
5
4
|
allowedCharacters: DDefaults.AllowedCharactersConstraint;
|
|
6
5
|
email: DDefaults.EmailConstraint;
|
|
7
6
|
url: DDefaults.UrlConstraint;
|
|
@@ -31,7 +30,9 @@ export interface ConstraintsStore {
|
|
|
31
30
|
greaterThanOrEqual: DDefaults.GreaterThanOrEqualConstraint;
|
|
32
31
|
lessThan: DDefaults.LessThanConstraint;
|
|
33
32
|
lessThanOrEqual: DDefaults.LessThanOrEqualConstraint;
|
|
33
|
+
absolutePath: DDefaults.AbsolutePathConstraint;
|
|
34
34
|
path: DDefaults.PathConstraint;
|
|
35
|
+
segmentPath: DDefaults.SegmentPathConstraint;
|
|
35
36
|
refine: DDefaults.RefineConstraint;
|
|
36
37
|
}
|
|
37
38
|
export type Constraints = Extract<ConstraintsStore[keyof ConstraintsStore], Constraint>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const require_segmentPath = require("../constraint/defaults/segmentPath.cjs");
|
|
2
|
+
//#region scripts/dataStructure/helpers/segmentPath.ts
|
|
3
|
+
function segmentPath() {
|
|
4
|
+
return require_segmentPath.SegmentPathConstraint();
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
exports.segmentPath = segmentPath;
|
|
@@ -30,6 +30,7 @@ const require_path = require("./constraint/defaults/path.cjs");
|
|
|
30
30
|
const require_positive = require("./constraint/defaults/positive.cjs");
|
|
31
31
|
const require_refine = require("./constraint/defaults/refine.cjs");
|
|
32
32
|
const require_safe = require("./constraint/defaults/safe.cjs");
|
|
33
|
+
const require_segmentPath = require("./constraint/defaults/segmentPath.cjs");
|
|
33
34
|
const require_strictNegative = require("./constraint/defaults/strictNegative.cjs");
|
|
34
35
|
const require_strictPositive = require("./constraint/defaults/strictPositive.cjs");
|
|
35
36
|
const require_stringLengthEqual = require("./constraint/defaults/stringLengthEqual.cjs");
|
|
@@ -115,6 +116,7 @@ const require_record$1 = require("./helpers/record.cjs");
|
|
|
115
116
|
const require_refine$1 = require("./helpers/refine.cjs");
|
|
116
117
|
const require_required = require("./helpers/required.cjs");
|
|
117
118
|
const require_safe$1 = require("./helpers/safe.cjs");
|
|
119
|
+
const require_segmentPath$1 = require("./helpers/segmentPath.cjs");
|
|
118
120
|
const require_string$2 = require("./helpers/string.cjs");
|
|
119
121
|
const require_strictNegative$1 = require("./helpers/strictNegative.cjs");
|
|
120
122
|
const require_strictPositive$1 = require("./helpers/strictPositive.cjs");
|
|
@@ -136,6 +138,7 @@ var dataStructure_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
136
138
|
BigintType: () => require_bigint$1.BigintType,
|
|
137
139
|
BooleanLiteralType: () => require_booleanLiteral.BooleanLiteralType,
|
|
138
140
|
BooleanType: () => require_boolean$1.BooleanType,
|
|
141
|
+
ConstraintBase: () => require_base.ConstraintBase,
|
|
139
142
|
DateType: () => require_date$1.DateType,
|
|
140
143
|
EmailConstraint: () => require_email.EmailConstraint,
|
|
141
144
|
ErrorSymbol: () => require_resultSymbol.ErrorSymbol,
|
|
@@ -166,6 +169,7 @@ var dataStructure_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
166
169
|
RefineConstraint: () => require_refine.RefineConstraint,
|
|
167
170
|
RegexConstraint: () => require_regex.RegexConstraint,
|
|
168
171
|
SafeConstraint: () => require_safe.SafeConstraint,
|
|
172
|
+
SegmentPathConstraint: () => require_segmentPath.SegmentPathConstraint,
|
|
169
173
|
StrictNegativeConstraint: () => require_strictNegative.StrictNegativeConstraint,
|
|
170
174
|
StrictPositiveConstraint: () => require_strictPositive.StrictPositiveConstraint,
|
|
171
175
|
StringLengthEqualConstraint: () => require_stringLengthEqual.StringLengthEqualConstraint,
|
|
@@ -294,6 +298,8 @@ var dataStructure_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
294
298
|
required: () => require_required.required,
|
|
295
299
|
safe: () => require_safe$1.safe,
|
|
296
300
|
safeConstraintKind: () => require_safe.safeConstraintKind,
|
|
301
|
+
segmentPath: () => require_segmentPath$1.segmentPath,
|
|
302
|
+
segmentPathConstraintKind: () => require_segmentPath.segmentPathConstraintKind,
|
|
297
303
|
strictNegative: () => require_strictNegative$1.strictNegative,
|
|
298
304
|
strictNegativeConstraintKind: () => require_strictNegative.strictNegativeConstraintKind,
|
|
299
305
|
strictPositive: () => require_strictPositive$1.strictPositive,
|
|
@@ -335,6 +341,7 @@ exports.BigintLiteralType = require_bigintLiteral.BigintLiteralType;
|
|
|
335
341
|
exports.BigintType = require_bigint$1.BigintType;
|
|
336
342
|
exports.BooleanLiteralType = require_booleanLiteral.BooleanLiteralType;
|
|
337
343
|
exports.BooleanType = require_boolean$1.BooleanType;
|
|
344
|
+
exports.ConstraintBase = require_base.ConstraintBase;
|
|
338
345
|
exports.DateType = require_date$1.DateType;
|
|
339
346
|
exports.EmailConstraint = require_email.EmailConstraint;
|
|
340
347
|
exports.ErrorSymbol = require_resultSymbol.ErrorSymbol;
|
|
@@ -365,6 +372,7 @@ exports.RecordStructure = require_record.RecordStructure;
|
|
|
365
372
|
exports.RefineConstraint = require_refine.RefineConstraint;
|
|
366
373
|
exports.RegexConstraint = require_regex.RegexConstraint;
|
|
367
374
|
exports.SafeConstraint = require_safe.SafeConstraint;
|
|
375
|
+
exports.SegmentPathConstraint = require_segmentPath.SegmentPathConstraint;
|
|
368
376
|
exports.StrictNegativeConstraint = require_strictNegative.StrictNegativeConstraint;
|
|
369
377
|
exports.StrictPositiveConstraint = require_strictPositive.StrictPositiveConstraint;
|
|
370
378
|
exports.StringLengthEqualConstraint = require_stringLengthEqual.StringLengthEqualConstraint;
|
|
@@ -499,6 +507,8 @@ exports.regexConstraintKind = require_regex.regexConstraintKind;
|
|
|
499
507
|
exports.required = require_required.required;
|
|
500
508
|
exports.safe = require_safe$1.safe;
|
|
501
509
|
exports.safeConstraintKind = require_safe.safeConstraintKind;
|
|
510
|
+
exports.segmentPath = require_segmentPath$1.segmentPath;
|
|
511
|
+
exports.segmentPathConstraintKind = require_segmentPath.segmentPathConstraintKind;
|
|
502
512
|
exports.strictNegative = require_strictNegative$1.strictNegative;
|
|
503
513
|
exports.strictNegativeConstraintKind = require_strictNegative.strictNegativeConstraintKind;
|
|
504
514
|
exports.strictPositive = require_strictPositive$1.strictPositive;
|
|
@@ -4,7 +4,7 @@ import { ErrorSymbol, SuccessSymbol } from "./common/resultSymbol.mjs";
|
|
|
4
4
|
import { codecKind, codecsKind, createCodec, createCodecs } from "./common/codec.mjs";
|
|
5
5
|
import { createErrorHandler, createGetErrorHandler, decodeIssueKind, encodeIssueKind, issueKind } from "./common/error.mjs";
|
|
6
6
|
import { createErrorInterpreter } from "./common/errorInterpreter.mjs";
|
|
7
|
-
import { constraintKind, createConstraint } from "./constraint/base.mjs";
|
|
7
|
+
import { ConstraintBase, constraintKind, createConstraint } from "./constraint/base.mjs";
|
|
8
8
|
import { AbsolutePathConstraint, absolutePathConstraintKind } from "./constraint/defaults/absolutePath.mjs";
|
|
9
9
|
import { AllowedCharactersConstraint, allowedCharactersConstraintKind } from "./constraint/defaults/allowedCharacters.mjs";
|
|
10
10
|
import { ArrayLengthEqualConstraint, arrayLengthEqualConstraintKind } from "./constraint/defaults/arrayLengthEqual.mjs";
|
|
@@ -30,6 +30,7 @@ import { PathConstraint, pathConstraintKind } from "./constraint/defaults/path.m
|
|
|
30
30
|
import { PositiveConstraint, positiveConstraintKind } from "./constraint/defaults/positive.mjs";
|
|
31
31
|
import { RefineConstraint, refineConstraintKind } from "./constraint/defaults/refine.mjs";
|
|
32
32
|
import { SafeConstraint, safeConstraintKind } from "./constraint/defaults/safe.mjs";
|
|
33
|
+
import { SegmentPathConstraint, segmentPathConstraintKind } from "./constraint/defaults/segmentPath.mjs";
|
|
33
34
|
import { StrictNegativeConstraint, strictNegativeConstraintKind } from "./constraint/defaults/strictNegative.mjs";
|
|
34
35
|
import { StrictPositiveConstraint, strictPositiveConstraintKind } from "./constraint/defaults/strictPositive.mjs";
|
|
35
36
|
import { StringLengthEqualConstraint, stringLengthEqualConstraintKind } from "./constraint/defaults/stringLengthEqual.mjs";
|
|
@@ -115,6 +116,7 @@ import { record } from "./helpers/record.mjs";
|
|
|
115
116
|
import { refine } from "./helpers/refine.mjs";
|
|
116
117
|
import { required } from "./helpers/required.mjs";
|
|
117
118
|
import { safe } from "./helpers/safe.mjs";
|
|
119
|
+
import { segmentPath } from "./helpers/segmentPath.mjs";
|
|
118
120
|
import { string } from "./helpers/string.mjs";
|
|
119
121
|
import { strictNegative } from "./helpers/strictNegative.mjs";
|
|
120
122
|
import { strictPositive } from "./helpers/strictPositive.mjs";
|
|
@@ -136,6 +138,7 @@ var dataStructure_exports = /* @__PURE__ */ __exportAll({
|
|
|
136
138
|
BigintType: () => BigintType,
|
|
137
139
|
BooleanLiteralType: () => BooleanLiteralType,
|
|
138
140
|
BooleanType: () => BooleanType,
|
|
141
|
+
ConstraintBase: () => ConstraintBase,
|
|
139
142
|
DateType: () => DateType,
|
|
140
143
|
EmailConstraint: () => EmailConstraint,
|
|
141
144
|
ErrorSymbol: () => ErrorSymbol,
|
|
@@ -166,6 +169,7 @@ var dataStructure_exports = /* @__PURE__ */ __exportAll({
|
|
|
166
169
|
RefineConstraint: () => RefineConstraint,
|
|
167
170
|
RegexConstraint: () => RegexConstraint,
|
|
168
171
|
SafeConstraint: () => SafeConstraint,
|
|
172
|
+
SegmentPathConstraint: () => SegmentPathConstraint,
|
|
169
173
|
StrictNegativeConstraint: () => StrictNegativeConstraint,
|
|
170
174
|
StrictPositiveConstraint: () => StrictPositiveConstraint,
|
|
171
175
|
StringLengthEqualConstraint: () => StringLengthEqualConstraint,
|
|
@@ -294,6 +298,8 @@ var dataStructure_exports = /* @__PURE__ */ __exportAll({
|
|
|
294
298
|
required: () => required,
|
|
295
299
|
safe: () => safe,
|
|
296
300
|
safeConstraintKind: () => safeConstraintKind,
|
|
301
|
+
segmentPath: () => segmentPath,
|
|
302
|
+
segmentPathConstraintKind: () => segmentPathConstraintKind,
|
|
297
303
|
strictNegative: () => strictNegative,
|
|
298
304
|
strictNegativeConstraintKind: () => strictNegativeConstraintKind,
|
|
299
305
|
strictPositive: () => strictPositive,
|
|
@@ -325,4 +331,4 @@ var dataStructure_exports = /* @__PURE__ */ __exportAll({
|
|
|
325
331
|
uuidConstraintKind: () => uuidConstraintKind
|
|
326
332
|
});
|
|
327
333
|
//#endregion
|
|
328
|
-
export { AbsolutePathConstraint, AllowedCharactersConstraint, ArrayLengthEqualConstraint, ArrayStructure, BetweenThanConstraint, BetweenThanOrEqualConstraint, BigintLiteralType, BigintType, BooleanLiteralType, BooleanType, DateType, EmailConstraint, ErrorSymbol, EvenConstraint, GreaterThanConstraint, GreaterThanOrEqualConstraint, IntegerConstraint, LazyStructure, LessThanConstraint, LessThanOrEqualConstraint, MaxCharactersConstraint, MaxElementsConstraint, MinCharactersConstraint, MinElementsConstraint, MultipleOfConstraint, NegativeConstraint, NonEncodableStringStructure, NotEmptyConstraint, NotZeroConstraint, NullType, NumberLiteralType, NumberType, ObjectStructure, OddConstraint, PathConstraint, PositiveConstraint, RecordStructure, RefineConstraint, RegexConstraint, SafeConstraint, StrictNegativeConstraint, StrictPositiveConstraint, StringLengthEqualConstraint, StringLiteralType, StringType, StructureClass, SuccessSymbol, TheBigint, TheBoolean, TheDate, TheNull, TheNumber, TheString, TheTime, TheUndefined, TimeType, TrimmedConstraint, TypeStructure, UndefinedType, UnionStructure, UrlConstraint, UuidConstraint, absolutePath, absolutePathConstraintKind, allowedCharacters, allowedCharactersConstraintKind, array, arrayLengthEqual, arrayLengthEqualConstraintKind, arrayStructureKind, betweenThan, betweenThanConstraintKind, betweenThanOrEqual, betweenThanOrEqualConstraintKind, bigint, bigintFundamentalTypeKind, bigintLiteralTypeKind, bigintTypeKind, boolean, booleanFundamentalTypeKind, booleanLiteralTypeKind, booleanTypeKind, codecKind, codecsKind, constraintIdentifier, constraintKind, createCodec, createCodecs, createConstraint, createErrorHandler, createErrorInterpreter, createFundamentalType, createGetErrorHandler, createKind, createStructure, createType, dataStructure_exports, date, dateFundamentalTypeKind, dateTypeKind, decodeIssueKind, email, emailConstraintKind, encodeIssueKind, even, evenConstraintKind, extend, fundamentalTypeIdentifier, fundamentalTypeKind, greaterThan, greaterThanConstraintKind, greaterThanOrEqual, greaterThanOrEqualConstraintKind, integer, integerConstraintKind, isNullStructure, isUndefinedStructure, issueKind, lazy, lazyStructureKind, lessThan, lessThanConstraintKind, lessThanOrEqual, lessThanOrEqualConstraintKind, literal, maxCharacters, maxCharactersConstraintKind, maxElements, maxElementsConstraintKind, minCharacters, minCharactersConstraintKind, minElements, minElementsConstraintKind, multipleOf, multipleOfConstraintKind, negative, negativeConstraintKind, nonEncodableStringStructureKind, notEmpty, notEmptyConstraintKind, notZero, notZeroConstraintKind, nullHelper as null, nullFundamentalTypeKind, nullTypeKind, nullable, number, numberFundamentalTypeKind, numberLiteralTypeKind, numberTypeKind, object, objectStructureKind, odd, oddConstraintKind, optional, partial, path, pathConstraintKind, positive, positiveConstraintKind, record, recordStructureKind, refine, refineConstraintKind, regex, regexConstraintKind, required, safe, safeConstraintKind, strictNegative, strictNegativeConstraintKind, strictPositive, strictPositiveConstraintKind, string, stringFundamentalTypeKind, stringLengthEqual, stringLengthEqualConstraintKind, stringLiteralTypeKind, stringTypeKind, structureIdentifier, structureKind, time, timeFundamentalTypeKind, timeTypeKind, trimmed, trimmedConstraintKind, typeIdentifier, typeKind, typeStructureKind, undefinedHelper as undefined, undefinedFundamentalTypeKind, undefinedTypeKind, union, unionStructureKind, url, urlConstraintKind, uuid, uuidConstraintKind };
|
|
334
|
+
export { AbsolutePathConstraint, AllowedCharactersConstraint, ArrayLengthEqualConstraint, ArrayStructure, BetweenThanConstraint, BetweenThanOrEqualConstraint, BigintLiteralType, BigintType, BooleanLiteralType, BooleanType, ConstraintBase, DateType, EmailConstraint, ErrorSymbol, EvenConstraint, GreaterThanConstraint, GreaterThanOrEqualConstraint, IntegerConstraint, LazyStructure, LessThanConstraint, LessThanOrEqualConstraint, MaxCharactersConstraint, MaxElementsConstraint, MinCharactersConstraint, MinElementsConstraint, MultipleOfConstraint, NegativeConstraint, NonEncodableStringStructure, NotEmptyConstraint, NotZeroConstraint, NullType, NumberLiteralType, NumberType, ObjectStructure, OddConstraint, PathConstraint, PositiveConstraint, RecordStructure, RefineConstraint, RegexConstraint, SafeConstraint, SegmentPathConstraint, StrictNegativeConstraint, StrictPositiveConstraint, StringLengthEqualConstraint, StringLiteralType, StringType, StructureClass, SuccessSymbol, TheBigint, TheBoolean, TheDate, TheNull, TheNumber, TheString, TheTime, TheUndefined, TimeType, TrimmedConstraint, TypeStructure, UndefinedType, UnionStructure, UrlConstraint, UuidConstraint, absolutePath, absolutePathConstraintKind, allowedCharacters, allowedCharactersConstraintKind, array, arrayLengthEqual, arrayLengthEqualConstraintKind, arrayStructureKind, betweenThan, betweenThanConstraintKind, betweenThanOrEqual, betweenThanOrEqualConstraintKind, bigint, bigintFundamentalTypeKind, bigintLiteralTypeKind, bigintTypeKind, boolean, booleanFundamentalTypeKind, booleanLiteralTypeKind, booleanTypeKind, codecKind, codecsKind, constraintIdentifier, constraintKind, createCodec, createCodecs, createConstraint, createErrorHandler, createErrorInterpreter, createFundamentalType, createGetErrorHandler, createKind, createStructure, createType, dataStructure_exports, date, dateFundamentalTypeKind, dateTypeKind, decodeIssueKind, email, emailConstraintKind, encodeIssueKind, even, evenConstraintKind, extend, fundamentalTypeIdentifier, fundamentalTypeKind, greaterThan, greaterThanConstraintKind, greaterThanOrEqual, greaterThanOrEqualConstraintKind, integer, integerConstraintKind, isNullStructure, isUndefinedStructure, issueKind, lazy, lazyStructureKind, lessThan, lessThanConstraintKind, lessThanOrEqual, lessThanOrEqualConstraintKind, literal, maxCharacters, maxCharactersConstraintKind, maxElements, maxElementsConstraintKind, minCharacters, minCharactersConstraintKind, minElements, minElementsConstraintKind, multipleOf, multipleOfConstraintKind, negative, negativeConstraintKind, nonEncodableStringStructureKind, notEmpty, notEmptyConstraintKind, notZero, notZeroConstraintKind, nullHelper as null, nullFundamentalTypeKind, nullTypeKind, nullable, number, numberFundamentalTypeKind, numberLiteralTypeKind, numberTypeKind, object, objectStructureKind, odd, oddConstraintKind, optional, partial, path, pathConstraintKind, positive, positiveConstraintKind, record, recordStructureKind, refine, refineConstraintKind, regex, regexConstraintKind, required, safe, safeConstraintKind, segmentPath, segmentPathConstraintKind, strictNegative, strictNegativeConstraintKind, strictPositive, strictPositiveConstraintKind, string, stringFundamentalTypeKind, stringLengthEqual, stringLengthEqualConstraintKind, stringLiteralTypeKind, stringTypeKind, structureIdentifier, structureKind, time, timeFundamentalTypeKind, timeTypeKind, trimmed, trimmedConstraintKind, typeIdentifier, typeKind, typeStructureKind, undefinedHelper as undefined, undefinedFundamentalTypeKind, undefinedTypeKind, union, unionStructureKind, url, urlConstraintKind, uuid, uuidConstraintKind };
|
|
@@ -24,14 +24,14 @@ export declare const entityStructureKind: DKind.Handler<DKind.Definition<"@Duplo
|
|
|
24
24
|
export interface EntityStructureDefinition extends DDataStructure.StructureDefinition<readonly []> {
|
|
25
25
|
readonly inner: DCommon.Memoized<DDataStructure.ObjectStructure>;
|
|
26
26
|
}
|
|
27
|
-
export type EntityMap<GenericValue extends unknown, GenericRawValue = DCommon.RemoveConstraint<GenericValue>> = GenericRawValue extends NewType ? NewTypeMap<GenericRawValue> : GenericRawValue extends
|
|
27
|
+
export type EntityMap<GenericValue extends unknown, GenericRawValue = DCommon.RemoveConstraint<GenericValue>> = GenericRawValue extends NewType ? NewTypeMap<GenericRawValue> : GenericRawValue extends object ? DCommon.Or<[
|
|
28
28
|
DCommon.IsExtends<GenericRawValue, readonly any[]>,
|
|
29
29
|
DCommon.And<[
|
|
30
30
|
DCommon.IsExtends<keyof GenericRawValue, string>,
|
|
31
31
|
DCommon.Not<DCommon.IsExtends<DCommon.AnyFunction, GenericRawValue[keyof GenericRawValue]>>
|
|
32
32
|
]>
|
|
33
33
|
]> extends true ? {
|
|
34
|
-
[Prop in keyof GenericRawValue]:
|
|
34
|
+
[Prop in keyof GenericRawValue]: EntityMap<GenericRawValue[Prop]>;
|
|
35
35
|
} : GenericRawValue : GenericRawValue;
|
|
36
36
|
export interface EntityStructure<GenericName extends string = string, GenericProperties extends Record<string, unknown> = Record<string, unknown>> extends DCommon.Forward<DDataStructure.Structure<Entity<GenericName> & GenericProperties, EntityStructureDefinition> & DKind.Kind<typeof entityStructureKind>> {
|
|
37
37
|
readonly name: GenericName;
|
|
@@ -7,7 +7,7 @@ const namespaceKind = require_kind.createKind("namespace");
|
|
|
7
7
|
function createEntityNamespace(entityName) {
|
|
8
8
|
return {
|
|
9
9
|
name: entityName,
|
|
10
|
-
createNewType: (name, structure, newTypeConstraints = []) => require_helper$1.
|
|
10
|
+
createNewType: (name, structure, newTypeConstraints = []) => require_helper$1.createNewType(`${entityName}${name}`, structure, newTypeConstraints),
|
|
11
11
|
createEntity: (shape) => require_helper.createEntity(entityName, shape),
|
|
12
12
|
createFlag: (entityStructure, name, valueStructure) => require_base.createFlag(entityStructure, `${entityName}${name}`, valueStructure),
|
|
13
13
|
[namespaceKind.runTimeKey]: null
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createKind } from "../kind.mjs";
|
|
2
2
|
import { createEntity } from "./helper.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { createNewType } from "../newType/helper.mjs";
|
|
4
4
|
import { createFlag } from "../flag/base.mjs";
|
|
5
5
|
//#region scripts/modeling/entity/namespace.ts
|
|
6
6
|
const namespaceKind = createKind("namespace");
|
|
7
7
|
function createEntityNamespace(entityName) {
|
|
8
8
|
return {
|
|
9
9
|
name: entityName,
|
|
10
|
-
createNewType: (name, structure, newTypeConstraints = []) =>
|
|
10
|
+
createNewType: (name, structure, newTypeConstraints = []) => createNewType(`${entityName}${name}`, structure, newTypeConstraints),
|
|
11
11
|
createEntity: (shape) => createEntity(entityName, shape),
|
|
12
12
|
createFlag: (entityStructure, name, valueStructure) => createFlag(entityStructure, `${entityName}${name}`, valueStructure),
|
|
13
13
|
[namespaceKind.runTimeKey]: null
|
package/dist/modeling/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@ var modeling_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
17
17
|
createEntityNamespace: () => require_namespace.createEntityNamespace,
|
|
18
18
|
createFlag: () => require_base$2.createFlag,
|
|
19
19
|
createKind: () => require_kind.createKind,
|
|
20
|
-
|
|
20
|
+
createNewType: () => require_helper$1.createNewType,
|
|
21
21
|
createTaggedObject: () => require_helper$2.createTaggedObject,
|
|
22
22
|
entityKind: () => require_base.entityKind,
|
|
23
23
|
entityStructureKind: () => require_base.entityStructureKind,
|
|
@@ -38,7 +38,7 @@ exports.createEntity = require_helper.createEntity;
|
|
|
38
38
|
exports.createEntityNamespace = require_namespace.createEntityNamespace;
|
|
39
39
|
exports.createFlag = require_base$2.createFlag;
|
|
40
40
|
exports.createKind = require_kind.createKind;
|
|
41
|
-
exports.
|
|
41
|
+
exports.createNewType = require_helper$1.createNewType;
|
|
42
42
|
exports.createTaggedObject = require_helper$2.createTaggedObject;
|
|
43
43
|
exports.entityKind = require_base.entityKind;
|
|
44
44
|
exports.entityStructureKind = require_base.entityStructureKind;
|
package/dist/modeling/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { createKind } from "./kind.mjs";
|
|
|
3
3
|
import { EntityStructure, entityKind, entityStructureKind } from "./entity/base.mjs";
|
|
4
4
|
import { createEntity } from "./entity/helper.mjs";
|
|
5
5
|
import { NewTypeStructure, newTypeStructureKind } from "./newType/base.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { createNewType } from "./newType/helper.mjs";
|
|
7
7
|
import { createFlag, flagKind } from "./flag/base.mjs";
|
|
8
8
|
import { createEntityNamespace, namespaceKind } from "./entity/namespace.mjs";
|
|
9
9
|
import { TaggedObjectStructure, objectTagKind, taggedObjectStructureKind } from "./taggedObject/base.mjs";
|
|
@@ -17,7 +17,7 @@ var modeling_exports = /* @__PURE__ */ __exportAll({
|
|
|
17
17
|
createEntityNamespace: () => createEntityNamespace,
|
|
18
18
|
createFlag: () => createFlag,
|
|
19
19
|
createKind: () => createKind,
|
|
20
|
-
|
|
20
|
+
createNewType: () => createNewType,
|
|
21
21
|
createTaggedObject: () => createTaggedObject,
|
|
22
22
|
entityKind: () => entityKind,
|
|
23
23
|
entityStructureKind: () => entityStructureKind,
|
|
@@ -31,4 +31,4 @@ var modeling_exports = /* @__PURE__ */ __exportAll({
|
|
|
31
31
|
taggedObjectStructureKind: () => taggedObjectStructureKind
|
|
32
32
|
});
|
|
33
33
|
//#endregion
|
|
34
|
-
export { EntityStructure, NewTypeStructure, TaggedObjectStructure, createEntity, createEntityNamespace, createFlag, createKind,
|
|
34
|
+
export { EntityStructure, NewTypeStructure, TaggedObjectStructure, createEntity, createEntityNamespace, createFlag, createKind, createNewType, createTaggedObject, entityKind, entityStructureKind, flagKind, getTagValue, hasTagValue, modeling_exports, namespaceKind, newTypeStructureKind, objectTagKind, taggedObject, taggedObjectStructureKind };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_base = require("./base.cjs");
|
|
2
2
|
//#region scripts/modeling/newType/helper.ts
|
|
3
|
-
function
|
|
3
|
+
function createNewType(name, structure, newTypeConstraints = []) {
|
|
4
4
|
return require_base.NewTypeStructure(name, structure, newTypeConstraints);
|
|
5
5
|
}
|
|
6
6
|
//#endregion
|
|
7
|
-
exports.
|
|
7
|
+
exports.createNewType = createNewType;
|
|
@@ -2,4 +2,4 @@ import { NewType, NewTypeStructure } from './base';
|
|
|
2
2
|
import type * as DCommon from '../../common';
|
|
3
3
|
import type * as DDataStructure from '../../dataStructure';
|
|
4
4
|
export type ForbiddenTopLevelNewType<GenericValue extends unknown> = GenericValue extends NewType ? DCommon.ComputedTypeError<"NewType on top level of NewType declaration is forbidden."> : never;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function createNewType<GenericName extends Capitalize<string>, GenericStructure extends DDataStructure.Structure, const GenericNewTypeConstraint extends readonly DDataStructure.Constraint<DDataStructure.StructureValue<GenericStructure>>[] = readonly []>(name: (GenericName & DCommon.NeverCoalescing<ForbiddenTopLevelNewType<DDataStructure.StructureValue<GenericStructure>>, unknown>), structure: GenericStructure, newTypeConstraints?: GenericNewTypeConstraint): NewTypeStructure<GenericName & DCommon.NeverCoalescing<ForbiddenTopLevelNewType<DDataStructure.StructureValue<GenericStructure>>, unknown>, DDataStructure.StructureValue<GenericStructure>, GenericNewTypeConstraint>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NewTypeStructure } from "./base.mjs";
|
|
2
2
|
//#region scripts/modeling/newType/helper.ts
|
|
3
|
-
function
|
|
3
|
+
function createNewType(name, structure, newTypeConstraints = []) {
|
|
4
4
|
return NewTypeStructure(name, structure, newTypeConstraints);
|
|
5
5
|
}
|
|
6
6
|
//#endregion
|
|
7
|
-
export {
|
|
7
|
+
export { createNewType };
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
const require_isSimple = require("../../object/isSimple.cjs");
|
|
2
|
+
const require_create = require("../../either/left/create.cjs");
|
|
3
|
+
const require_create$1 = require("../../either/right/create.cjs");
|
|
4
|
+
const require_justExec = require("../../common/justExec.cjs");
|
|
5
|
+
const require_resultSymbol = require("../../dataStructure/common/resultSymbol.cjs");
|
|
6
|
+
const require_error = require("../../dataStructure/common/error.cjs");
|
|
1
7
|
const require_base = require("../../dataStructure/structure/base.cjs");
|
|
2
8
|
const require_nonEncodableString = require("../../dataStructure/structure/defaults/nonEncodableString.cjs");
|
|
3
9
|
const require_object = require("../../dataStructure/structure/defaults/object.cjs");
|
|
@@ -16,7 +22,64 @@ const TaggedObjectStructure = require_base.createStructure(taggedObjectStructure
|
|
|
16
22
|
executeEncode: (self, codecContext, data, errorHandler) => self.definition.inner.executeEncode(codecContext, data, errorHandler),
|
|
17
23
|
executeDecode: (self, codecContext, data, errorHandler) => self.definition.inner.executeDecode(codecContext, data, errorHandler),
|
|
18
24
|
isAsynchronous: (self) => self.definition.inner.isAsynchronous()
|
|
19
|
-
}, {
|
|
25
|
+
}, {
|
|
26
|
+
name,
|
|
27
|
+
new: (self, properties) => ({
|
|
28
|
+
...properties,
|
|
29
|
+
[objectTagKind.runTimeKey]: name
|
|
30
|
+
}),
|
|
31
|
+
decodeMap: (self, ...args) => {
|
|
32
|
+
if (args.length === 1) {
|
|
33
|
+
const [codecs] = args;
|
|
34
|
+
return (value) => self.decodeMap(codecs, value);
|
|
35
|
+
}
|
|
36
|
+
const errorHandler = require_error.createGetErrorHandler();
|
|
37
|
+
const [codecs, data] = args;
|
|
38
|
+
const result = self.executeDecode(codecs.context.value, require_isSimple.isSimple(data) ? {
|
|
39
|
+
...data,
|
|
40
|
+
[objectTagKind.runTimeKey]: name
|
|
41
|
+
} : data, errorHandler);
|
|
42
|
+
if (result instanceof Promise) return require_create.left("async-error", void 0);
|
|
43
|
+
if (result === require_resultSymbol.ErrorSymbol) return require_create.left("map-error", errorHandler().createError());
|
|
44
|
+
return require_create$1.right("map-success", result);
|
|
45
|
+
},
|
|
46
|
+
map: (self, data) => {
|
|
47
|
+
const errorHandler = require_error.createGetErrorHandler();
|
|
48
|
+
const formattedData = require_isSimple.isSimple(data) ? {
|
|
49
|
+
...data,
|
|
50
|
+
[objectTagKind.runTimeKey]: name
|
|
51
|
+
} : data;
|
|
52
|
+
const result = self.executeCheck(formattedData, errorHandler);
|
|
53
|
+
if (result instanceof Promise) return require_create.left("async-error", void 0);
|
|
54
|
+
if (result === require_resultSymbol.ErrorSymbol) return require_create.left("map-error", errorHandler().createError());
|
|
55
|
+
return require_create$1.right("map-success", formattedData);
|
|
56
|
+
},
|
|
57
|
+
asyncDecodeMap: (self, ...args) => {
|
|
58
|
+
if (args.length === 1) {
|
|
59
|
+
const [codecs] = args;
|
|
60
|
+
return (value) => self.asyncDecodeMap(codecs, value);
|
|
61
|
+
}
|
|
62
|
+
return require_justExec.justExec(async () => {
|
|
63
|
+
const errorHandler = require_error.createGetErrorHandler();
|
|
64
|
+
const [codecs, data] = args;
|
|
65
|
+
const result = await self.executeDecode(codecs.context.value, require_isSimple.isSimple(data) ? {
|
|
66
|
+
...data,
|
|
67
|
+
[objectTagKind.runTimeKey]: name
|
|
68
|
+
} : data, errorHandler);
|
|
69
|
+
if (result === require_resultSymbol.ErrorSymbol) return require_create.left("map-error", errorHandler().createError());
|
|
70
|
+
return require_create$1.right("map-success", result);
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
asyncMap: (self, data) => require_justExec.justExec(async () => {
|
|
74
|
+
const errorHandler = require_error.createGetErrorHandler();
|
|
75
|
+
const formattedData = require_isSimple.isSimple(data) ? {
|
|
76
|
+
...data,
|
|
77
|
+
[objectTagKind.runTimeKey]: name
|
|
78
|
+
} : data;
|
|
79
|
+
if (await self.executeCheck(formattedData, errorHandler) === require_resultSymbol.ErrorSymbol) return require_create.left("map-error", errorHandler().createError());
|
|
80
|
+
return require_create$1.right("map-success", formattedData);
|
|
81
|
+
})
|
|
82
|
+
}));
|
|
20
83
|
//#endregion
|
|
21
84
|
exports.TaggedObjectStructure = TaggedObjectStructure;
|
|
22
85
|
exports.objectTagKind = objectTagKind;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { NewType, NewTypeMap } from '../newType';
|
|
1
2
|
import type * as DKind from '../../kind';
|
|
2
|
-
import
|
|
3
|
+
import * as DCommon from '../../common';
|
|
4
|
+
import * as DEither from '../../either';
|
|
3
5
|
import * as DDataStructure from '../../dataStructure';
|
|
4
6
|
declare module '../../dataStructure' {
|
|
5
7
|
interface StructuresStore {
|
|
@@ -25,7 +27,23 @@ export declare const taggedObjectStructureKind: DKind.Handler<DKind.Definition<"
|
|
|
25
27
|
export interface TaggedObjectStructureDefinition extends DDataStructure.StructureDefinition<readonly []> {
|
|
26
28
|
readonly inner: DDataStructure.ObjectStructure;
|
|
27
29
|
}
|
|
30
|
+
export type TaggedObjectMap<GenericValue extends unknown, GenericRawValue = DCommon.RemoveConstraint<GenericValue>> = GenericRawValue extends NewType ? NewTypeMap<GenericRawValue> : GenericRawValue extends object ? DCommon.Or<[
|
|
31
|
+
DCommon.IsExtends<GenericRawValue, readonly any[]>,
|
|
32
|
+
DCommon.And<[
|
|
33
|
+
DCommon.IsExtends<keyof GenericRawValue, string>,
|
|
34
|
+
DCommon.Not<DCommon.IsExtends<DCommon.AnyFunction, GenericRawValue[keyof GenericRawValue]>>
|
|
35
|
+
]>
|
|
36
|
+
]> extends true ? {
|
|
37
|
+
[Prop in keyof GenericRawValue]: TaggedObjectMap<GenericRawValue[Prop]>;
|
|
38
|
+
} : GenericRawValue : GenericRawValue;
|
|
28
39
|
export interface TaggedObjectStructure<GenericTaggedObject extends ObjectTag = ObjectTag> extends DCommon.Forward<DDataStructure.Structure<GenericTaggedObject, TaggedObjectStructureDefinition> & DKind.Kind<typeof taggedObjectStructureKind>> {
|
|
29
40
|
readonly name: GetTagValue<GenericTaggedObject>;
|
|
41
|
+
"new"(properties: DCommon.SimplifyTopLevel<DKind.Remove<GenericTaggedObject>>): GenericTaggedObject;
|
|
42
|
+
decodeMap<GenericCodecs extends DDataStructure.Codecs>(codecs: GenericCodecs): (data: DDataStructure.EncodedValue<TaggedObjectMap<DKind.Remove<DDataStructure.StructureValue<this>>>, GenericCodecs>) => (DEither.Right<"map-success", DDataStructure.StructureValue<this>> | DEither.Left<"async-error", undefined> | DEither.Left<"map-error", DDataStructure.Error>);
|
|
43
|
+
decodeMap<GenericCodecs extends DDataStructure.Codecs>(codecs: GenericCodecs, data: DDataStructure.EncodedValue<TaggedObjectMap<DKind.Remove<DDataStructure.StructureValue<this>>>, GenericCodecs>): (DEither.Right<"map-success", DDataStructure.StructureValue<this>> | DEither.Left<"async-error", undefined> | DEither.Left<"map-error", DDataStructure.Error>);
|
|
44
|
+
map(data: TaggedObjectMap<DKind.Remove<DDataStructure.StructureValue<this>>>): (DEither.Right<"map-success", DDataStructure.StructureValue<this>> | DEither.Left<"async-error", undefined> | DEither.Left<"map-error", DDataStructure.Error>);
|
|
45
|
+
asyncDecodeMap<GenericCodecs extends DDataStructure.Codecs>(codecs: GenericCodecs): (data: DDataStructure.EncodedValue<TaggedObjectMap<DKind.Remove<DDataStructure.StructureValue<this>>>, GenericCodecs>) => Promise<DEither.Right<"map-success", DDataStructure.StructureValue<this>> | DEither.Left<"map-error", DDataStructure.Error>>;
|
|
46
|
+
asyncDecodeMap<GenericCodecs extends DDataStructure.Codecs>(codecs: GenericCodecs, data: DDataStructure.EncodedValue<TaggedObjectMap<DKind.Remove<DDataStructure.StructureValue<this>>>, GenericCodecs>): Promise<DEither.Right<"map-success", DDataStructure.StructureValue<this>> | DEither.Left<"map-error", DDataStructure.Error>>;
|
|
47
|
+
asyncMap(data: TaggedObjectMap<DKind.Remove<DDataStructure.StructureValue<this>>>): Promise<DEither.Right<"map-success", DDataStructure.StructureValue<this>> | DEither.Left<"map-error", DDataStructure.Error>>;
|
|
30
48
|
}
|
|
31
49
|
export declare const TaggedObjectStructure: <GenericTaggedObject extends ObjectTag, GenericName extends string = never, GenericShape extends DDataStructure.ShapeObjectStructure = never>(name: GetTagValue<GenericTaggedObject> | GenericName, shape: ShapeTaggedObjectStructure<GenericTaggedObject> | GenericShape) => TaggedObjectStructure<ObjectTag extends GenericTaggedObject ? (ObjectTag<GenericName> & DDataStructure.ShapeObjectStructureValue<GenericShape>) : GenericTaggedObject>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { isSimple } from "../../object/isSimple.mjs";
|
|
2
|
+
import { left } from "../../either/left/create.mjs";
|
|
3
|
+
import { right } from "../../either/right/create.mjs";
|
|
4
|
+
import { justExec } from "../../common/justExec.mjs";
|
|
5
|
+
import { ErrorSymbol } from "../../dataStructure/common/resultSymbol.mjs";
|
|
6
|
+
import { createGetErrorHandler } from "../../dataStructure/common/error.mjs";
|
|
1
7
|
import { createStructure } from "../../dataStructure/structure/base.mjs";
|
|
2
8
|
import { NonEncodableStringStructure } from "../../dataStructure/structure/defaults/nonEncodableString.mjs";
|
|
3
9
|
import { ObjectStructure } from "../../dataStructure/structure/defaults/object.mjs";
|
|
@@ -16,6 +22,63 @@ const TaggedObjectStructure = createStructure(taggedObjectStructureKind, ({ init
|
|
|
16
22
|
executeEncode: (self, codecContext, data, errorHandler) => self.definition.inner.executeEncode(codecContext, data, errorHandler),
|
|
17
23
|
executeDecode: (self, codecContext, data, errorHandler) => self.definition.inner.executeDecode(codecContext, data, errorHandler),
|
|
18
24
|
isAsynchronous: (self) => self.definition.inner.isAsynchronous()
|
|
19
|
-
}, {
|
|
25
|
+
}, {
|
|
26
|
+
name,
|
|
27
|
+
new: (self, properties) => ({
|
|
28
|
+
...properties,
|
|
29
|
+
[objectTagKind.runTimeKey]: name
|
|
30
|
+
}),
|
|
31
|
+
decodeMap: (self, ...args) => {
|
|
32
|
+
if (args.length === 1) {
|
|
33
|
+
const [codecs] = args;
|
|
34
|
+
return (value) => self.decodeMap(codecs, value);
|
|
35
|
+
}
|
|
36
|
+
const errorHandler = createGetErrorHandler();
|
|
37
|
+
const [codecs, data] = args;
|
|
38
|
+
const result = self.executeDecode(codecs.context.value, isSimple(data) ? {
|
|
39
|
+
...data,
|
|
40
|
+
[objectTagKind.runTimeKey]: name
|
|
41
|
+
} : data, errorHandler);
|
|
42
|
+
if (result instanceof Promise) return left("async-error", void 0);
|
|
43
|
+
if (result === ErrorSymbol) return left("map-error", errorHandler().createError());
|
|
44
|
+
return right("map-success", result);
|
|
45
|
+
},
|
|
46
|
+
map: (self, data) => {
|
|
47
|
+
const errorHandler = createGetErrorHandler();
|
|
48
|
+
const formattedData = isSimple(data) ? {
|
|
49
|
+
...data,
|
|
50
|
+
[objectTagKind.runTimeKey]: name
|
|
51
|
+
} : data;
|
|
52
|
+
const result = self.executeCheck(formattedData, errorHandler);
|
|
53
|
+
if (result instanceof Promise) return left("async-error", void 0);
|
|
54
|
+
if (result === ErrorSymbol) return left("map-error", errorHandler().createError());
|
|
55
|
+
return right("map-success", formattedData);
|
|
56
|
+
},
|
|
57
|
+
asyncDecodeMap: (self, ...args) => {
|
|
58
|
+
if (args.length === 1) {
|
|
59
|
+
const [codecs] = args;
|
|
60
|
+
return (value) => self.asyncDecodeMap(codecs, value);
|
|
61
|
+
}
|
|
62
|
+
return justExec(async () => {
|
|
63
|
+
const errorHandler = createGetErrorHandler();
|
|
64
|
+
const [codecs, data] = args;
|
|
65
|
+
const result = await self.executeDecode(codecs.context.value, isSimple(data) ? {
|
|
66
|
+
...data,
|
|
67
|
+
[objectTagKind.runTimeKey]: name
|
|
68
|
+
} : data, errorHandler);
|
|
69
|
+
if (result === ErrorSymbol) return left("map-error", errorHandler().createError());
|
|
70
|
+
return right("map-success", result);
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
asyncMap: (self, data) => justExec(async () => {
|
|
74
|
+
const errorHandler = createGetErrorHandler();
|
|
75
|
+
const formattedData = isSimple(data) ? {
|
|
76
|
+
...data,
|
|
77
|
+
[objectTagKind.runTimeKey]: name
|
|
78
|
+
} : data;
|
|
79
|
+
if (await self.executeCheck(formattedData, errorHandler) === ErrorSymbol) return left("map-error", errorHandler().createError());
|
|
80
|
+
return right("map-success", formattedData);
|
|
81
|
+
})
|
|
82
|
+
}));
|
|
20
83
|
//#endregion
|
|
21
84
|
export { TaggedObjectStructure, objectTagKind, taggedObjectStructureKind };
|
|
@@ -19,8 +19,13 @@ function taggedObject(tag, props) {
|
|
|
19
19
|
[require_base.objectTagKind.runTimeKey]: tag
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function createTaggedObject(
|
|
23
|
-
|
|
22
|
+
function createTaggedObject(...args) {
|
|
23
|
+
if (args.length === 1) {
|
|
24
|
+
const [name] = args;
|
|
25
|
+
return (shape) => createTaggedObject(name, shape);
|
|
26
|
+
}
|
|
27
|
+
const [name, shape] = args;
|
|
28
|
+
return require_base.TaggedObjectStructure(name, shape);
|
|
24
29
|
}
|
|
25
30
|
//#endregion
|
|
26
31
|
exports.createTaggedObject = createTaggedObject;
|
|
@@ -12,3 +12,4 @@ export declare function taggedObject<GenericTaggedObject extends ObjectTag>(...a
|
|
|
12
12
|
] : never): GenericTaggedObject;
|
|
13
13
|
export type RequireTaggedObjectSameShape<GenericTaggedObject extends ObjectTag, GenericTaggedObjectShape extends ShapeTaggedObjectStructure> = DCommon.IsEqual<DCommon.SimplifyTopLevel<DObject.DeepReadonly<DKind.Remove<GenericTaggedObject>>>, DCommon.SimplifyTopLevel<DObject.DeepReadonly<DDataStructure.ShapeObjectStructureValue<GenericTaggedObjectShape>>>> extends true ? unknown : DCommon.ComputedTypeError<"Shape do not match.">;
|
|
14
14
|
export declare function createTaggedObject<GenericTaggedObject extends ObjectTag>(name: GetTagValue<GenericTaggedObject>): <GenericShape extends ShapeTaggedObjectStructure<GenericTaggedObject>>(shape: (GenericShape & RequireTaggedObjectSameShape<GenericTaggedObject, GenericShape>)) => TaggedObjectStructure<GenericTaggedObject>;
|
|
15
|
+
export declare function createTaggedObject<GenericTaggedObject extends ObjectTag, GenericName extends string = never, GenericShape extends DDataStructure.ShapeObjectStructure = never>(name: GetTagValue<GenericTaggedObject> | GenericName, shape: ShapeTaggedObjectStructure<GenericTaggedObject> | GenericShape): TaggedObjectStructure<ObjectTag extends GenericTaggedObject ? (ObjectTag<GenericName> & DDataStructure.ShapeObjectStructureValue<GenericShape>) : GenericTaggedObject>;
|
|
@@ -19,8 +19,13 @@ function taggedObject(tag, props) {
|
|
|
19
19
|
[objectTagKind.runTimeKey]: tag
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function createTaggedObject(
|
|
23
|
-
|
|
22
|
+
function createTaggedObject(...args) {
|
|
23
|
+
if (args.length === 1) {
|
|
24
|
+
const [name] = args;
|
|
25
|
+
return (shape) => createTaggedObject(name, shape);
|
|
26
|
+
}
|
|
27
|
+
const [name, shape] = args;
|
|
28
|
+
return TaggedObjectStructure(name, shape);
|
|
24
29
|
}
|
|
25
30
|
//#endregion
|
|
26
31
|
export { createTaggedObject, getTagValue, hasTagValue, taggedObject };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
const require_isSegment = require("./isSegment.cjs");
|
|
1
2
|
//#region scripts/path/getBaseName.ts
|
|
2
3
|
const baseNameRegex = /([^/]+)$/;
|
|
3
4
|
const extensionNameRegex = /(?<!^)\.[^./]+$/;
|
|
4
5
|
function getBaseName(path, params) {
|
|
5
6
|
const baseName = baseNameRegex.exec(path)?.[1];
|
|
6
7
|
if (baseName === void 0) return null;
|
|
7
|
-
|
|
8
|
+
const result = params?.removeExtension ? baseName.replace(extensionNameRegex, "") : baseName;
|
|
9
|
+
return require_isSegment.isSegment(result) ? result : null;
|
|
8
10
|
}
|
|
9
11
|
//#endregion
|
|
10
12
|
exports.getBaseName = getBaseName;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Absolute, Path } from './constraints';
|
|
1
|
+
import { Absolute, Path, Segment } from './constraints';
|
|
2
2
|
export interface GetBaseNameParams {
|
|
3
3
|
removeExtension?: boolean;
|
|
4
4
|
}
|
|
5
|
-
export declare function getBaseName<GenericPath extends string & (Path | Absolute)>(path: GenericPath, params?: GetBaseNameParams): string | null;
|
|
5
|
+
export declare function getBaseName<GenericPath extends string & (Path | Absolute | Segment)>(path: GenericPath, params?: GetBaseNameParams): (string & Segment) | null;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { isSegment } from "./isSegment.mjs";
|
|
1
2
|
//#region scripts/path/getBaseName.ts
|
|
2
3
|
const baseNameRegex = /([^/]+)$/;
|
|
3
4
|
const extensionNameRegex = /(?<!^)\.[^./]+$/;
|
|
4
5
|
function getBaseName(path, params) {
|
|
5
6
|
const baseName = baseNameRegex.exec(path)?.[1];
|
|
6
7
|
if (baseName === void 0) return null;
|
|
7
|
-
|
|
8
|
+
const result = params?.removeExtension ? baseName.replace(extensionNameRegex, "") : baseName;
|
|
9
|
+
return isSegment(result) ? result : null;
|
|
8
10
|
}
|
|
9
11
|
//#endregion
|
|
10
12
|
export { getBaseName };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_isSegment = require("./isSegment.cjs");
|
|
1
2
|
//#region scripts/path/getExtensionName.ts
|
|
2
3
|
const basenameRegex = /([^/]+)$/;
|
|
3
4
|
function getExtensionName(path, params) {
|
|
@@ -6,7 +7,8 @@ function getExtensionName(path, params) {
|
|
|
6
7
|
const dotIndex = baseName.lastIndexOf(".");
|
|
7
8
|
if (dotIndex <= 0 || dotIndex === baseName.length - 1) return null;
|
|
8
9
|
const extension = baseName.slice(dotIndex + 1);
|
|
9
|
-
|
|
10
|
+
const result = params?.withDot ? `.${extension}` : extension;
|
|
11
|
+
return require_isSegment.isSegment(result) ? result : null;
|
|
10
12
|
}
|
|
11
13
|
//#endregion
|
|
12
14
|
exports.getExtensionName = getExtensionName;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Absolute, Path } from './constraints';
|
|
1
|
+
import { Absolute, Path, Segment } from './constraints';
|
|
2
2
|
export interface GetExtensionNameParams {
|
|
3
3
|
withDot?: boolean;
|
|
4
4
|
}
|
|
5
|
-
export declare function getExtensionName<GenericPath extends string & (Path | Absolute)>(path: GenericPath, params?: GetExtensionNameParams): string | null;
|
|
5
|
+
export declare function getExtensionName<GenericPath extends string & (Path | Absolute | Segment)>(path: GenericPath, params?: GetExtensionNameParams): (string & Segment) | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isSegment } from "./isSegment.mjs";
|
|
1
2
|
//#region scripts/path/getExtensionName.ts
|
|
2
3
|
const basenameRegex = /([^/]+)$/;
|
|
3
4
|
function getExtensionName(path, params) {
|
|
@@ -6,7 +7,8 @@ function getExtensionName(path, params) {
|
|
|
6
7
|
const dotIndex = baseName.lastIndexOf(".");
|
|
7
8
|
if (dotIndex <= 0 || dotIndex === baseName.length - 1) return null;
|
|
8
9
|
const extension = baseName.slice(dotIndex + 1);
|
|
9
|
-
|
|
10
|
+
const result = params?.withDot ? `.${extension}` : extension;
|
|
11
|
+
return isSegment(result) ? result : null;
|
|
10
12
|
}
|
|
11
13
|
//#endregion
|
|
12
14
|
export { getExtensionName };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
//#region scripts/path/getParentFolderPath.ts
|
|
2
2
|
const parentFolderPathRegex = /^([^]*)\/[^/]+$/;
|
|
3
|
-
const
|
|
3
|
+
const onlyParentSegmentsRegex = /^(?:\.\.)(?:\/\.\.)*$/;
|
|
4
4
|
function getParentFolderPath(path) {
|
|
5
|
+
if (path === "/") return null;
|
|
6
|
+
if (path === ".") return "..";
|
|
7
|
+
if (onlyParentSegmentsRegex.test(path)) return `${path}/..`;
|
|
5
8
|
const parent = parentFolderPathRegex.exec(path)?.[1];
|
|
6
|
-
if (parent === void 0
|
|
9
|
+
if (parent === void 0) return ".";
|
|
10
|
+
if (parent === "") return "/";
|
|
7
11
|
return parent;
|
|
8
12
|
}
|
|
9
13
|
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Absolute, Path } from './constraints';
|
|
2
|
-
export declare function getParentFolderPath<GenericPath extends string & (Path | Absolute)>(path: GenericPath): string | null;
|
|
2
|
+
export declare function getParentFolderPath<GenericPath extends string & (Path | Absolute)>(path: GenericPath): (string & Path) | null;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
//#region scripts/path/getParentFolderPath.ts
|
|
2
2
|
const parentFolderPathRegex = /^([^]*)\/[^/]+$/;
|
|
3
|
-
const
|
|
3
|
+
const onlyParentSegmentsRegex = /^(?:\.\.)(?:\/\.\.)*$/;
|
|
4
4
|
function getParentFolderPath(path) {
|
|
5
|
+
if (path === "/") return null;
|
|
6
|
+
if (path === ".") return "..";
|
|
7
|
+
if (onlyParentSegmentsRegex.test(path)) return `${path}/..`;
|
|
5
8
|
const parent = parentFolderPathRegex.exec(path)?.[1];
|
|
6
|
-
if (parent === void 0
|
|
9
|
+
if (parent === void 0) return ".";
|
|
10
|
+
if (parent === "") return "/";
|
|
7
11
|
return parent;
|
|
8
12
|
}
|
|
9
13
|
//#endregion
|
package/dist/path/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_computeRelative = require("./computeRelative.cjs");
|
|
3
|
+
const require_isSegment = require("./isSegment.cjs");
|
|
3
4
|
const require_getBaseName = require("./getBaseName.cjs");
|
|
4
5
|
const require_getExtensionName = require("./getExtensionName.cjs");
|
|
5
6
|
const require_getParentFolderPath = require("./getParentFolderPath.cjs");
|
|
@@ -16,6 +17,7 @@ var path_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
16
17
|
getParentFolderPath: () => require_getParentFolderPath.getParentFolderPath,
|
|
17
18
|
is: () => require_is.is,
|
|
18
19
|
isAbsolute: () => require_isAbsolute.isAbsolute,
|
|
20
|
+
isSegment: () => require_isSegment.isSegment,
|
|
19
21
|
normalize: () => require_normalize.normalize,
|
|
20
22
|
resolveFrom: () => require_resolveFrom.resolveFrom,
|
|
21
23
|
resolveRelative: () => require_resolveRelative.resolveRelative
|
|
@@ -27,6 +29,7 @@ exports.getExtensionName = require_getExtensionName.getExtensionName;
|
|
|
27
29
|
exports.getParentFolderPath = require_getParentFolderPath.getParentFolderPath;
|
|
28
30
|
exports.is = require_is.is;
|
|
29
31
|
exports.isAbsolute = require_isAbsolute.isAbsolute;
|
|
32
|
+
exports.isSegment = require_isSegment.isSegment;
|
|
30
33
|
exports.normalize = require_normalize.normalize;
|
|
31
34
|
Object.defineProperty(exports, "path_exports", {
|
|
32
35
|
enumerable: true,
|
package/dist/path/index.d.ts
CHANGED
package/dist/path/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
import { computeRelative } from "./computeRelative.mjs";
|
|
3
|
+
import { isSegment } from "./isSegment.mjs";
|
|
3
4
|
import { getBaseName } from "./getBaseName.mjs";
|
|
4
5
|
import { getExtensionName } from "./getExtensionName.mjs";
|
|
5
6
|
import { getParentFolderPath } from "./getParentFolderPath.mjs";
|
|
@@ -16,9 +17,10 @@ var path_exports = /* @__PURE__ */ __exportAll({
|
|
|
16
17
|
getParentFolderPath: () => getParentFolderPath,
|
|
17
18
|
is: () => is,
|
|
18
19
|
isAbsolute: () => isAbsolute,
|
|
20
|
+
isSegment: () => isSegment,
|
|
19
21
|
normalize: () => normalize,
|
|
20
22
|
resolveFrom: () => resolveFrom,
|
|
21
23
|
resolveRelative: () => resolveRelative
|
|
22
24
|
});
|
|
23
25
|
//#endregion
|
|
24
|
-
export { computeRelative, getBaseName, getExtensionName, getParentFolderPath, is, isAbsolute, normalize, path_exports, resolveFrom, resolveRelative };
|
|
26
|
+
export { computeRelative, getBaseName, getExtensionName, getParentFolderPath, is, isAbsolute, isSegment, normalize, path_exports, resolveFrom, resolveRelative };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Segment } from './constraints';
|
|
2
|
+
import { IsLiteralSegmentPath } from './types';
|
|
3
|
+
import type * as DString from '../string';
|
|
4
|
+
export declare function isSegment<GenericValue extends string>(value: GenericValue): value is (GenericValue extends Segment ? GenericValue : IsLiteralSegmentPath<GenericValue> extends true ? GenericValue : DString.IsLiteral<GenericValue> extends true ? never : GenericValue & Segment);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Absolute, Path } from './constraints';
|
|
1
|
+
import { Absolute, Path, Segment } from './constraints';
|
|
2
2
|
import { RequireSegments } from './types';
|
|
3
3
|
import type * as DCommon from '../common';
|
|
4
4
|
export interface ResolveFromParams {
|
|
5
5
|
stayInOrigin?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare function resolveFrom<const GenericSegments extends readonly (string & (Path | Absolute))[], const GenericParams extends ResolveFromParams>(origin: string & Absolute, segments: GenericSegments & RequireSegments<GenericSegments>, params?: GenericParams): (string & Absolute) | (DCommon.BreakGenericLink<DCommon.Or<[
|
|
7
|
+
export declare function resolveFrom<const GenericSegments extends readonly (string & (Path | Absolute | Segment))[], const GenericParams extends ResolveFromParams>(origin: string & Absolute, segments: GenericSegments & RequireSegments<GenericSegments>, params?: GenericParams): (string & Absolute) | (DCommon.BreakGenericLink<DCommon.Or<[
|
|
8
8
|
DCommon.IsEqual<GenericParams["stayInOrigin"], ResolveFromParams["stayInOrigin"]>,
|
|
9
9
|
DCommon.IsEqual<GenericParams["stayInOrigin"], false>,
|
|
10
10
|
DCommon.IsEqual<GenericParams["stayInOrigin"], unknown>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Absolute, Path } from './constraints';
|
|
1
|
+
import { Absolute, Path, Segment } from './constraints';
|
|
2
2
|
import { RequireSegments } from './types';
|
|
3
3
|
import type * as DCommon from '../common';
|
|
4
|
-
type HasAbsolutePath<GenericSegments extends readonly (string & (Path | Absolute))[]> = DCommon.ContainExtends<{
|
|
4
|
+
type HasAbsolutePath<GenericSegments extends readonly (string & (Path | Absolute | Segment))[]> = DCommon.ContainExtends<{
|
|
5
5
|
[Prop in keyof GenericSegments]: [DCommon.IsExtends<GenericSegments[Prop], Absolute>];
|
|
6
6
|
}[Extract<keyof GenericSegments, number>], [
|
|
7
7
|
true
|
|
8
8
|
]>;
|
|
9
|
-
export declare function resolveRelative<const GenericSegments extends readonly (string & (Path | Absolute))[]>(segments: GenericSegments & RequireSegments<GenericSegments>): string & Path & (DCommon.BreakGenericLink<HasAbsolutePath<GenericSegments> extends true ? Absolute : unknown>);
|
|
9
|
+
export declare function resolveRelative<const GenericSegments extends readonly (string & (Path | Absolute | Segment))[]>(segments: GenericSegments & RequireSegments<GenericSegments>): string & Path & (DCommon.BreakGenericLink<HasAbsolutePath<GenericSegments> extends true ? Absolute : unknown>);
|
|
10
10
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type * from './isLiteralAbsolutePath';
|
|
2
2
|
export type * from './isLiteralPath';
|
|
3
|
+
export type * from './isLiteralSegmentPath';
|
|
3
4
|
export type * from './requireLiteralAbsolutePath';
|
|
4
5
|
export type * from './requireLiteralPath';
|
|
6
|
+
export type * from './requireLiteralSegmentPath';
|
|
5
7
|
export type * from './requireSegments';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as DCommon from '../../common';
|
|
2
|
+
import type * as DString from '../../string';
|
|
3
|
+
export type IsLiteralSegmentPath<GenericValue extends string> = DString.IsLiteral<GenericValue> extends true ? DCommon.Not<DCommon.Or<[
|
|
4
|
+
DCommon.IsEqual<GenericValue, ".">,
|
|
5
|
+
DCommon.IsEqual<GenericValue, "..">,
|
|
6
|
+
DCommon.IsEqual<GenericValue, "">,
|
|
7
|
+
DString.Includes<GenericValue, "/">,
|
|
8
|
+
DString.Includes<GenericValue, "\0">
|
|
9
|
+
]>> : false;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IsLiteralSegmentPath } from './isLiteralSegmentPath';
|
|
2
|
+
import type * as DCommon from '../../common';
|
|
3
|
+
export type RequireLiteralSegmentPath<GenericValue extends string> = IsLiteralSegmentPath<GenericValue> extends true ? unknown : DCommon.ComputedTypeError<"Value is not a segment path.">;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Create } from './types';
|
|
2
|
+
import type * as DArray from '../array';
|
|
3
|
+
type FromOutput<GenericArray extends readonly unknown[]> = DArray.ExtractLengthEqual<GenericArray, unknown> extends DArray.LengthEqual<infer InferredLength extends number> ? DArray.ReapplyCompatiblesConstraints<GenericArray, Create<GenericArray[number], InferredLength>, "maxElements"> : DArray.ExtractMinElements<GenericArray, unknown> extends DArray.MinElements<infer InferredMin extends number> ? DArray.ReapplyCompatiblesConstraints<GenericArray, readonly [
|
|
4
|
+
...Create<GenericArray[number], InferredMin>,
|
|
5
|
+
...GenericArray[number][]
|
|
6
|
+
], "maxElements"> : GenericArray;
|
|
7
|
+
export declare function from<GenericArray extends readonly unknown[]>(source: GenericArray): FromOutput<GenericArray>;
|
|
8
|
+
export {};
|
package/dist/tuple/index.cjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_map = require("./map.cjs");
|
|
3
|
+
const require_from = require("./from.cjs");
|
|
3
4
|
//#region scripts/tuple/index.ts
|
|
4
|
-
var tuple_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
5
|
+
var tuple_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
6
|
+
from: () => require_from.from,
|
|
7
|
+
map: () => require_map.map
|
|
8
|
+
});
|
|
5
9
|
//#endregion
|
|
10
|
+
exports.from = require_from.from;
|
|
6
11
|
exports.map = require_map.map;
|
|
7
12
|
Object.defineProperty(exports, "tuple_exports", {
|
|
8
13
|
enumerable: true,
|
package/dist/tuple/index.d.ts
CHANGED
package/dist/tuple/index.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
import { map } from "./map.mjs";
|
|
3
|
+
import { from } from "./from.mjs";
|
|
3
4
|
//#region scripts/tuple/index.ts
|
|
4
|
-
var tuple_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
var tuple_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
from: () => from,
|
|
7
|
+
map: () => map
|
|
8
|
+
});
|
|
5
9
|
//#endregion
|
|
6
|
-
export { map, tuple_exports };
|
|
10
|
+
export { from, map, tuple_exports };
|