@duplojs/agents-kit 0.1.0-beta.3 → 0.1.0-beta.6
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/README.md +11 -11
- package/dist/bin/index.mjs +2 -2
- package/dist/bin/installSkill/index.d.ts +2 -0
- package/dist/bin/{install → installSkill}/index.mjs +3 -3
- package/dist/bin/{install → installSkill}/skill.mjs +1 -1
- package/dist/bin/setup/instructions.d.ts +1 -1
- package/docs/API/10-lang/10-array/10-at.ts +4 -4
- package/docs/API/10-lang/10-array/10-coalescing.ts +3 -2
- package/docs/API/10-lang/10-array/10-indexOf.ts +1 -1
- package/docs/API/10-lang/10-array/10-is.ts +17 -3
- package/docs/API/10-lang/10-array/10-lastIndexOf.ts +1 -1
- package/docs/API/10-lang/10-chrono/10-addTime.ts +1 -1
- package/docs/API/10-lang/10-chrono/10-closestTo.ts +5 -8
- package/docs/API/10-lang/10-chrono/10-isDate.ts +15 -2
- package/docs/API/10-lang/10-chrono/10-isSerializedTheDate.ts +16 -1
- package/docs/API/10-lang/10-chrono/10-isSerializedTheTime.ts +16 -1
- package/docs/API/10-lang/10-chrono/10-isTime.ts +15 -2
- package/docs/API/10-lang/10-chrono/10-maxDate.ts +4 -8
- package/docs/API/10-lang/10-chrono/10-maxTime.ts +4 -8
- package/docs/API/10-lang/10-chrono/10-minDate.ts +4 -8
- package/docs/API/10-lang/10-chrono/10-minTime.ts +4 -8
- package/docs/API/10-lang/10-chrono/10-sortDates.ts +6 -8
- package/docs/API/10-lang/10-chrono/10-sortTimes.ts +6 -8
- package/docs/API/10-lang/10-chrono/10-subtractTime.ts +1 -1
- package/docs/API/10-lang/10-common/10-and.ts +6 -0
- package/docs/API/10-lang/10-common/10-createQueue.ts +4 -3
- package/docs/API/10-lang/10-common/10-createTransformer.ts +1 -1
- package/docs/API/10-lang/10-common/10-equal.ts +6 -0
- package/docs/API/10-lang/10-common/10-falsy.ts +19 -0
- package/docs/API/10-lang/10-common/10-instanceOf.ts +14 -3
- package/docs/API/10-lang/10-common/10-isType.ts +6 -0
- package/docs/API/10-lang/10-common/10-justExec.ts +3 -3
- package/docs/API/10-lang/10-common/10-or.ts +17 -3
- package/docs/API/10-lang/10-common/10-tap.ts +28 -0
- package/docs/API/10-lang/10-common/10-toJSON.ts +1 -1
- package/docs/API/10-lang/10-common/10-toNative.ts +1 -1
- package/docs/API/10-lang/10-common/10-toRegExp.ts +1 -1
- package/docs/API/10-lang/10-common/10-truthy.ts +19 -0
- package/docs/API/10-lang/10-common/10-whenNot.ts +44 -13
- package/docs/API/10-lang/10-common/index.llms.md +4 -0
- package/docs/API/10-lang/10-dataStructure/10-typeStructureIdentifier.ts +2 -2
- package/docs/API/10-lang/10-either/10-asyncGroup.ts +1 -1
- package/docs/API/10-lang/10-either/10-asyncSafeCallback.ts +4 -2
- package/docs/API/10-lang/10-either/10-extractErrorInLeft.ts +45 -0
- package/docs/API/10-lang/10-either/10-forwardAssertsSelection.ts +1 -1
- package/docs/API/10-lang/10-either/10-group.ts +1 -1
- package/docs/API/10-lang/10-either/10-hasInformation.ts +6 -0
- package/docs/API/10-lang/10-either/10-isLeft.ts +10 -1
- package/docs/API/10-lang/10-either/10-isRight.ts +10 -1
- package/docs/API/10-lang/10-either/10-isSelected.ts +13 -1
- package/docs/API/10-lang/10-either/10-keepAsRightSelection.ts +1 -1
- package/docs/API/10-lang/10-either/10-matchInformation.ts +7 -5
- package/docs/API/10-lang/10-either/10-matchInformationCombination.ts +61 -0
- package/docs/API/10-lang/10-either/10-matchInformationCombinationOtherwise.ts +62 -0
- package/docs/API/10-lang/10-either/10-matchInformationOtherwise.ts +7 -5
- package/docs/API/10-lang/10-either/10-rightAsyncPipe.ts +2 -1
- package/docs/API/10-lang/10-either/10-rightPipe.ts +1 -1
- package/docs/API/10-lang/10-either/10-safeCallback.ts +1 -1
- package/docs/API/10-lang/10-either/10-unwrapOr.ts +2 -2
- package/docs/API/10-lang/10-either/10-unwrapOtherwise.ts +2 -2
- package/docs/API/10-lang/10-either/10-whenHasInformation.ts +4 -3
- package/docs/API/10-lang/10-either/10-whenHasInformationOtherwise.ts +5 -5
- package/docs/API/10-lang/10-either/10-whenIsLeft.ts +2 -2
- package/docs/API/10-lang/10-either/10-whenIsLeftOtherwise.ts +5 -5
- package/docs/API/10-lang/10-either/10-whenIsRight.ts +2 -2
- package/docs/API/10-lang/10-either/10-whenIsRightOtherwise.ts +7 -7
- package/docs/API/10-lang/10-either/10-whenIsSelected.ts +5 -5
- package/docs/API/10-lang/10-either/10-whenIsSelectedOtherwise.ts +5 -5
- package/docs/API/10-lang/10-either/index.llms.md +12 -0
- package/docs/API/10-lang/10-generator/10-asyncConcat.ts +7 -10
- package/docs/API/10-lang/10-generator/10-asyncFlat.ts +6 -6
- package/docs/API/10-lang/10-generator/10-concat.ts +3 -3
- package/docs/API/10-lang/10-generator/10-flat.ts +2 -2
- package/docs/API/10-lang/10-generator/10-map.ts +1 -1
- package/docs/API/10-lang/10-generator/10-reduce.ts +1 -1
- package/docs/API/10-lang/10-number/10-betweenThan.ts +43 -0
- package/docs/API/10-lang/10-number/10-betweenThanOrEqual.ts +43 -0
- package/docs/API/10-lang/10-number/10-greaterThan.ts +35 -0
- package/docs/API/10-lang/10-number/10-greaterThanOrEqual.ts +35 -0
- package/docs/API/10-lang/10-number/10-isEven.ts +33 -0
- package/docs/API/10-lang/10-number/10-isInteger.ts +33 -0
- package/docs/API/10-lang/10-number/10-isMultipleOf.ts +35 -0
- package/docs/API/10-lang/10-number/10-isNegative.ts +33 -0
- package/docs/API/10-lang/10-number/10-isNotZero.ts +33 -0
- package/docs/API/10-lang/10-number/10-isOdd.ts +33 -0
- package/docs/API/10-lang/10-number/10-isPositive.ts +33 -0
- package/docs/API/10-lang/10-number/10-isSafe.ts +33 -0
- package/docs/API/10-lang/10-number/10-isStrictNegative.ts +34 -0
- package/docs/API/10-lang/10-number/10-isStrictPositive.ts +33 -0
- package/docs/API/10-lang/10-number/10-lessThan.ts +35 -0
- package/docs/API/10-lang/10-number/10-lessThanOrEqual.ts +35 -0
- package/docs/API/10-lang/10-number/10-max.ts +19 -0
- package/docs/API/10-lang/10-number/10-maxOf.ts +19 -0
- package/docs/API/10-lang/10-number/10-min.ts +19 -0
- package/docs/API/10-lang/10-number/10-minOf.ts +19 -0
- package/docs/API/10-lang/10-number/10-sort.ts +19 -0
- package/docs/API/10-lang/10-number/10-sum.ts +19 -0
- package/docs/API/10-lang/10-number/index.llms.md +92 -0
- package/docs/API/10-lang/10-number/index.md +3 -0
- package/docs/API/10-lang/10-object/10-assign.ts +41 -0
- package/docs/API/10-lang/10-object/10-countKeys.ts +15 -0
- package/docs/API/10-lang/10-object/10-deepDiscriminate.ts +63 -0
- package/docs/API/10-lang/10-object/10-deepOverride.ts +35 -0
- package/docs/API/10-lang/10-object/10-discriminate.ts +55 -0
- package/docs/API/10-lang/10-object/10-discriminateEntryKey.ts +43 -0
- package/docs/API/10-lang/10-object/10-discriminateEntryValue.ts +44 -0
- package/docs/API/10-lang/10-object/10-entries.ts +19 -0
- package/docs/API/10-lang/10-object/10-entry.ts +17 -0
- package/docs/API/10-lang/10-object/10-fromEntries.ts +23 -0
- package/docs/API/10-lang/10-object/10-getDeepProperty.ts +26 -0
- package/docs/API/10-lang/10-object/10-getProperty.ts +24 -0
- package/docs/API/10-lang/10-object/10-hasKeys.ts +43 -0
- package/docs/API/10-lang/10-object/10-isSimple.ts +38 -0
- package/docs/API/10-lang/10-object/10-keys.ts +19 -0
- package/docs/API/10-lang/10-object/10-omit.ts +39 -0
- package/docs/API/10-lang/10-object/10-override.ts +24 -0
- package/docs/API/10-lang/10-object/10-pick.ts +41 -0
- package/docs/API/10-lang/10-object/10-to.ts +40 -0
- package/docs/API/10-lang/10-object/10-transformProperties.ts +43 -0
- package/docs/API/10-lang/10-object/10-transformProperty.ts +39 -0
- package/docs/API/10-lang/10-object/10-values.ts +19 -0
- package/docs/API/10-lang/10-object/index.llms.md +92 -0
- package/docs/API/10-lang/10-object/index.md +3 -0
- package/docs/API/10-lang/10-path/10-computeRelative.ts +19 -0
- package/docs/API/10-lang/10-path/10-concatSegment.ts +28 -0
- package/docs/API/10-lang/10-path/10-create.ts +21 -0
- package/docs/API/10-lang/10-path/10-createAbsolute.ts +21 -0
- package/docs/API/10-lang/10-path/10-createAbsoluteOrThrow.ts +16 -0
- package/docs/API/10-lang/10-path/10-createMatcher.ts +50 -0
- package/docs/API/10-lang/10-path/10-createOrThrow.ts +16 -0
- package/docs/API/10-lang/10-path/10-createSegment.ts +26 -0
- package/docs/API/10-lang/10-path/10-createSegmentOrThrow.ts +16 -0
- package/docs/API/10-lang/10-path/10-declareAbsolutePath.ts +15 -0
- package/docs/API/10-lang/10-path/10-declarePath.ts +15 -0
- package/docs/API/10-lang/10-path/10-declareSegment.ts +15 -0
- package/docs/API/10-lang/10-path/10-getBaseName.ts +22 -0
- package/docs/API/10-lang/10-path/10-getExtensionName.ts +22 -0
- package/docs/API/10-lang/10-path/10-getParentFolderPath.ts +25 -0
- package/docs/API/10-lang/10-path/10-is.ts +46 -0
- package/docs/API/10-lang/10-path/10-isAbsolute.ts +46 -0
- package/docs/API/10-lang/10-path/10-isSegment.ts +42 -0
- package/docs/API/10-lang/10-path/10-normalize.ts +26 -0
- package/docs/API/10-lang/10-path/10-resolveFrom.ts +37 -0
- package/docs/API/10-lang/10-path/10-resolveRelative.ts +23 -0
- package/docs/API/10-lang/10-path/index.llms.md +88 -0
- package/docs/API/10-lang/10-path/index.md +3 -0
- package/docs/API/10-lang/10-pattern/10-exhaustive.ts +26 -0
- package/docs/API/10-lang/10-pattern/10-isMatch.ts +72 -0
- package/docs/API/10-lang/10-pattern/10-match.ts +133 -0
- package/docs/API/10-lang/10-pattern/10-matchWithEntity.ts +49 -0
- package/docs/API/10-lang/10-pattern/10-matchWithEntityOtherwise.ts +55 -0
- package/docs/API/10-lang/10-pattern/10-matchWithError.ts +45 -0
- package/docs/API/10-lang/10-pattern/10-matchWithErrorOtherwise.ts +48 -0
- package/docs/API/10-lang/10-pattern/10-matchWithFact.ts +49 -0
- package/docs/API/10-lang/10-pattern/10-matchWithFactOtherwise.ts +49 -0
- package/docs/API/10-lang/10-pattern/10-matchWithNumber.ts +33 -0
- package/docs/API/10-lang/10-pattern/10-matchWithNumberOtherwise.ts +37 -0
- package/docs/API/10-lang/10-pattern/10-matchWithString.ts +34 -0
- package/docs/API/10-lang/10-pattern/10-matchWithStringOtherwise.ts +35 -0
- package/docs/API/10-lang/10-pattern/10-matchWithTaggedObject.ts +43 -0
- package/docs/API/10-lang/10-pattern/10-matchWithTaggedObjectOtherwise.ts +49 -0
- package/docs/API/10-lang/10-pattern/10-otherwise.ts +28 -0
- package/docs/API/10-lang/10-pattern/10-union.ts +47 -0
- package/docs/API/10-lang/10-pattern/10-when.ts +46 -0
- package/docs/API/10-lang/10-pattern/10-whenNot.ts +123 -0
- package/docs/API/10-lang/10-pattern/index.llms.md +80 -0
- package/docs/API/10-lang/10-pattern/index.md +3 -0
- package/docs/API/10-lang/10-printer/10-bold.ts +12 -0
- package/docs/API/10-lang/10-printer/10-colorized.ts +18 -0
- package/docs/API/10-lang/10-printer/10-colorizedBold.ts +18 -0
- package/docs/API/10-lang/10-printer/10-indent.ts +20 -0
- package/docs/API/10-lang/10-printer/10-primitives.md +11 -0
- package/docs/API/10-lang/10-printer/10-render.ts +29 -0
- package/docs/API/10-lang/10-printer/10-renderLine.ts +12 -0
- package/docs/API/10-lang/10-printer/10-renderParagraph.ts +16 -0
- package/docs/API/10-lang/10-printer/index.llms.md +37 -0
- package/docs/API/10-lang/10-printer/index.md +3 -0
- package/docs/API/10-lang/10-string/10-at.ts +18 -0
- package/docs/API/10-lang/10-string/10-capitalize.ts +18 -0
- package/docs/API/10-lang/10-string/10-charAt.ts +18 -0
- package/docs/API/10-lang/10-string/10-concat.ts +18 -0
- package/docs/API/10-lang/10-string/10-endsWith.ts +33 -0
- package/docs/API/10-lang/10-string/10-extract.ts +18 -0
- package/docs/API/10-lang/10-string/10-extractAll.ts +18 -0
- package/docs/API/10-lang/10-string/10-first.ts +17 -0
- package/docs/API/10-lang/10-string/10-includes.ts +33 -0
- package/docs/API/10-lang/10-string/10-indexOf.ts +17 -0
- package/docs/API/10-lang/10-string/10-isComposedOf.ts +33 -0
- package/docs/API/10-lang/10-string/10-isEmail.ts +56 -0
- package/docs/API/10-lang/10-string/10-isIn.ts +34 -0
- package/docs/API/10-lang/10-string/10-isKeyof.ts +37 -0
- package/docs/API/10-lang/10-string/10-isNotEmpty.ts +32 -0
- package/docs/API/10-lang/10-string/10-isNumber.ts +32 -0
- package/docs/API/10-lang/10-string/10-isTrimmed.ts +33 -0
- package/docs/API/10-lang/10-string/10-isUrl.ts +31 -0
- package/docs/API/10-lang/10-string/10-isUuid.ts +31 -0
- package/docs/API/10-lang/10-string/10-join.ts +18 -0
- package/docs/API/10-lang/10-string/10-last.ts +17 -0
- package/docs/API/10-lang/10-string/10-lastIndexOf.ts +17 -0
- package/docs/API/10-lang/10-string/10-length.ts +18 -0
- package/docs/API/10-lang/10-string/10-lengthEqual.ts +33 -0
- package/docs/API/10-lang/10-string/10-maxCharacters.ts +33 -0
- package/docs/API/10-lang/10-string/10-minCharacters.ts +33 -0
- package/docs/API/10-lang/10-string/10-normalize.ts +17 -0
- package/docs/API/10-lang/10-string/10-padEnd.ts +17 -0
- package/docs/API/10-lang/10-string/10-padStart.ts +17 -0
- package/docs/API/10-lang/10-string/10-pop.ts +17 -0
- package/docs/API/10-lang/10-string/10-prepend.ts +17 -0
- package/docs/API/10-lang/10-string/10-repeat.ts +17 -0
- package/docs/API/10-lang/10-string/10-replace.ts +18 -0
- package/docs/API/10-lang/10-string/10-replaceAll.ts +17 -0
- package/docs/API/10-lang/10-string/10-search.ts +17 -0
- package/docs/API/10-lang/10-string/10-shift.ts +17 -0
- package/docs/API/10-lang/10-string/10-slice.ts +17 -0
- package/docs/API/10-lang/10-string/10-sort.ts +19 -0
- package/docs/API/10-lang/10-string/10-sortCompare.ts +17 -0
- package/docs/API/10-lang/10-string/10-split.ts +34 -0
- package/docs/API/10-lang/10-string/10-startsWith.ts +33 -0
- package/docs/API/10-lang/10-string/10-stringify.ts +11 -0
- package/docs/API/10-lang/10-string/10-substring.ts +17 -0
- package/docs/API/10-lang/10-string/10-test.ts +17 -0
- package/docs/API/10-lang/10-string/10-to.ts +11 -0
- package/docs/API/10-lang/10-string/10-toLowerCase.ts +17 -0
- package/docs/API/10-lang/10-string/10-toUpperCase.ts +17 -0
- package/docs/API/10-lang/10-string/10-trim.ts +17 -0
- package/docs/API/10-lang/10-string/10-trimEnd.ts +17 -0
- package/docs/API/10-lang/10-string/10-trimStart.ts +17 -0
- package/docs/API/10-lang/10-string/10-uncapitalize.ts +17 -0
- package/docs/API/10-lang/10-string/index.llms.md +208 -0
- package/docs/API/10-lang/10-string/index.md +3 -0
- package/docs/API/10-lang/10-tuple/10-from.ts +50 -0
- package/docs/API/10-lang/10-tuple/10-map.ts +37 -0
- package/docs/API/10-lang/10-tuple/index.llms.md +12 -0
- package/docs/API/10-lang/10-tuple/index.md +3 -0
- package/docs/API/40-json-web-token/10-tokenHandler/10-createTokenHandler.ts +160 -0
- package/docs/API/40-json-web-token/10-tokenHandler/index.llms.md +8 -0
- package/docs/API/40-json-web-token/10-tokenHandler/index.md +3 -0
- package/docs/API/40-json-web-token/20-signer/10-createHS256.ts +24 -0
- package/docs/API/40-json-web-token/20-signer/10-createHS512.ts +24 -0
- package/docs/API/40-json-web-token/20-signer/10-createRS256.ts +28 -0
- package/docs/API/40-json-web-token/20-signer/10-createRS512.ts +28 -0
- package/docs/API/40-json-web-token/20-signer/10-factory.ts +29 -0
- package/docs/API/40-json-web-token/20-signer/index.llms.md +24 -0
- package/docs/API/40-json-web-token/20-signer/index.md +3 -0
- package/docs/API/40-json-web-token/30-cipher/10-createRSAOAEP.ts +26 -0
- package/docs/API/40-json-web-token/30-cipher/10-createRSAOAEP256.ts +26 -0
- package/docs/API/40-json-web-token/30-cipher/10-factory.ts +29 -0
- package/docs/API/40-json-web-token/30-cipher/index.llms.md +16 -0
- package/docs/API/40-json-web-token/30-cipher/index.md +3 -0
- package/docs/API/40-json-web-token/40-utils/10-AES_GCM.decrypt.ts +17 -0
- package/docs/API/40-json-web-token/40-utils/10-AES_GCM.encrypt.ts +11 -0
- package/docs/API/40-json-web-token/40-utils/10-AES_GCM.generateInitializationVector.ts +9 -0
- package/docs/API/40-json-web-token/40-utils/10-HMAC.sign.ts +13 -0
- package/docs/API/40-json-web-token/40-utils/10-HMAC.verify.ts +11 -0
- package/docs/API/40-json-web-token/40-utils/10-RSA.sign.ts +14 -0
- package/docs/API/40-json-web-token/40-utils/10-RSA.verify.ts +13 -0
- package/docs/API/40-json-web-token/40-utils/10-RSA_OAEP.decrypt.ts +13 -0
- package/docs/API/40-json-web-token/40-utils/10-RSA_OAEP.encrypt.ts +10 -0
- package/docs/API/40-json-web-token/40-utils/10-decodeBase64.ts +9 -0
- package/docs/API/40-json-web-token/40-utils/10-decodeBase64Url.ts +9 -0
- package/docs/API/40-json-web-token/40-utils/10-decodeText.ts +9 -0
- package/docs/API/40-json-web-token/40-utils/10-encodeBase64.ts +9 -0
- package/docs/API/40-json-web-token/40-utils/10-encodeBase64Url.ts +9 -0
- package/docs/API/40-json-web-token/40-utils/10-encodeText.ts +9 -0
- package/docs/API/40-json-web-token/40-utils/10-isBase64Url.ts +11 -0
- package/docs/API/40-json-web-token/40-utils/10-jsonParse.ts +11 -0
- package/docs/API/40-json-web-token/40-utils/10-pemToBinary.ts +11 -0
- package/docs/API/40-json-web-token/40-utils/index.llms.md +76 -0
- package/docs/API/40-json-web-token/40-utils/index.md +3 -0
- package/docs/API/40-json-web-token/index.md +3 -0
- package/docs/API/50-form/10-vue/10-construction/10-createForm.ts +48 -0
- package/docs/API/50-form/10-vue/10-construction/10-createFormField.ts +66 -0
- package/docs/API/50-form/10-vue/10-construction/10-createGridTemplates.ts +39 -0
- package/docs/API/50-form/10-vue/10-construction/10-createInput.ts +46 -0
- package/docs/API/50-form/10-vue/10-construction/10-createTemplate.ts +36 -0
- package/docs/API/50-form/10-vue/10-construction/fixtures/AddressInput.vue +19 -0
- package/docs/API/50-form/10-vue/10-construction/index.llms.md +24 -0
- package/docs/API/50-form/10-vue/10-construction/index.md +3 -0
- package/docs/API/50-form/10-vue/20-layouts/10-useCheckLayout.ts +40 -0
- package/docs/API/50-form/10-vue/20-layouts/10-useDisabledLayout.ts +34 -0
- package/docs/API/50-form/10-vue/20-layouts/10-useMultiLayout.ts +32 -0
- package/docs/API/50-form/10-vue/20-layouts/10-useRepeatLayout.ts +34 -0
- package/docs/API/50-form/10-vue/20-layouts/10-useSectionLayout.ts +20 -0
- package/docs/API/50-form/10-vue/20-layouts/10-useSlotLayout.ts +37 -0
- package/docs/API/50-form/10-vue/20-layouts/10-useStepLayout.ts +31 -0
- package/docs/API/50-form/10-vue/20-layouts/10-useUnionLayout.ts +48 -0
- package/docs/API/50-form/10-vue/20-layouts/index.llms.md +36 -0
- package/docs/API/50-form/10-vue/20-layouts/index.md +3 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useCheckbox.ts +13 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useCheckboxPolicy.ts +18 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useDateInput.ts +20 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useDualRangeInput.ts +27 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useFileInput.ts +23 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useNumberInput.ts +18 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useRadioGroup.ts +31 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useRangeDateInput.ts +23 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useRangeInput.ts +18 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useRangeTimeInput.ts +23 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useSelectInput.ts +31 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useTextInput.ts +14 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useTextareaInput.ts +14 -0
- package/docs/API/50-form/10-vue/30-designSystem/10-useTimeInput.ts +20 -0
- package/docs/API/50-form/10-vue/30-designSystem/20-components.md +11 -0
- package/docs/API/50-form/10-vue/30-designSystem/index.llms.md +65 -0
- package/docs/API/50-form/10-vue/30-designSystem/index.md +3 -0
- package/docs/API/50-form/10-vue/fixtures/templates.ts +20 -0
- package/docs/API/50-form/10-vue/index.md +3 -0
- package/docs/API/50-form/index.md +3 -0
- package/docs/API/60-playwright/10-construction/10-createComponent.ts +47 -0
- package/docs/API/60-playwright/10-construction/10-createComponentInteraction.ts +28 -0
- package/docs/API/60-playwright/10-construction/10-createPage.ts +34 -0
- package/docs/API/60-playwright/10-construction/10-createStepWrapper.ts +23 -0
- package/docs/API/60-playwright/10-construction/10-createWebsite.ts +57 -0
- package/docs/API/60-playwright/10-construction/10-initClient.ts +38 -0
- package/docs/API/60-playwright/10-construction/index.llms.md +28 -0
- package/docs/API/60-playwright/10-construction/index.md +3 -0
- package/docs/API/60-playwright/20-actions/10-check.ts +9 -0
- package/docs/API/60-playwright/20-actions/10-clear.ts +9 -0
- package/docs/API/60-playwright/20-actions/10-click.ts +9 -0
- package/docs/API/60-playwright/20-actions/10-dragTo.ts +10 -0
- package/docs/API/60-playwright/20-actions/10-extractContent.ts +10 -0
- package/docs/API/60-playwright/20-actions/10-fill.ts +9 -0
- package/docs/API/60-playwright/20-actions/10-focus.ts +9 -0
- package/docs/API/60-playwright/20-actions/10-forceClick.ts +10 -0
- package/docs/API/60-playwright/20-actions/10-hover.ts +9 -0
- package/docs/API/60-playwright/20-actions/10-press.ts +9 -0
- package/docs/API/60-playwright/20-actions/10-selectOption.ts +10 -0
- package/docs/API/60-playwright/20-actions/10-type.ts +10 -0
- package/docs/API/60-playwright/20-actions/10-uncheck.ts +9 -0
- package/docs/API/60-playwright/20-actions/10-withStep.ts +10 -0
- package/docs/API/60-playwright/20-actions/index.llms.md +60 -0
- package/docs/API/60-playwright/20-actions/index.md +3 -0
- package/docs/API/60-playwright/30-assertions/10-toBeBusy.ts +10 -0
- package/docs/API/60-playwright/30-assertions/10-toBeChecked.ts +9 -0
- package/docs/API/60-playwright/30-assertions/10-toBeDisabled.ts +9 -0
- package/docs/API/60-playwright/30-assertions/10-toBeEnabled.ts +9 -0
- package/docs/API/60-playwright/30-assertions/10-toBeHidden.ts +9 -0
- package/docs/API/60-playwright/30-assertions/10-toBeNotBusy.ts +10 -0
- package/docs/API/60-playwright/30-assertions/10-toBeVisible.ts +10 -0
- package/docs/API/60-playwright/30-assertions/10-toContainText.ts +9 -0
- package/docs/API/60-playwright/30-assertions/10-toHaveAttribute.ts +12 -0
- package/docs/API/60-playwright/30-assertions/10-toHaveClass.ts +9 -0
- package/docs/API/60-playwright/30-assertions/10-toHaveNoText.ts +10 -0
- package/docs/API/60-playwright/30-assertions/10-toHaveQuantity.ts +20 -0
- package/docs/API/60-playwright/30-assertions/10-toHaveText.ts +9 -0
- package/docs/API/60-playwright/30-assertions/10-toHaveValue.ts +9 -0
- package/docs/API/60-playwright/30-assertions/10-withStep.ts +10 -0
- package/docs/API/60-playwright/30-assertions/index.llms.md +64 -0
- package/docs/API/60-playwright/30-assertions/index.md +3 -0
- package/docs/API/60-playwright/fixtures/component.ts +44 -0
- package/docs/API/60-playwright/index.md +3 -0
- package/docs/API.llms.md +84 -0
- package/docs/concepts/01-fundamental/01-constraint/20-manipulation.ts +9 -6
- package/docs/concepts/01-fundamental/01-constraint/30-cast.ts +9 -5
- package/docs/concepts/01-fundamental/02-currying/01-use.ts +5 -0
- package/docs/concepts/01-fundamental/02-currying/10-built-in-function.ts +28 -16
- package/docs/concepts/01-fundamental/02-currying/20-inner-pipe.ts +11 -2
- package/docs/concepts/01-fundamental/02-currying/30-async-pipe.ts +11 -2
- package/docs/concepts/01-fundamental/03-either/10-discrimination.ts +23 -12
- package/docs/concepts/01-fundamental/03-either/20-exhaustive-handling.ts +27 -10
- package/docs/concepts/01-fundamental/03-either/30-composition.ts +18 -10
- package/docs/concepts/01-fundamental/03-either/40-result-adaptation.ts +10 -4
- package/docs/concepts/01-fundamental/03-either/50-external-results.ts +16 -3
- package/docs/concepts/01-fundamental/04-data-structure/10-structure.ts +110 -59
- package/docs/concepts/01-fundamental/04-data-structure/20-constraint.ts +20 -12
- package/docs/concepts/01-fundamental/04-data-structure/30-validation.ts +13 -9
- package/docs/concepts/01-fundamental/04-data-structure/40-codecs.ts +31 -20
- package/docs/concepts/01-fundamental/04-data-structure/50-recursive.ts +10 -1
- package/docs/concepts/01-fundamental/05-chrono/10-creation.ts +39 -13
- package/docs/concepts/01-fundamental/05-chrono/20-manipulation.ts +20 -4
- package/docs/concepts/01-fundamental/05-chrono/30-serialized.ts +22 -6
- package/docs/concepts/01-fundamental/05-chrono/40-timezone.ts +5 -1
- package/docs/concepts/01-fundamental/06-modeling/20-entity.ts +29 -42
- package/docs/concepts/01-fundamental/06-modeling/30-tagged-object.ts +46 -23
- package/docs/concepts/01-fundamental/06-modeling/40-entity-lifecycle.ts +30 -33
- package/docs/concepts/01-fundamental/07-discrimination/10-entity.ts +52 -20
- package/docs/concepts/01-fundamental/07-discrimination/20-fact.ts +54 -38
- package/docs/concepts/01-fundamental/07-discrimination/30-tagged-object.ts +52 -20
- package/docs/concepts/01-fundamental/07-discrimination/40-error.ts +26 -10
- package/docs/concepts/01-fundamental/07-discrimination/50-literal.ts +29 -10
- package/docs/concepts/01-fundamental/07-discrimination/60-shape.ts +10 -2
- package/docs/concepts/01-fundamental/07-discrimination/70-predicate.ts +18 -6
- package/docs/concepts/01-fundamental/08-kind/01-identity.md +7 -0
- package/docs/concepts/01-fundamental/08-kind/20-metadata.md +11 -0
- package/docs/concepts/01-fundamental/08-kind/30-transport.md +11 -0
- package/docs/concepts/01-fundamental/08-kind/index.md +3 -0
- package/docs/concepts/02-server/10-file/10-manipulation.ts +15 -3
- package/docs/concepts/02-server/10-file/20-path.ts +22 -6
- package/docs/concepts/02-server/20-http/10-init.ts +1 -9
- package/docs/concepts/02-server/20-http/20-route.ts +40 -32
- package/docs/concepts/02-server/20-http/30-routine.ts +12 -19
- package/docs/concepts/02-server/20-http/40-jwt.ts +49 -37
- package/docs/concepts/02-server/20-http/50-open-api.ts +44 -0
- package/docs/concepts/02-server/20-http/index.md +1 -1
- package/docs/concepts/02-server/30-environment/10-platform.ts +12 -3
- package/docs/concepts/02-server/30-environment/20-variable.ts +13 -7
- package/docs/concepts/03-client/10-http/10-init.ts +11 -23
- package/docs/concepts/03-client/10-http/20-request.ts +79 -69
- package/docs/concepts/03-client/10-http/30-hook.ts +23 -23
- package/docs/concepts/03-client/20-form/10-init.ts +18 -15
- package/docs/concepts/03-client/20-form/20-input.ts +13 -6
- package/docs/concepts/03-client/20-form/30-layout.ts +44 -49
- package/docs/concepts/03-client/20-form/40-template.ts +10 -5
- package/docs/concepts/03-client/20-form/50-integration.md +11 -0
- package/docs/concepts/03-client/20-form/examples/postModeration/ThePage.vue +32 -0
- package/docs/concepts/03-client/20-form/examples/postModeration/usePostModeration.ts +80 -0
- package/docs/concepts/05-type-driven-design/01-architecture/10-boundaries.md +23 -20
- package/docs/concepts/05-type-driven-design/01-architecture/index.md +1 -1
- package/docs/concepts/05-type-driven-design/02-domains/10-entities.md +29 -37
- package/docs/concepts/05-type-driven-design/02-domains/20-aggregates.md +42 -26
- package/docs/concepts/05-type-driven-design/02-domains/30-repositories.md +20 -26
- package/docs/concepts/05-type-driven-design/02-domains/40-refinements.md +30 -0
- package/docs/concepts/05-type-driven-design/02-domains/index.md +1 -1
- package/docs/concepts/05-type-driven-design/03-applications/10-use-case.md +33 -40
- package/docs/concepts/05-type-driven-design/03-applications/20-ports.md +49 -0
- package/docs/concepts/05-type-driven-design/03-applications/index.md +1 -1
- package/docs/concepts/05-type-driven-design/04-infrastructure/10-implementation.md +27 -36
- package/docs/concepts/05-type-driven-design/04-infrastructure/index.md +1 -1
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/ports/index.ts +1 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/ports/waitingListEntry.ts +17 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/useCases/clientGiveBackBook.ts +30 -12
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/useCases/clientRentBook.ts +9 -8
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/useCases/createBook.ts +7 -7
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/useCases/index.ts +2 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/useCases/withdrawBook.ts +32 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/aggregates/clientGiveBackBook.ts +72 -13
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/aggregates/clientRentBook.ts +37 -11
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/aggregates/createBook.ts +29 -17
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/aggregates/index.ts +1 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/aggregates/withdrawBook.ts +37 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/facts/create.ts +4 -5
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/facts/index.ts +2 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/facts/rental.ts +9 -9
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/facts/reserve.ts +37 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/facts/returnBook.ts +11 -9
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/facts/withdraw.ts +21 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/index.ts +42 -11
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/client/facts/giveBackBook.ts +11 -9
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/client/facts/rentBook.ts +10 -10
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/client/index.ts +6 -29
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/index.ts +1 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/waitingListEntry/facts/cancel.ts +26 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/waitingListEntry/facts/create.ts +33 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/waitingListEntry/facts/index.ts +3 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/waitingListEntry/facts/prepare.ts +23 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/waitingListEntry/index.ts +79 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/index.ts +1 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/refinements/index.ts +1 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/refinements/refineLinkBetweenClientAndBorrowedBook.ts +34 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/repositories/book.ts +1 -1
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/repositories/index.ts +1 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/repositories/waitingListEntry.ts +19 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/command/clientRentBook.ts +3 -3
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/checkers/bookExist.ts +2 -2
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/checkers/clientExist.ts +2 -2
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/routes/clientGiveBackBook.ts +23 -14
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/routes/clientRentBook.ts +7 -12
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/ports/book.ts +1 -1
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/ports/index.ts +1 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/ports/waitingListEntry.ts +17 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/useCases/index.ts +2 -1
- package/docs/concepts/05-type-driven-design/index.md +2 -2
- package/docs/concepts.llms.md +71 -25
- package/instructions/coding-conventions.md +2 -2
- package/package.json +17 -14
- package/skills/http-client/SKILL.md +1 -1
- package/skills/http-client/references/configuration.md +3 -1
- package/skills/http-client/references/examples/client-expectations.ts +11 -10
- package/skills/http-client/references/examples/client-streams.ts +2 -2
- package/skills/http-client/references/examples/external-client.ts +2 -2
- package/skills/http-client/references/responses.md +1 -1
- package/skills/http-server/SKILL.md +4 -9
- package/skills/http-server/references/examples/authentication.ts +2 -2
- package/skills/http-server/references/examples/inferred-client.ts +54 -0
- package/skills/http-server/references/examples/minimal-route.ts +2 -3
- package/skills/http-server/references/examples/protected-route.ts +4 -6
- package/skills/http-server/references/examples/rename-user-route.ts +4 -6
- package/skills/http-server/references/examples/user-checker.ts +2 -2
- package/skills/http-server/references/examples/user-route.ts +12 -5
- package/skills/http-server/references/initialization.md +1 -1
- package/skills/http-server/references/reusable-flows.md +3 -3
- package/skills/http-server/references/routes-and-floor.md +11 -3
- package/dist/bin/install/index.d.ts +0 -2
- package/docs/concepts/02-server/20-http/50-codegen.ts +0 -29
- package/skills/http-server/references/code-generation.md +0 -31
- package/skills/http-server/references/examples/generate-sdk.ts +0 -36
- /package/dist/bin/{install → installSkill}/skill.d.ts +0 -0
|
@@ -3,66 +3,74 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Ajouter et cumuler des contraintes compatibles, fournies ou personnalisées.
|
|
5
5
|
*/
|
|
6
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
6
7
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
8
|
+
import * as DString from "@duplojs/lang/string";
|
|
9
|
+
import type * as DNumber from "@duplojs/lang/number";
|
|
10
|
+
import type * as DArray from "@duplojs/lang/array";
|
|
7
11
|
|
|
8
12
|
// Une structure vérifie la nature de la donnée, puis ses propriétés supplémentaires.
|
|
9
13
|
// Les contraintes sont vérifiées au runtime et enrichissent le type obtenu par StructureValue.
|
|
10
14
|
// Toute structure peut en recevoir, à condition que la contrainte soit compatible.
|
|
11
15
|
|
|
12
|
-
// string & DString.Email
|
|
13
16
|
const emailStructure = DDataStructure.string([DDataStructure.email()]);
|
|
17
|
+
type _CheckEmailStructure = DCommon.ExpectType<
|
|
18
|
+
DDataStructure.StructureValue<typeof emailStructure>,
|
|
19
|
+
string & DString.Email,
|
|
20
|
+
"strict"
|
|
21
|
+
>;
|
|
14
22
|
|
|
15
23
|
// Une contrainte ne remplace pas le type de base.
|
|
16
24
|
// Elle apporte une information supplémentaire garantie après validation.
|
|
17
25
|
|
|
18
|
-
// number & DNumber.Integer & DNumber.GreaterThanOrEqual<18>
|
|
19
26
|
const ageStructure = DDataStructure.number([
|
|
20
27
|
DDataStructure.integer(),
|
|
21
28
|
DDataStructure.greaterThanOrEqual(18),
|
|
22
29
|
]);
|
|
30
|
+
type _CheckAgeStructure = DCommon.ExpectType<
|
|
31
|
+
DDataStructure.StructureValue<typeof ageStructure>,
|
|
32
|
+
number & DNumber.Integer & DNumber.GreaterThanOrEqual<18>,
|
|
33
|
+
"strict"
|
|
34
|
+
>;
|
|
23
35
|
|
|
24
36
|
type Age = DDataStructure.StructureValue<typeof ageStructure>;
|
|
25
37
|
|
|
26
38
|
// Plusieurs contraintes peuvent être cumulées.
|
|
27
39
|
// Toutes doivent être vérifiées pour que la donnée soit valide.
|
|
28
40
|
|
|
29
|
-
// string & DString.MinCharacters<3> & DString.Trimmed
|
|
30
41
|
const usernameStructure = DDataStructure.string([
|
|
31
42
|
DDataStructure.minCharacters(3),
|
|
32
43
|
DDataStructure.trimmed(),
|
|
33
44
|
]);
|
|
45
|
+
type _CheckUsernameStructure = DCommon.ExpectType<DDataStructure.StructureValue<typeof usernameStructure>, string & DString.MinCharacters<3> & DString.Trimmed, "strict">;
|
|
34
46
|
|
|
35
47
|
// Les contraintes ne concernent pas uniquement les `TypeStructure`.
|
|
36
48
|
// Elles peuvent s'appliquer aux autres structures comme les tableaux.
|
|
37
49
|
|
|
38
|
-
// readonly string[] & DArray.MinElements<1>
|
|
39
50
|
const tagsStructure = DDataStructure.array(
|
|
40
51
|
DDataStructure.string(),
|
|
41
52
|
[DDataStructure.minElements(1)],
|
|
42
53
|
);
|
|
54
|
+
type _CheckTagsStructure = DCommon.ExpectType<DDataStructure.StructureValue<typeof tagsStructure>, readonly string[] & DArray.MinElements<1>, "strict">;
|
|
43
55
|
|
|
44
56
|
// Une contrainte peut également être ajoutée après la création d'une structure.
|
|
45
57
|
// La structure originale n'est pas modifiée.
|
|
46
58
|
|
|
47
|
-
// string
|
|
48
59
|
const stringStructure = DDataStructure.string();
|
|
60
|
+
type _CheckStringStructure = DCommon.ExpectType<DDataStructure.StructureValue<typeof stringStructure>, string, "strict">;
|
|
49
61
|
|
|
50
|
-
// string & DString.Email
|
|
51
62
|
const constrainedStringStructure = stringStructure.addConstraint(
|
|
52
63
|
DDataStructure.email(),
|
|
53
64
|
);
|
|
65
|
+
type _CheckConstrainedStringStructure = DCommon.ExpectType<DDataStructure.StructureValue<typeof constrainedStringStructure>, string & DString.Email, "strict">;
|
|
54
66
|
|
|
55
67
|
// `refine` permet de définir une contrainte spécifique au domaine.
|
|
56
68
|
// Un type predicate permet également d'affiner le type produit par la structure.
|
|
57
69
|
|
|
58
70
|
type UserId = `user:${string}`;
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
DDataStructure.refine(
|
|
63
|
-
(value): value is UserId => value.startsWith("user:"),
|
|
64
|
-
),
|
|
65
|
-
]);
|
|
72
|
+
const userIdStructure = DDataStructure.string([DDataStructure.refine(DString.startsWith("user:"))]);
|
|
73
|
+
type _CheckUserIdStructure = DCommon.ExpectType<DDataStructure.StructureValue<typeof userIdStructure>, UserId, "strict">;
|
|
66
74
|
|
|
67
75
|
// Une contrainte ne peut être utilisée que sur une structure compatible.
|
|
68
76
|
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Vérification, conversion et narrowing aux frontières du logiciel, en synchrone ou asynchrone.
|
|
5
5
|
*/
|
|
6
6
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
7
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
8
|
+
import type * as DString from "@duplojs/lang/string";
|
|
7
9
|
|
|
8
10
|
// La structure décrit la donnée attendue à la fois dans TypeScript et au runtime.
|
|
9
11
|
// Les opérations ci-dessous s’appliquent aux frontières du logiciel, avant de considérer
|
|
@@ -22,15 +24,17 @@ const componentStructure = DDataStructure.object({
|
|
|
22
24
|
// Le type TypeScript correspondant à une structure peut être récupéré
|
|
23
25
|
// avec `StructureValue`.
|
|
24
26
|
//
|
|
25
|
-
// {
|
|
26
|
-
// readonly id: bigint;
|
|
27
|
-
// readonly name: string;
|
|
28
|
-
// readonly alt?: string | undefined;
|
|
29
|
-
// readonly image: {
|
|
30
|
-
// readonly src: string & DString.Url;
|
|
31
|
-
// };
|
|
32
|
-
// }
|
|
33
27
|
type Component = DDataStructure.StructureValue<typeof componentStructure>;
|
|
28
|
+
type _CheckComponent = DCommon.ExpectType<
|
|
29
|
+
Component,
|
|
30
|
+
{
|
|
31
|
+
readonly id: bigint;
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly alt?: string | undefined;
|
|
34
|
+
readonly image: { readonly src: string & DString.Url };
|
|
35
|
+
},
|
|
36
|
+
"strict"
|
|
37
|
+
>;
|
|
34
38
|
|
|
35
39
|
declare const unknownComponent: unknown;
|
|
36
40
|
|
|
@@ -78,7 +82,7 @@ declare const value: unknown;
|
|
|
78
82
|
// Contrairement à `check`, il ne retourne pas les détails de l'erreur.
|
|
79
83
|
// Il agit également comme un type predicate TypeScript.
|
|
80
84
|
if (componentStructure.is(value)) {
|
|
81
|
-
|
|
85
|
+
type _CheckNarrowedComponent = DCommon.ExpectType<typeof value, Component, "strict">;
|
|
82
86
|
void value;
|
|
83
87
|
}
|
|
84
88
|
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Encoder et décoder les données avec un même contrat, selon leur type fondamental.
|
|
5
5
|
*/
|
|
6
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
6
7
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
7
8
|
import * as DString from "@duplojs/lang/string";
|
|
9
|
+
import type * as DEither from "@duplojs/lang/either";
|
|
10
|
+
import type * as DNumber from "@duplojs/lang/number";
|
|
8
11
|
|
|
9
12
|
// Un codec fait transiter les données entre deux représentations d’une même structure.
|
|
10
13
|
// encode convertit la représentation interne vers l’externe ; decode effectue l’inverse.
|
|
@@ -55,16 +58,6 @@ const productStructure = DDataStructure.object({
|
|
|
55
58
|
]),
|
|
56
59
|
});
|
|
57
60
|
|
|
58
|
-
// DEither.Right<
|
|
59
|
-
// "encode-success",
|
|
60
|
-
// {
|
|
61
|
-
// readonly name: string;
|
|
62
|
-
// readonly price: string & DString.Number;
|
|
63
|
-
// readonly quantity: string & DString.Number;
|
|
64
|
-
// }
|
|
65
|
-
// >
|
|
66
|
-
// | DEither.Left<"async-error", DDataStructure.ErrorPromise>
|
|
67
|
-
// | DEither.Left<"encode-error", DDataStructure.Error>
|
|
68
61
|
const encodedProduct = productStructure.encode(
|
|
69
62
|
codecs,
|
|
70
63
|
{
|
|
@@ -73,6 +66,20 @@ const encodedProduct = productStructure.encode(
|
|
|
73
66
|
quantity: 2,
|
|
74
67
|
},
|
|
75
68
|
);
|
|
69
|
+
type _CheckEncodedProductLine68 = DCommon.ExpectType<
|
|
70
|
+
typeof encodedProduct,
|
|
71
|
+
DEither.Right<
|
|
72
|
+
"encode-success",
|
|
73
|
+
{
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly price: string & DString.Number;
|
|
76
|
+
readonly quantity: string & DString.Number;
|
|
77
|
+
}
|
|
78
|
+
>
|
|
79
|
+
| DEither.Left<"async-error", DDataStructure.ErrorPromise>
|
|
80
|
+
| DEither.Left<"encode-error", DDataStructure.Error>,
|
|
81
|
+
"strict"
|
|
82
|
+
>;
|
|
76
83
|
|
|
77
84
|
// Pendant l'encode, la structure est parcourue.
|
|
78
85
|
//
|
|
@@ -83,16 +90,6 @@ const encodedProduct = productStructure.encode(
|
|
|
83
90
|
// Le codec associé à `TheNumber` transforme donc automatiquement
|
|
84
91
|
// leurs valeurs de `number` vers `string`.
|
|
85
92
|
|
|
86
|
-
// DEither.Right<
|
|
87
|
-
// "decode-success",
|
|
88
|
-
// {
|
|
89
|
-
// readonly name: string;
|
|
90
|
-
// readonly price: number;
|
|
91
|
-
// readonly quantity: number & DNumber.Integer & DNumber.Positive;
|
|
92
|
-
// }
|
|
93
|
-
// >
|
|
94
|
-
// | DEither.Left<"async-error", DDataStructure.ErrorPromise>
|
|
95
|
-
// | DEither.Left<"decode-error", DDataStructure.Error>
|
|
96
93
|
const decodedProduct = productStructure.decode(
|
|
97
94
|
codecs,
|
|
98
95
|
{
|
|
@@ -101,6 +98,20 @@ const decodedProduct = productStructure.decode(
|
|
|
101
98
|
quantity: "2",
|
|
102
99
|
},
|
|
103
100
|
);
|
|
101
|
+
type _CheckDecodedProductLine96 = DCommon.ExpectType<
|
|
102
|
+
typeof decodedProduct,
|
|
103
|
+
DEither.Right<
|
|
104
|
+
"decode-success",
|
|
105
|
+
{
|
|
106
|
+
readonly name: string;
|
|
107
|
+
readonly price: number;
|
|
108
|
+
readonly quantity: number & DNumber.Integer & DNumber.Positive;
|
|
109
|
+
}
|
|
110
|
+
>
|
|
111
|
+
| DEither.Left<"async-error", DDataStructure.ErrorPromise>
|
|
112
|
+
| DEither.Left<"decode-error", DDataStructure.Error>,
|
|
113
|
+
"strict"
|
|
114
|
+
>;
|
|
104
115
|
|
|
105
116
|
// Le decode parcourt exactement la même structure dans le sens inverse.
|
|
106
117
|
//
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Références différées et cohérence entre un type déclaré et sa structure runtime.
|
|
5
5
|
*/
|
|
6
6
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
7
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
8
|
+
import type * as DEither from "@duplojs/lang/either";
|
|
7
9
|
|
|
8
10
|
// Une structure récursive se référence elle-même. Le type attendu est déclaré en amont
|
|
9
11
|
// pour permettre à TypeScript de typer cette dépendance récursive.
|
|
@@ -12,13 +14,13 @@ interface Tree {
|
|
|
12
14
|
readonly children: readonly Tree[];
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
// Tree
|
|
16
17
|
const treeStructure: DDataStructure.Structure<Tree> = DDataStructure.object({
|
|
17
18
|
value: DDataStructure.string(),
|
|
18
19
|
children: DDataStructure.array(
|
|
19
20
|
DDataStructure.lazy(() => treeStructure),
|
|
20
21
|
),
|
|
21
22
|
}).contract();
|
|
23
|
+
type _CheckTreeStructure = DCommon.ExpectType<DDataStructure.StructureValue<typeof treeStructure>, Tree, "strict">;
|
|
22
24
|
|
|
23
25
|
// `lazy` retarde la résolution de `treeStructure`.
|
|
24
26
|
//
|
|
@@ -46,3 +48,10 @@ const tree = {
|
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
const result = treeStructure.check(tree);
|
|
51
|
+
type _CheckTreeResult = DCommon.ExpectType<
|
|
52
|
+
typeof result,
|
|
53
|
+
DEither.Left<"async-error", DDataStructure.ErrorPromise>
|
|
54
|
+
| DEither.Left<"check-error", DDataStructure.Error>
|
|
55
|
+
| DEither.Right<"check-success", Tree>,
|
|
56
|
+
"strict"
|
|
57
|
+
>;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Valeurs connues statiquement ou reçues au runtime, et gestion des entrées invalides.
|
|
5
5
|
*/
|
|
6
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
6
7
|
import * as DChrono from "@duplojs/lang/chrono";
|
|
8
|
+
import type * as DEither from "@duplojs/lang/either";
|
|
7
9
|
|
|
8
10
|
// TheDate représente un instant absolu ; TheTime représente une quantité de temps.
|
|
9
11
|
// Lorsque le typage peut établir la validité de l’entrée, la création retourne directement
|
|
@@ -11,49 +13,73 @@ import * as DChrono from "@duplojs/lang/chrono";
|
|
|
11
13
|
|
|
12
14
|
// Les dates littérales au format YYYY-MM-DD sont vérifiées par le typage.
|
|
13
15
|
|
|
14
|
-
// DChrono.TheDate
|
|
15
16
|
const date = DChrono.createDate("2026-09-30");
|
|
17
|
+
type _CheckDateLine15 = DCommon.ExpectType<
|
|
18
|
+
typeof date,
|
|
19
|
+
DChrono.TheDate,
|
|
20
|
+
"strict"
|
|
21
|
+
>;
|
|
16
22
|
|
|
17
23
|
// Les temps sont également sûrs lorsque la valeur littérale
|
|
18
24
|
// et son unité permettent d'être vérifiées par le typage.
|
|
19
25
|
|
|
20
|
-
// DChrono.TheTime
|
|
21
26
|
const time = DChrono.createTime(2, "hour");
|
|
27
|
+
type _CheckTimeLine21 = DCommon.ExpectType<
|
|
28
|
+
typeof time,
|
|
29
|
+
DChrono.TheTime,
|
|
30
|
+
"strict"
|
|
31
|
+
>;
|
|
22
32
|
|
|
23
33
|
// Lorsque la valeur provient du runtime, sa validité n'est plus garantie.
|
|
24
34
|
declare const dateInput: string;
|
|
25
35
|
declare const timeInput: number;
|
|
26
36
|
|
|
27
|
-
// DChrono.MayBeDate
|
|
28
|
-
// DEither.Right<"date-created", DChrono.TheDate>
|
|
29
|
-
// | DEither.Left<"date-created-error", null>
|
|
30
37
|
const maybeDate = DChrono.createDate({
|
|
31
38
|
value: dateInput,
|
|
32
39
|
});
|
|
40
|
+
type _CheckMaybeDateLine30 = DCommon.ExpectType<
|
|
41
|
+
typeof maybeDate,
|
|
42
|
+
DEither.Right<"date-created", DChrono.TheDate> | DEither.Left<"date-created-error", null>,
|
|
43
|
+
"strict"
|
|
44
|
+
>;
|
|
33
45
|
|
|
34
|
-
// DChrono.MayBeTime
|
|
35
|
-
// DEither.Right<"time-created", DChrono.TheTime>
|
|
36
|
-
// | DEither.Left<"time-created-error", null>
|
|
37
46
|
// Sans unité explicite, l’entrée numérique représente des millisecondes.
|
|
38
47
|
const maybeTime = DChrono.createTime(timeInput);
|
|
48
|
+
type _CheckMaybeTime = DCommon.ExpectType<typeof maybeTime, DChrono.MayBeTime, "strict">;
|
|
39
49
|
|
|
40
50
|
// Les variantes `OrThrow` permettent de récupérer directement la valeur.
|
|
41
51
|
// Une entrée invalide provoquera une `CreateTheDateError`
|
|
42
52
|
// ou une `CreateTheTimeError`.
|
|
43
53
|
|
|
44
|
-
// DChrono.TheDate
|
|
45
54
|
const dateOrThrow = DChrono.createDateOrThrow({
|
|
46
55
|
value: dateInput,
|
|
47
56
|
});
|
|
57
|
+
type _CheckDateOrThrowLine45 = DCommon.ExpectType<
|
|
58
|
+
typeof dateOrThrow,
|
|
59
|
+
DChrono.TheDate,
|
|
60
|
+
"strict"
|
|
61
|
+
>;
|
|
48
62
|
|
|
49
|
-
// DChrono.TheTime
|
|
50
63
|
const timeOrThrow = DChrono.createTimeOrThrow(timeInput);
|
|
64
|
+
type _CheckTimeOrThrowLine50 = DCommon.ExpectType<
|
|
65
|
+
typeof timeOrThrow,
|
|
66
|
+
DChrono.TheTime,
|
|
67
|
+
"strict"
|
|
68
|
+
>;
|
|
51
69
|
|
|
52
70
|
// Les objets natifs et timestamps sont également considérés
|
|
53
71
|
// comme des valeurs runtime potentiellement invalides.
|
|
54
72
|
|
|
55
|
-
// DChrono.MayBeDate
|
|
56
73
|
const maybeNativeDate = DChrono.createDate(new Date());
|
|
74
|
+
type _CheckMaybeNativeDateLine56 = DCommon.ExpectType<
|
|
75
|
+
typeof maybeNativeDate,
|
|
76
|
+
DChrono.MayBeDate,
|
|
77
|
+
"strict"
|
|
78
|
+
>;
|
|
57
79
|
|
|
58
|
-
|
|
59
|
-
|
|
80
|
+
const currentDate = DChrono.now();
|
|
81
|
+
type _CheckCurrentDate = DCommon.ExpectType<
|
|
82
|
+
typeof currentDate,
|
|
83
|
+
DChrono.TheDate,
|
|
84
|
+
"strict"
|
|
85
|
+
>;
|
|
@@ -12,39 +12,55 @@ const date = DChrono.createDate("2026-09-30");
|
|
|
12
12
|
|
|
13
13
|
// Les unités peuvent être ajoutées ou retirées directement sur une date.
|
|
14
14
|
|
|
15
|
-
// DChrono.TheDate
|
|
16
15
|
const nextWeek = DCommon.pipe(
|
|
17
16
|
date,
|
|
18
17
|
DChrono.addWeeks(1),
|
|
19
18
|
DChrono.addDays(2),
|
|
20
19
|
DChrono.subtractHours(3),
|
|
21
20
|
);
|
|
21
|
+
type _CheckNextWeekLine16 = DCommon.ExpectType<
|
|
22
|
+
typeof nextWeek,
|
|
23
|
+
DChrono.TheDate,
|
|
24
|
+
"strict"
|
|
25
|
+
>;
|
|
22
26
|
|
|
23
27
|
// `TheTime` permet de représenter une durée puis de l'appliquer
|
|
24
28
|
// à une date ou à un autre temps.
|
|
25
29
|
const duration = DChrono.createTime(2, "hour");
|
|
26
30
|
|
|
27
|
-
// DChrono.TheDate
|
|
28
31
|
const later = DCommon.pipe(
|
|
29
32
|
date,
|
|
30
33
|
DChrono.addTime(duration),
|
|
31
34
|
);
|
|
35
|
+
type _CheckLaterLine28 = DCommon.ExpectType<
|
|
36
|
+
typeof later,
|
|
37
|
+
DChrono.TheDate,
|
|
38
|
+
"strict"
|
|
39
|
+
>;
|
|
32
40
|
|
|
33
|
-
// DChrono.TheTime
|
|
34
41
|
const totalDuration = DCommon.pipe(
|
|
35
42
|
duration,
|
|
36
43
|
DChrono.addTime(DChrono.createTime(30, "minute")),
|
|
37
44
|
);
|
|
45
|
+
type _CheckTotalDurationLine34 = DCommon.ExpectType<
|
|
46
|
+
typeof totalDuration,
|
|
47
|
+
DChrono.TheTime,
|
|
48
|
+
"strict"
|
|
49
|
+
>;
|
|
38
50
|
|
|
39
51
|
// La différence entre deux dates produit un TheTime signé : date moins date de référence.
|
|
40
52
|
const startDate = DChrono.createDate("2026-09-01");
|
|
41
53
|
const endDate = DChrono.createDate("2026-09-30");
|
|
42
54
|
|
|
43
|
-
// DChrono.TheTime
|
|
44
55
|
const difference = DCommon.pipe(
|
|
45
56
|
endDate,
|
|
46
57
|
DChrono.getDifference(startDate),
|
|
47
58
|
);
|
|
59
|
+
type _CheckDifferenceLine44 = DCommon.ExpectType<
|
|
60
|
+
typeof difference,
|
|
61
|
+
DChrono.TheTime,
|
|
62
|
+
"strict"
|
|
63
|
+
>;
|
|
48
64
|
|
|
49
65
|
// `computeTime` permet d'exprimer un `TheTime` dans une unité donnée.
|
|
50
66
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Sérialiser, reconnaître et reconstruire les instants et durées en conservant leur valeur.
|
|
5
5
|
*/
|
|
6
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
6
7
|
import * as DChrono from "@duplojs/lang/chrono";
|
|
7
8
|
|
|
8
9
|
// Chrono possède un format dédié qui conserve la valeur numérique et identifie sa nature.
|
|
@@ -13,15 +14,21 @@ const time = DChrono.createTime(2, "hour");
|
|
|
13
14
|
// Une `TheDate` est sérialisée avec le préfixe `date`,
|
|
14
15
|
// suivi de son timestamp et de son signe.
|
|
15
16
|
|
|
16
|
-
// DChrono.SerializedTheDate
|
|
17
|
-
// "date1790726400000+"
|
|
18
17
|
const serializedDate = DChrono.serialize(date);
|
|
18
|
+
type _CheckSerializedDateLine18 = DCommon.ExpectType<
|
|
19
|
+
typeof serializedDate,
|
|
20
|
+
`date${number}-` | `date${number}+`,
|
|
21
|
+
"strict"
|
|
22
|
+
>;
|
|
19
23
|
|
|
20
24
|
// Un `TheTime` utilise le même principe avec le préfixe `time`.
|
|
21
25
|
|
|
22
|
-
// DChrono.SerializedTheTime
|
|
23
|
-
// "time7200000+"
|
|
24
26
|
const serializedTime = DChrono.serialize(time);
|
|
27
|
+
type _CheckSerializedTimeLine24 = DCommon.ExpectType<
|
|
28
|
+
typeof serializedTime,
|
|
29
|
+
`time${number}-` | `time${number}+`,
|
|
30
|
+
"strict"
|
|
31
|
+
>;
|
|
25
32
|
|
|
26
33
|
// Le format permet de conserver exactement la valeur transportée,
|
|
27
34
|
// tout en distinguant une date d'un simple nombre ou d'une string classique.
|
|
@@ -33,6 +40,7 @@ const payload = JSON.stringify({
|
|
|
33
40
|
date,
|
|
34
41
|
time,
|
|
35
42
|
});
|
|
43
|
+
type _CheckPayload = DCommon.ExpectType<typeof payload, string, "strict">;
|
|
36
44
|
|
|
37
45
|
// {
|
|
38
46
|
// "date": "date1790726400000+",
|
|
@@ -45,13 +53,21 @@ const payload = JSON.stringify({
|
|
|
45
53
|
declare const input: string;
|
|
46
54
|
|
|
47
55
|
if (DChrono.isSerializedTheDate(input)) {
|
|
48
|
-
// DChrono.SerializedTheDate
|
|
49
56
|
const serializedDate = input;
|
|
57
|
+
type _CheckSerializedDateLine49 = DCommon.ExpectType<
|
|
58
|
+
typeof serializedDate,
|
|
59
|
+
`date${number}-` | `date${number}+`,
|
|
60
|
+
"strict"
|
|
61
|
+
>;
|
|
50
62
|
}
|
|
51
63
|
|
|
52
64
|
if (DChrono.isSerializedTheTime(input)) {
|
|
53
|
-
// DChrono.SerializedTheTime
|
|
54
65
|
const serializedTime = input;
|
|
66
|
+
type _CheckSerializedTimeLine54 = DCommon.ExpectType<
|
|
67
|
+
typeof serializedTime,
|
|
68
|
+
`time${number}-` | `time${number}+`,
|
|
69
|
+
"strict"
|
|
70
|
+
>;
|
|
55
71
|
}
|
|
56
72
|
|
|
57
73
|
// Une valeur sérialisée peut ensuite être reconstruite.
|
|
@@ -31,11 +31,15 @@ const localDate = DChrono.createDate("2026-09-30", {
|
|
|
31
31
|
hour: "09",
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
// DChrono.TheDate
|
|
35
34
|
const instant = DCommon.pipe(
|
|
36
35
|
localDate,
|
|
37
36
|
DChrono.applyTimezone("Europe/Paris"),
|
|
38
37
|
);
|
|
38
|
+
type _CheckInstantLine35 = DCommon.ExpectType<
|
|
39
|
+
typeof instant,
|
|
40
|
+
DChrono.TheDate,
|
|
41
|
+
"strict"
|
|
42
|
+
>;
|
|
39
43
|
|
|
40
44
|
// `getTimezoneOffset` retourne le décalage du fuseau pour une date donnée.
|
|
41
45
|
// Ce décalage dépend notamment des changements d'heure saisonniers.
|
|
@@ -8,6 +8,8 @@ import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
|
8
8
|
import * as DModeling from "@duplojs/lang/modeling";
|
|
9
9
|
import * as DArray from "@duplojs/lang/array";
|
|
10
10
|
import * as DCommon from "@duplojs/lang/common";
|
|
11
|
+
import type * as DString from "@duplojs/lang/string";
|
|
12
|
+
import type * as DNumber from "@duplojs/lang/number";
|
|
11
13
|
|
|
12
14
|
// Une Entity représente un objet métier doté d’une identité explicite.
|
|
13
15
|
// Ses valeurs primitives sont définies par des NewType qui associent un sens métier
|
|
@@ -21,15 +23,14 @@ export namespace User {
|
|
|
21
23
|
// préfixés par le nom de l'entité.
|
|
22
24
|
const namespace = DModeling.createEntityNamespace("User");
|
|
23
25
|
|
|
24
|
-
// string & DModeling.NewType<"UserId", DString.Uuid>
|
|
25
26
|
export const Id = namespace.createNewType(
|
|
26
27
|
"Id",
|
|
27
28
|
DDataStructure.string(),
|
|
28
29
|
[DDataStructure.uuid()],
|
|
29
30
|
);
|
|
30
31
|
export type Id = DDataStructure.StructureValue<typeof Id>;
|
|
32
|
+
type _CheckId = DCommon.ExpectType<Id, string & DModeling.NewType<"UserId", DString.Uuid>, "strict">;
|
|
31
33
|
|
|
32
|
-
// number & DModeling.NewType<"UserAge", Integer | Positive>
|
|
33
34
|
export const Age = namespace.createNewType(
|
|
34
35
|
"Age",
|
|
35
36
|
DDataStructure.number(),
|
|
@@ -39,8 +40,12 @@ export namespace User {
|
|
|
39
40
|
],
|
|
40
41
|
);
|
|
41
42
|
export type Age = DDataStructure.StructureValue<typeof Age>;
|
|
43
|
+
type _CheckAge = DCommon.ExpectType<
|
|
44
|
+
Age,
|
|
45
|
+
number & DModeling.NewType<"UserAge", DNumber.Integer | DNumber.Positive>,
|
|
46
|
+
"strict"
|
|
47
|
+
>;
|
|
42
48
|
|
|
43
|
-
// string & DModeling.NewType<"UserName", DString.Trimmed | DString.MinCharacters<3> | DString.MaxCharacters<45>>
|
|
44
49
|
export const Name = namespace.createNewType(
|
|
45
50
|
"Name",
|
|
46
51
|
DDataStructure.string(),
|
|
@@ -51,8 +56,12 @@ export namespace User {
|
|
|
51
56
|
],
|
|
52
57
|
);
|
|
53
58
|
export type Name = DDataStructure.StructureValue<typeof Name>;
|
|
59
|
+
type _CheckName = DCommon.ExpectType<
|
|
60
|
+
Name,
|
|
61
|
+
string & DModeling.NewType<"UserName", DString.Trimmed | DString.MinCharacters<3> | DString.MaxCharacters<45>>,
|
|
62
|
+
"strict"
|
|
63
|
+
>;
|
|
54
64
|
|
|
55
|
-
// string & DModeling.NewType<"UserTag", DString.Trimmed | DString.MinCharacters<2> | DString.MaxCharacters<20>>
|
|
56
65
|
export const Tag = namespace.createNewType(
|
|
57
66
|
"Tag",
|
|
58
67
|
DDataStructure.string(),
|
|
@@ -63,19 +72,10 @@ export namespace User {
|
|
|
63
72
|
],
|
|
64
73
|
);
|
|
65
74
|
export type Tag = DDataStructure.StructureValue<typeof Tag>;
|
|
75
|
+
type _CheckTag = DCommon.ExpectType<Tag, string & DModeling.NewType<"UserTag", DString.Trimmed | DString.MinCharacters<2> | DString.MaxCharacters<20>>, "strict">;
|
|
66
76
|
|
|
67
77
|
// L'entité est ensuite déclarée à partir de ses différentes propriétés.
|
|
68
78
|
//
|
|
69
|
-
// DModeling.Entity<"User"> & {
|
|
70
|
-
// readonly name: string
|
|
71
|
-
// & DModeling.NewType<"UserName", DString.Trimmed | DString.MinCharacters<3> | DString.MaxCharacters<45>>;
|
|
72
|
-
// readonly id: string
|
|
73
|
-
// & DModeling.NewType<"UserId", DString.Uuid>;
|
|
74
|
-
// readonly age: number & DModeling.NewType<"UserAge", DNumber.Integer | DNumber.Positive>;
|
|
75
|
-
// readonly tags: readonly (
|
|
76
|
-
// string & DModeling.NewType<"UserTag", DString.Trimmed | DString.MinCharacters<2> | DString.MaxCharacters<20>>
|
|
77
|
-
// )[];
|
|
78
|
-
// };
|
|
79
79
|
export const Entity = namespace.createEntity(
|
|
80
80
|
() => ({
|
|
81
81
|
id: Id,
|
|
@@ -85,6 +85,12 @@ export namespace User {
|
|
|
85
85
|
}),
|
|
86
86
|
);
|
|
87
87
|
export type Entity = DDataStructure.StructureValue<typeof Entity>;
|
|
88
|
+
type _CheckEntity = DCommon.ExpectType<Entity, DModeling.Entity<"User"> & {
|
|
89
|
+
readonly id: Id;
|
|
90
|
+
readonly age: Age;
|
|
91
|
+
readonly name: Name;
|
|
92
|
+
readonly tags: readonly Tag[];
|
|
93
|
+
}, "strict">;
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
// L’hydratation fait entrer dans le modèle métier des données de repository ou de base de données.
|
|
@@ -99,21 +105,13 @@ export namespace User {
|
|
|
99
105
|
// Les contraintes sont vérifiées pendant cette opération.
|
|
100
106
|
// Le mapping pouvant échouer, son résultat est représenté par un `Either`.
|
|
101
107
|
|
|
102
|
-
// DEither.Left<"async-error", DDataStructure.ErrorPromise> | DEither.Left<"map-error", DDataStructure.Error>
|
|
103
|
-
// | DEither.Right<"map-success", DModeling.Entity<"User"> & {
|
|
104
|
-
// readonly name: string & DModeling.NewType<"UserName", Trimmed | MinCharacters<3> | MaxCharacters<45>>;
|
|
105
|
-
// readonly id: string & DModeling.NewType<"UserId", Uuid>;
|
|
106
|
-
// readonly age: number & DModeling.NewType<"UserAge", Integer | Positive>;
|
|
107
|
-
// readonly tags: readonly (
|
|
108
|
-
// DModeling.NewType<"UserTag", DString.Trimmed | DString.MinCharacters<2> | DString.MaxCharacters<20>>
|
|
109
|
-
// )[];
|
|
110
|
-
// }>
|
|
111
108
|
const maybeMapUser = User.Entity.map({
|
|
112
109
|
id: "invalid-id",
|
|
113
110
|
name: "SuperName",
|
|
114
111
|
age: 12,
|
|
115
112
|
tags: ["superTag"],
|
|
116
113
|
});
|
|
114
|
+
type _CheckMaybeMapUser = DCommon.ExpectType<typeof maybeMapUser, DEither.Left<"async-error", DDataStructure.ErrorPromise> | DEither.Left<"map-error", DDataStructure.Error> | DEither.Right<"map-success", User.Entity>, "strict">;
|
|
117
115
|
|
|
118
116
|
// `decodeMap` applique le même principe à une donnée encodée.
|
|
119
117
|
//
|
|
@@ -124,21 +122,13 @@ const maybeMapUser = User.Entity.map({
|
|
|
124
122
|
// L'âge de l'entité est donc ici fourni dans sa représentation encodée
|
|
125
123
|
// plutôt que directement comme un `number`.
|
|
126
124
|
|
|
127
|
-
// DEither.Left<"async-error", DDataStructure.ErrorPromise> | DEither.Left<"map-error", DDataStructure.Error>
|
|
128
|
-
// | DEither.Right<"map-success", DModeling.Entity<"User"> & {
|
|
129
|
-
// readonly name: string & DModeling.NewType<"UserName", Trimmed | MinCharacters<3> | MaxCharacters<45>>;
|
|
130
|
-
// readonly id: string & DModeling.NewType<"UserId", Uuid>;
|
|
131
|
-
// readonly age: number & DModeling.NewType<"UserAge", Integer | Positive>;
|
|
132
|
-
// readonly tags: readonly (
|
|
133
|
-
// DModeling.NewType<"UserTag", DString.Trimmed | DString.MinCharacters<2> | DString.MaxCharacters<20>>
|
|
134
|
-
// )[];
|
|
135
|
-
// }>
|
|
136
125
|
const maybeDecodeMapUser = User.Entity.decodeMap(DDataStructure.codecsString, {
|
|
137
126
|
id: "550e8400-e29b-41d4-a716-446655440000",
|
|
138
127
|
name: "SuperName",
|
|
139
128
|
age: DCommon.cast("12"),
|
|
140
129
|
tags: ["superTag"],
|
|
141
130
|
});
|
|
131
|
+
type _CheckMaybeDecodeMapUser = DCommon.ExpectType<typeof maybeDecodeMapUser, DEither.Left<"async-error", DDataStructure.ErrorPromise> | DEither.Left<"map-error", DDataStructure.Error> | DEither.Right<"map-success", User.Entity>, "strict">;
|
|
142
132
|
|
|
143
133
|
// `new` est utilisé lorsque les propriétés possèdent déjà leur typage métier.
|
|
144
134
|
//
|
|
@@ -152,15 +142,6 @@ const maybeDecodeMapUser = User.Entity.decodeMap(DDataStructure.codecsString, {
|
|
|
152
142
|
// Le résultat du `rightPipe` conserve la monade `Success` produite après
|
|
153
143
|
// regroupement des différentes validations.
|
|
154
144
|
|
|
155
|
-
// DEither.Left<"async-error", DDataStructure.ErrorPromise> | DEither.Left<"map-error", DDataStructure.Error>
|
|
156
|
-
// | DEither.Success<DModeling.Entity<"User"> & {
|
|
157
|
-
// readonly id: string & DModeling.NewType<"UserId", Uuid>;
|
|
158
|
-
// readonly name: string & DModeling.NewType<"UserName", Trimmed | MinCharacters<3> | MaxCharacters<45>>;
|
|
159
|
-
// readonly age: number & DModeling.NewType<"UserAge", Integer | Positive>;
|
|
160
|
-
// readonly tags: readonly [
|
|
161
|
-
// DModeling.NewType<"UserTag", DString.Trimmed | DString.MinCharacters<2> | DString.MaxCharacters<20>>
|
|
162
|
-
// ];
|
|
163
|
-
// }>
|
|
164
145
|
const maybeUser = DEither.rightPipe(
|
|
165
146
|
DEither.group({
|
|
166
147
|
id: User.Id.map("550e8400-e29b-41d4-a716-446655440000"),
|
|
@@ -173,17 +154,23 @@ const maybeUser = DEither.rightPipe(
|
|
|
173
154
|
}),
|
|
174
155
|
User.Entity.new,
|
|
175
156
|
);
|
|
157
|
+
type _CheckMaybeUser = DCommon.ExpectType<typeof maybeUser, DEither.Left<"async-error", DDataStructure.ErrorPromise> | DEither.Left<"map-error", DDataStructure.Error> | DEither.Success<DModeling.Entity<"User"> & {
|
|
158
|
+
readonly id: User.Id;
|
|
159
|
+
readonly name: User.Name;
|
|
160
|
+
readonly age: User.Age;
|
|
161
|
+
readonly tags: readonly [User.Tag];
|
|
162
|
+
}>, "strict">;
|
|
176
163
|
|
|
177
164
|
declare const user: User.Entity;
|
|
178
165
|
declare const maybeAge: User.Age | undefined;
|
|
179
166
|
|
|
180
|
-
// User.Entity
|
|
181
167
|
const updatedUser = User.Entity.update(
|
|
182
168
|
user,
|
|
183
169
|
{
|
|
184
170
|
age: maybeAge,
|
|
185
171
|
},
|
|
186
172
|
);
|
|
173
|
+
type _CheckUpdatedUser = DCommon.ExpectType<typeof updatedUser, User.Entity, "strict">;
|
|
187
174
|
|
|
188
175
|
// `update` retourne une nouvelle entité en remplaçant uniquement
|
|
189
176
|
// les propriétés dont la nouvelle valeur n'est pas `undefined`.
|