@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
|
@@ -10,7 +10,6 @@ import * as DString from "@duplojs/lang/string";
|
|
|
10
10
|
// `asyncPipe` applique le même principe lorsqu'une ou plusieurs étapes
|
|
11
11
|
// du traitement sont asynchrones.
|
|
12
12
|
//
|
|
13
|
-
// Promise<readonly Lowercase<string>[] & DArray.LengthEqual<2> & DArray.MinElements<2> & DArray.MaxElements<2>>
|
|
14
13
|
const asyncTags = DCommon.asyncPipe(
|
|
15
14
|
Promise.resolve(" TypeScript, DuploJS " as const),
|
|
16
15
|
DString.split(","),
|
|
@@ -18,11 +17,15 @@ const asyncTags = DCommon.asyncPipe(
|
|
|
18
17
|
(tags) => Promise.resolve(tags),
|
|
19
18
|
DArray.map(DString.toLowerCase),
|
|
20
19
|
);
|
|
20
|
+
type _CheckAsyncTags = DCommon.ExpectType<
|
|
21
|
+
typeof asyncTags,
|
|
22
|
+
Promise<readonly Lowercase<string>[] & DArray.LengthEqual<2> & DArray.MinElements<2> & DArray.MaxElements<2>>,
|
|
23
|
+
"strict"
|
|
24
|
+
>;
|
|
21
25
|
|
|
22
26
|
// `asyncInnerPipe` permet de composer plusieurs transformations synchrones
|
|
23
27
|
// ou asynchrones lorsqu'une callback asynchrone est attendue.
|
|
24
28
|
//
|
|
25
|
-
// Promise<readonly Promise<Lowercase<string>>[] & DArray.LengthEqual<2>>
|
|
26
29
|
// map produit ici un tableau de promesses ; asyncPipe attend chaque étape, pas chaque élément.
|
|
27
30
|
const values = DCommon.asyncPipe(
|
|
28
31
|
[" TypeScript ", " DuploJS "] as const,
|
|
@@ -34,9 +37,15 @@ const values = DCommon.asyncPipe(
|
|
|
34
37
|
),
|
|
35
38
|
),
|
|
36
39
|
);
|
|
40
|
+
type _CheckValues = DCommon.ExpectType<
|
|
41
|
+
typeof values,
|
|
42
|
+
Promise<readonly Promise<Lowercase<string>>[] & DArray.LengthEqual<2>>,
|
|
43
|
+
"strict"
|
|
44
|
+
>;
|
|
37
45
|
|
|
38
46
|
// Pour récupérer les valeurs résolues, ajouter une étape qui attend toutes les promesses.
|
|
39
47
|
const resolvedValues = DCommon.asyncPipe(
|
|
40
48
|
values,
|
|
41
49
|
DCommon.promiseAll,
|
|
42
50
|
);
|
|
51
|
+
type _CheckResolvedValues = DCommon.ExpectType<typeof resolvedValues, Promise<Lowercase<string>[]>, "strict">;
|
|
@@ -15,20 +15,22 @@ declare const myResult: (
|
|
|
15
15
|
|
|
16
16
|
// Choisir Right ou Left lorsque seul le statut du résultat compte.
|
|
17
17
|
// whenIsRight transforme la valeur contenue dans un Right et transmet les Left tels quels.
|
|
18
|
-
// "result" | DEither.Left<"fail-task", Error> | DEither.Fail | DEither.Error<Error>
|
|
19
18
|
const resultWhenIsRight = DCommon.pipe(
|
|
20
19
|
myResult,
|
|
21
20
|
DEither.whenIsRight(
|
|
22
21
|
(rightValue) => rightValue,
|
|
23
22
|
),
|
|
24
23
|
);
|
|
25
|
-
|
|
24
|
+
type _CheckResultWhenIsRight = DCommon.ExpectType<
|
|
25
|
+
typeof resultWhenIsRight,
|
|
26
|
+
"result" | DEither.Left<"fail-task", Error> | DEither.Fail | DEither.Error<Error>,
|
|
27
|
+
"strict"
|
|
28
|
+
>;
|
|
26
29
|
const resultUnwrapLeft = DEither.unwrapLeft(myResult);
|
|
27
30
|
// unwrapLeft extrait la valeur des Left et conserve les autres résultats enveloppés.
|
|
28
31
|
|
|
29
32
|
// Choisir une information lorsque le cas précis compte, quel que soit son statut.
|
|
30
33
|
// La callback reçoit ici l’Error contenue dans le Left "fail-task".
|
|
31
|
-
// DEither.Success<"result"> | DEither.Fail | DEither.Error<Error> | "test"
|
|
32
34
|
const resultWhenHasInformation = DCommon.pipe(
|
|
33
35
|
myResult,
|
|
34
36
|
DEither.whenHasInformation(
|
|
@@ -36,44 +38,53 @@ const resultWhenHasInformation = DCommon.pipe(
|
|
|
36
38
|
(error) => "test" as const,
|
|
37
39
|
),
|
|
38
40
|
);
|
|
39
|
-
|
|
41
|
+
type _CheckResultWhenHasInformation = DCommon.ExpectType<
|
|
42
|
+
typeof resultWhenHasInformation,
|
|
43
|
+
DEither.Success<"result"> | DEither.Fail | DEither.Error<Error> | "test",
|
|
44
|
+
"strict"
|
|
45
|
+
>;
|
|
40
46
|
const resultUnwrapByInformation = DCommon.pipe(
|
|
41
47
|
myResult,
|
|
42
48
|
DEither.unwrapByInformation(
|
|
43
49
|
["success", "fail-task"],
|
|
44
50
|
),
|
|
45
51
|
);
|
|
52
|
+
type _CheckResultUnwrapByInformation = DCommon.ExpectType<typeof resultUnwrapByInformation, "result" | Error | DEither.Fail | DEither.Error<Error>, "strict">;
|
|
46
53
|
// Les variantes non ciblées sont conservées dans le résultat et dans son type.
|
|
47
54
|
|
|
48
55
|
// Les variantes Otherwise traitent aussi les cas non ciblés, au lieu de les transmettre.
|
|
49
|
-
// "right" | "left"
|
|
50
56
|
const resultWhenIsRightOtherwise = DCommon.pipe(
|
|
51
57
|
myResult,
|
|
52
58
|
DEither.whenIsRightOtherwise(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
(rightValue) => {
|
|
60
|
+
type _CheckRightValue = DCommon.ExpectType<typeof rightValue, "result", "strict">;
|
|
61
|
+
return "right" as const;
|
|
62
|
+
},
|
|
63
|
+
(leftResult) => {
|
|
64
|
+
type _CheckLeftResult = DCommon.ExpectType<typeof leftResult, DEither.Left<"fail-task", Error> | DEither.Fail | DEither.Error<Error>, "strict">;
|
|
65
|
+
return "left" as const;
|
|
66
|
+
},
|
|
57
67
|
),
|
|
58
68
|
);
|
|
69
|
+
type _CheckResultWhenIsRightOtherwise = DCommon.ExpectType<typeof resultWhenIsRightOtherwise, "right" | "left", "strict">;
|
|
59
70
|
|
|
60
71
|
// Les variantes OrThrow extraient les cas ciblés et lèvent une exception pour les autres.
|
|
61
|
-
// "result" | Error
|
|
62
72
|
const resultUnwrapByInformationOrThrow = DCommon.pipe(
|
|
63
73
|
myResult,
|
|
64
74
|
DEither.unwrapByInformationOrThrow(
|
|
65
75
|
["success", "fail-task"],
|
|
66
76
|
),
|
|
67
77
|
);
|
|
78
|
+
type _CheckResultUnwrapByInformationOrThrow = DCommon.ExpectType<typeof resultUnwrapByInformationOrThrow, "result" | Error, "strict">;
|
|
68
79
|
// Utile notamment pour affirmer le résultat attendu dans un test unitaire.
|
|
69
80
|
|
|
70
81
|
// Les predicates réduisent le type dans une branche conditionnelle.
|
|
71
82
|
if (DEither.hasInformation(myResult, "success")) {
|
|
72
|
-
|
|
83
|
+
type _CheckSuccessResult = DCommon.ExpectType<typeof myResult, DEither.Success<"result">, "strict">;
|
|
73
84
|
void myResult;
|
|
74
85
|
}
|
|
75
86
|
// isRight et isLeft réduisent aussi le type selon le statut du résultat.
|
|
76
87
|
if (DEither.isLeft(myResult)) {
|
|
77
|
-
// Error | void
|
|
78
88
|
const leftValue = DEither.unwrapLeft(myResult);
|
|
89
|
+
void leftValue;
|
|
79
90
|
}
|
|
@@ -14,7 +14,6 @@ declare const myResult: (
|
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
// Sélectionner plusieurs variantes avec une décision explicite pour chacune.
|
|
17
|
-
// DEither.Left<"fail-task", Error> | DEither.Fail | "test"
|
|
18
17
|
const resultWhenIsSelected = DCommon.pipe(
|
|
19
18
|
myResult,
|
|
20
19
|
DEither.whenIsSelected(
|
|
@@ -27,7 +26,11 @@ const resultWhenIsSelected = DCommon.pipe(
|
|
|
27
26
|
(value) => "test" as const,
|
|
28
27
|
),
|
|
29
28
|
);
|
|
30
|
-
|
|
29
|
+
type _CheckResultWhenIsSelected = DCommon.ExpectType<
|
|
30
|
+
typeof resultWhenIsSelected,
|
|
31
|
+
DEither.Left<"fail-task", Error> | DEither.Fail | "test",
|
|
32
|
+
"strict"
|
|
33
|
+
>;
|
|
31
34
|
const resultUnwrapSelection = DCommon.pipe(
|
|
32
35
|
myResult,
|
|
33
36
|
DEither.unwrapSelection(
|
|
@@ -39,6 +42,11 @@ const resultUnwrapSelection = DCommon.pipe(
|
|
|
39
42
|
},
|
|
40
43
|
),
|
|
41
44
|
);
|
|
45
|
+
type _CheckResultUnwrapSelection = DCommon.ExpectType<
|
|
46
|
+
typeof resultUnwrapSelection,
|
|
47
|
+
DEither.Success<"result"> | Error | DEither.Left<"fail-task", Error> | DEither.Fail,
|
|
48
|
+
"strict"
|
|
49
|
+
>;
|
|
42
50
|
// Chaque information doit apparaître dans le sélecteur, même lorsqu’elle vaut false.
|
|
43
51
|
// Ajouter une variante au contrat oblige à réviser la sélection à cet endroit.
|
|
44
52
|
// Cela place la décision dans la couche qui doit la prendre, plutôt que de transmettre
|
|
@@ -51,17 +59,26 @@ const resultMatchInformation = DCommon.pipe(
|
|
|
51
59
|
myResult,
|
|
52
60
|
DEither.matchInformation(
|
|
53
61
|
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
"fail-task": (value) => {
|
|
63
|
+
type _CheckFailTaskValue = DCommon.ExpectType<typeof value, Error, "strict">;
|
|
64
|
+
return "fail-task" as const;
|
|
65
|
+
},
|
|
66
|
+
error: (value) => {
|
|
67
|
+
type _CheckErrorValue = DCommon.ExpectType<typeof value, Error, "strict">;
|
|
68
|
+
return "error" as const;
|
|
69
|
+
},
|
|
70
|
+
fail: (value) => {
|
|
71
|
+
type _CheckFailValue = DCommon.ExpectType<typeof value, void, "strict">;
|
|
72
|
+
return "fail" as const;
|
|
73
|
+
},
|
|
74
|
+
success: (value) => {
|
|
75
|
+
type _CheckSuccessValue = DCommon.ExpectType<typeof value, "result", "strict">;
|
|
76
|
+
return "success" as const;
|
|
77
|
+
},
|
|
62
78
|
},
|
|
63
79
|
),
|
|
64
80
|
);
|
|
81
|
+
type _CheckResultMatchInformation = DCommon.ExpectType<typeof resultMatchInformation, "fail-task" | "success" | "fail" | "error", "strict">;
|
|
65
82
|
// matchInformationOtherwise autorise un traitement partiel avec une branche de repli.
|
|
66
83
|
const resultWithFallback = DCommon.pipe(
|
|
67
84
|
myResult,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Enchaîner ou regrouper des opérations en arrêtant le traitement au premier Left.
|
|
5
5
|
*/
|
|
6
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
6
7
|
import * as DEither from "@duplojs/lang/either";
|
|
7
8
|
import * as DArray from "@duplojs/lang/array";
|
|
8
9
|
import * as DString from "@duplojs/lang/string";
|
|
@@ -18,8 +19,6 @@ declare const myResult: (
|
|
|
18
19
|
// wrapper `Right` lui-même. Dès qu’un Left apparaît, les étapes suivantes sont
|
|
19
20
|
// ignorées et ce Left est retourné. Une valeur finale brute est enveloppée dans
|
|
20
21
|
// Success ; un Right final est conservé.
|
|
21
|
-
// DEither.Left<"fail-task", Error> | DEither.Fail | DEither.Error<Error>
|
|
22
|
-
// | DEither.Left<"wrong", undefined> | DEither.Success<string>
|
|
23
22
|
const resultRightPipe = DEither.rightPipe(
|
|
24
23
|
myResult,
|
|
25
24
|
DString.split(""),
|
|
@@ -32,8 +31,13 @@ const resultRightPipe = DEither.rightPipe(
|
|
|
32
31
|
return DEither.success(elementAt);
|
|
33
32
|
},
|
|
34
33
|
// Cette étape reçoit la string du Success retourné ci-dessus, pas son wrapper.
|
|
35
|
-
|
|
34
|
+
DString.toUpperCase,
|
|
36
35
|
);
|
|
36
|
+
type _CheckResultRightPipe = DCommon.ExpectType<
|
|
37
|
+
typeof resultRightPipe,
|
|
38
|
+
DEither.Left<"fail-task", Error> | DEither.Fail | DEither.Error<Error> | DEither.Left<"wrong", undefined> | DEither.Success<Uppercase<string>>,
|
|
39
|
+
"strict"
|
|
40
|
+
>;
|
|
37
41
|
// `rightAsyncPipe` applique le même arrêt sur Left et attend chaque étape
|
|
38
42
|
// asynchrone. Une étape peut retourner un Either : s’il s’agit d’un Right,
|
|
39
43
|
// l’étape suivante reçoit encore sa valeur déballée ; s’il s’agit d’un Left,
|
|
@@ -43,8 +47,13 @@ const asyncResult = DEither.rightAsyncPipe(
|
|
|
43
47
|
(value) => Promise.resolve(DEither.right("normalized", value)),
|
|
44
48
|
DString.toLowerCase,
|
|
45
49
|
);
|
|
50
|
+
type _CheckAsyncResult = DCommon.ExpectType<
|
|
51
|
+
typeof asyncResult,
|
|
52
|
+
Promise<DEither.Left<"fail-task", Error> | DEither.Fail | DEither.Error<Error> | DEither.Success<"result">>,
|
|
53
|
+
"strict"
|
|
54
|
+
>;
|
|
46
55
|
// La dernière callback retourne une string brute : `asyncResult` est donc un
|
|
47
|
-
// `Success<
|
|
56
|
+
// `Success<"result">`, tandis que le `Right<"normalized", ...>` intermédiaire
|
|
48
57
|
// n’est pas transmis comme wrapper à la callback suivante.
|
|
49
58
|
// Si une étape intermédiaire produit un `Result` dont une information doit être
|
|
50
59
|
// sélectionnée, composez sa sélection dans cette même callback avec
|
|
@@ -54,17 +63,16 @@ const asyncResult = DEither.rightAsyncPipe(
|
|
|
54
63
|
// group rassemble les valeurs des Right dans un Success, ou retourne le premier Left.
|
|
55
64
|
// Les getters sont appelés dans l’ordre et ceux placés après un Left ne sont pas exécutés.
|
|
56
65
|
// Les valeurs déjà calculées avant l’appel à group ne peuvent pas être annulées.
|
|
57
|
-
// DEither.Left<"fail-task", Error> | DEither.Fail | DEither.Error<Error> | DEither.Error<"errorDeLaMort">
|
|
58
|
-
// | DEither.Success<{
|
|
59
|
-
// result1: "result";
|
|
60
|
-
// result2: "mySuperResult";
|
|
61
|
-
// result3: never;
|
|
62
|
-
// }>
|
|
63
66
|
const groupResult = DEither.group({
|
|
64
67
|
result1: () => myResult,
|
|
65
68
|
result2: DEither.success("mySuperResult"),
|
|
66
69
|
result3: DEither.error("errorDeLaMort"),
|
|
67
70
|
});
|
|
71
|
+
type _CheckGroupResult = DCommon.ExpectType<typeof groupResult, DEither.Left<"fail-task", Error> | DEither.Fail | DEither.Error<Error> | DEither.Error<"errorDeLaMort"> | DEither.Success<{
|
|
72
|
+
result1: "result";
|
|
73
|
+
result2: "mySuperResult";
|
|
74
|
+
result3: never;
|
|
75
|
+
}>, "strict">;
|
|
68
76
|
// asyncGroup attend chaque résultat dans l’ordre, sans lancer les getters en parallèle.
|
|
69
77
|
const asyncGroupResult = DEither.asyncGroup({
|
|
70
78
|
result1: () => Promise.resolve(myResult),
|
|
@@ -15,8 +15,6 @@ declare const myResult: (
|
|
|
15
15
|
|
|
16
16
|
// Réinterpréter les statuts selon le contexte : true donne Right, false donne Left.
|
|
17
17
|
// L’information et la valeur sont conservées ; le sélecteur couvre toutes les variantes.
|
|
18
|
-
// DEither.Left<"fail", void> | DEither.Left<"error", Error> | DEither.Left<"success", "result">
|
|
19
|
-
// | DEither.Right<"fail-task", Error>
|
|
20
18
|
const resultKeepAsRightSelection = DCommon.pipe(
|
|
21
19
|
myResult,
|
|
22
20
|
DEither.keepAsRightSelection({
|
|
@@ -26,15 +24,23 @@ const resultKeepAsRightSelection = DCommon.pipe(
|
|
|
26
24
|
success: false,
|
|
27
25
|
}),
|
|
28
26
|
);
|
|
27
|
+
type _CheckResultKeepAsRightSelection = DCommon.ExpectType<
|
|
28
|
+
typeof resultKeepAsRightSelection,
|
|
29
|
+
DEither.Left<"fail", void> | DEither.Left<"error", Error> | DEither.Left<"success", "result"> | DEither.Right<"fail-task", Error>,
|
|
30
|
+
"strict"
|
|
31
|
+
>;
|
|
29
32
|
// keepAsRightByInformation sélectionne seulement les informations à considérer comme Right.
|
|
30
33
|
// Toutes les autres deviennent Left, sans imposer de sélecteur exhaustif.
|
|
31
34
|
const resultByInformation = DEither.keepAsRightByInformation(myResult, "fail-task");
|
|
32
35
|
|
|
33
36
|
// Renommer une information adapte le vocabulaire du résultat au contexte appelant.
|
|
34
37
|
// rewriteInformation conserve le statut et la valeur ; les variantes non ciblées restent identiques.
|
|
35
|
-
// DEither.Fail | DEither.Error<Error> | DEither.Left<"fail-task", Error>
|
|
36
|
-
// | DEither.Right<"new-information", "result">
|
|
37
38
|
const resultRewriteInformation = DCommon.pipe(
|
|
38
39
|
myResult,
|
|
39
40
|
DEither.rewriteInformation({ success: "new-information" }),
|
|
40
41
|
);
|
|
42
|
+
type _CheckResultRewriteInformation = DCommon.ExpectType<
|
|
43
|
+
typeof resultRewriteInformation,
|
|
44
|
+
DEither.Fail | DEither.Error<Error> | DEither.Left<"fail-task", Error> | DEither.Right<"new-information", "result">,
|
|
45
|
+
"strict"
|
|
46
|
+
>;
|
|
@@ -25,8 +25,12 @@ import * as DCommon from "@duplojs/lang/common";
|
|
|
25
25
|
|
|
26
26
|
declare function someFunction(): string | number | null | undefined;
|
|
27
27
|
|
|
28
|
-
// DEither.None | DEither.Some<string> | DEither.Some<number>
|
|
29
28
|
const resultToMaybe = DEither.toMaybe(someFunction());
|
|
29
|
+
type _CheckResultToMaybeLine29 = DCommon.ExpectType<
|
|
30
|
+
typeof resultToMaybe,
|
|
31
|
+
DEither.None | DEither.Some<string> | DEither.Some<number>,
|
|
32
|
+
"strict"
|
|
33
|
+
>;
|
|
30
34
|
|
|
31
35
|
interface User {
|
|
32
36
|
name: string;
|
|
@@ -34,11 +38,11 @@ interface User {
|
|
|
34
38
|
declare function findUser(): DEither.Maybe<User>;
|
|
35
39
|
|
|
36
40
|
// Une transformation sur Some reçoit le User ; None est transmis sans exécuter la callback.
|
|
37
|
-
// DEither.None | DEither.Success<string>
|
|
38
41
|
const userName = DCommon.pipe(
|
|
39
42
|
findUser(),
|
|
40
43
|
DEither.whenIsRight((user) => DEither.success(user.name)),
|
|
41
44
|
);
|
|
45
|
+
type _CheckUserName = DCommon.ExpectType<typeof userName, DEither.None | DEither.Success<string>, "strict">;
|
|
42
46
|
|
|
43
47
|
// Une API qui lève sur un refus prévisible doit être adaptée pour le rendre
|
|
44
48
|
// exploitable comme résultat. Ne pas déduire la nature de l'échec du choix de cette API.
|
|
@@ -47,13 +51,22 @@ const userName = DCommon.pipe(
|
|
|
47
51
|
// La capture est large : distinguer le refus documenté d'une cause technique.
|
|
48
52
|
// Conserver cette cause dans le résultat jusqu'à sa consommation finale, sans
|
|
49
53
|
// la requalifier en refus métier ni la relancer depuis une fonction réutilisable.
|
|
50
|
-
// DEither.SafeCallbackError | DEither.SafeCallbackSuccess<"test">
|
|
51
54
|
const resultSafeCallback = DEither.safeCallback(
|
|
52
55
|
() => "test" as const,
|
|
53
56
|
);
|
|
57
|
+
type _CheckSafeCallback = DCommon.ExpectType<
|
|
58
|
+
typeof resultSafeCallback,
|
|
59
|
+
DEither.SafeCallbackError | DEither.SafeCallbackSuccess<"test">,
|
|
60
|
+
"strict"
|
|
61
|
+
>;
|
|
54
62
|
// asyncSafeCallback capture aussi les rejets et retourne toujours une Promise de résultat.
|
|
55
63
|
declare function loadValue(): Promise<string>;
|
|
56
64
|
const asyncSafeResult = DEither.asyncSafeCallback(loadValue);
|
|
65
|
+
type _CheckAsyncSafeResult = DCommon.ExpectType<
|
|
66
|
+
typeof asyncSafeResult,
|
|
67
|
+
Promise<DEither.SafeCallbackError | DEither.SafeCallbackSuccess<string>>,
|
|
68
|
+
"strict"
|
|
69
|
+
>;
|
|
57
70
|
|
|
58
71
|
// safeCallback gère aussi les promesses, mais une exception synchrone peut produire
|
|
59
72
|
// directement un Left : préférer asyncSafeCallback pour un retour toujours asynchrone.
|
|
@@ -3,60 +3,66 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Construire et réutiliser des structures pour décrire des données simples ou composées.
|
|
5
5
|
*/
|
|
6
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
6
7
|
import * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
7
8
|
|
|
8
9
|
// Une Structure associe un type TypeScript à une représentation capable de vérifier la donnée.
|
|
9
10
|
// Une TypeStructure repose sur un Type ; les autres structures composent plusieurs contrats.
|
|
10
11
|
|
|
11
|
-
// string
|
|
12
12
|
const nameStructure = DDataStructure.string();
|
|
13
|
+
type _CheckNameStructure = DCommon.ExpectType<DDataStructure.StructureValue<typeof nameStructure>, string, "strict">;
|
|
13
14
|
|
|
14
|
-
// number
|
|
15
15
|
const ageStructure = DDataStructure.number();
|
|
16
|
+
type _CheckAgeStructure = DCommon.ExpectType<DDataStructure.StructureValue<typeof ageStructure>, number, "strict">;
|
|
16
17
|
|
|
17
|
-
// boolean
|
|
18
18
|
const activeStructure = DDataStructure.boolean();
|
|
19
|
+
type _CheckActiveStructure = DCommon.ExpectType<
|
|
20
|
+
DDataStructure.StructureValue<typeof activeStructure>,
|
|
21
|
+
boolean,
|
|
22
|
+
"strict"
|
|
23
|
+
>;
|
|
19
24
|
|
|
20
25
|
// Les structures simples comme `string`, `number` ou `boolean` sont des
|
|
21
26
|
// `TypeStructure`. Elles représentent directement un type fondamental.
|
|
22
27
|
|
|
23
|
-
// "user"
|
|
24
28
|
const userKindStructure = DDataStructure.literal("user");
|
|
29
|
+
type _CheckUserKindStructure = DCommon.ExpectType<
|
|
30
|
+
DDataStructure.StructureValue<typeof userKindStructure>,
|
|
31
|
+
"user",
|
|
32
|
+
"strict"
|
|
33
|
+
>;
|
|
25
34
|
|
|
26
35
|
// `literal` produit également une `TypeStructure` lorsqu'une seule valeur
|
|
27
36
|
// est représentée.
|
|
28
37
|
|
|
29
|
-
// "admin" | "member" | "guest"
|
|
30
38
|
const roleStructure = DDataStructure.literal([
|
|
31
39
|
"admin",
|
|
32
40
|
"member",
|
|
33
41
|
"guest",
|
|
34
42
|
]);
|
|
43
|
+
type _CheckRoleStructure = DCommon.ExpectType<DDataStructure.StructureValue<typeof roleStructure>, "admin" | "member" | "guest", "strict">;
|
|
35
44
|
|
|
36
45
|
// Lorsque plusieurs valeurs sont représentées, `literal` construit une
|
|
37
46
|
// `UnionStructure` composée de plusieurs `TypeStructure`.
|
|
38
47
|
|
|
39
|
-
// {
|
|
40
|
-
// readonly street: string;
|
|
41
|
-
// readonly city: string;
|
|
42
|
-
// readonly zipCode: string;
|
|
43
|
-
// }
|
|
44
48
|
const addressStructure = DDataStructure.object({
|
|
45
49
|
street: DDataStructure.string(),
|
|
46
50
|
city: DDataStructure.string(),
|
|
47
51
|
zipCode: DDataStructure.string(),
|
|
48
52
|
});
|
|
53
|
+
type _CheckAddressStructure = DCommon.ExpectType<
|
|
54
|
+
DDataStructure.StructureValue<typeof addressStructure>,
|
|
55
|
+
{
|
|
56
|
+
readonly street: string;
|
|
57
|
+
readonly city: string;
|
|
58
|
+
readonly zipCode: string;
|
|
59
|
+
},
|
|
60
|
+
"strict"
|
|
61
|
+
>;
|
|
49
62
|
|
|
50
63
|
// `ObjectStructure` compose plusieurs structures pour représenter les
|
|
51
64
|
// propriétés d'un objet.
|
|
52
65
|
|
|
53
|
-
// {
|
|
54
|
-
// readonly name: string;
|
|
55
|
-
// readonly age: number;
|
|
56
|
-
// readonly active: boolean;
|
|
57
|
-
// readonly role: "admin" | "member" | "guest";
|
|
58
|
-
// readonly address: Address;
|
|
59
|
-
// }
|
|
60
66
|
const userStructure = DDataStructure.object({
|
|
61
67
|
name: nameStructure,
|
|
62
68
|
age: ageStructure,
|
|
@@ -64,61 +70,77 @@ const userStructure = DDataStructure.object({
|
|
|
64
70
|
role: roleStructure,
|
|
65
71
|
address: addressStructure,
|
|
66
72
|
});
|
|
73
|
+
type _CheckUserStructure = DCommon.ExpectType<
|
|
74
|
+
DDataStructure.StructureValue<typeof userStructure>,
|
|
75
|
+
{
|
|
76
|
+
readonly name: string;
|
|
77
|
+
readonly age: number;
|
|
78
|
+
readonly active: boolean;
|
|
79
|
+
readonly role: "admin" | "member" | "guest";
|
|
80
|
+
readonly address: DDataStructure.StructureValue<typeof addressStructure>;
|
|
81
|
+
},
|
|
82
|
+
"strict"
|
|
83
|
+
>;
|
|
67
84
|
|
|
68
85
|
// Une structure déjà définie peut et doit être réutilisée pour construire
|
|
69
86
|
// des structures plus complexes.
|
|
70
87
|
|
|
71
|
-
// readonly User[]
|
|
72
88
|
const usersStructure = DDataStructure.array(
|
|
73
89
|
userStructure,
|
|
74
90
|
);
|
|
91
|
+
type _CheckUsersStructure = DCommon.ExpectType<
|
|
92
|
+
DDataStructure.StructureValue<typeof usersStructure>,
|
|
93
|
+
readonly DDataStructure.StructureValue<typeof userStructure>[],
|
|
94
|
+
"strict"
|
|
95
|
+
>;
|
|
75
96
|
|
|
76
97
|
// `array` applique une même structure à chaque élément du tableau.
|
|
77
98
|
|
|
78
|
-
// {
|
|
79
|
-
// readonly name: string;
|
|
80
|
-
// readonly bio?: string | undefined;
|
|
81
|
-
// }
|
|
82
99
|
const profileStructure = DDataStructure.object({
|
|
83
100
|
name: DDataStructure.string(),
|
|
84
101
|
bio: DDataStructure.optional(
|
|
85
102
|
DDataStructure.string(),
|
|
86
103
|
),
|
|
87
104
|
});
|
|
105
|
+
type _CheckProfileStructure = DCommon.ExpectType<
|
|
106
|
+
DDataStructure.StructureValue<typeof profileStructure>,
|
|
107
|
+
{
|
|
108
|
+
readonly name: string;
|
|
109
|
+
readonly bio?: string | undefined;
|
|
110
|
+
},
|
|
111
|
+
"strict"
|
|
112
|
+
>;
|
|
88
113
|
|
|
89
114
|
type Profile = DDataStructure.StructureValue<typeof profileStructure>;
|
|
90
115
|
|
|
91
116
|
// `optional` ajoute `undefined` à une structure.
|
|
92
117
|
// Dans un `ObjectStructure`, cela permet également d'omettre la propriété.
|
|
93
118
|
|
|
94
|
-
// {
|
|
95
|
-
// readonly user: User | null;
|
|
96
|
-
// }
|
|
97
119
|
const sessionStructure = DDataStructure.object({
|
|
98
120
|
user: DDataStructure.nullable(
|
|
99
121
|
userStructure,
|
|
100
122
|
),
|
|
101
123
|
});
|
|
124
|
+
type _CheckSessionStructure = DCommon.ExpectType<
|
|
125
|
+
DDataStructure.StructureValue<typeof sessionStructure>,
|
|
126
|
+
{ readonly user: DDataStructure.StructureValue<typeof userStructure> | null },
|
|
127
|
+
"strict"
|
|
128
|
+
>;
|
|
102
129
|
|
|
103
130
|
// `nullable` ajoute `null` à une structure sans rendre la propriété optionnelle.
|
|
104
131
|
|
|
105
|
-
// string | number
|
|
106
132
|
const identifierStructure = DDataStructure.union([
|
|
107
133
|
DDataStructure.string(),
|
|
108
134
|
DDataStructure.number(),
|
|
109
135
|
]);
|
|
136
|
+
type _CheckIdentifierStructure = DCommon.ExpectType<
|
|
137
|
+
DDataStructure.StructureValue<typeof identifierStructure>,
|
|
138
|
+
string | number,
|
|
139
|
+
"strict"
|
|
140
|
+
>;
|
|
110
141
|
|
|
111
142
|
// `union` représente plusieurs structures possibles.
|
|
112
143
|
|
|
113
|
-
// {
|
|
114
|
-
// readonly type: "user-created";
|
|
115
|
-
// readonly user: User;
|
|
116
|
-
// }
|
|
117
|
-
// |
|
|
118
|
-
// {
|
|
119
|
-
// readonly type: "user-deleted";
|
|
120
|
-
// readonly userId: string | number;
|
|
121
|
-
// }
|
|
122
144
|
const eventStructure = DDataStructure.union([
|
|
123
145
|
DDataStructure.object({
|
|
124
146
|
type: DDataStructure.literal("user-created"),
|
|
@@ -129,14 +151,23 @@ const eventStructure = DDataStructure.union([
|
|
|
129
151
|
userId: identifierStructure,
|
|
130
152
|
}),
|
|
131
153
|
]);
|
|
154
|
+
interface UserCreatedEvent {
|
|
155
|
+
readonly type: "user-created";
|
|
156
|
+
readonly user: DDataStructure.StructureValue<typeof userStructure>;
|
|
157
|
+
}
|
|
158
|
+
interface UserDeletedEvent {
|
|
159
|
+
readonly type: "user-deleted";
|
|
160
|
+
readonly userId: string | number;
|
|
161
|
+
}
|
|
162
|
+
type _CheckEventStructure = DCommon.ExpectType<
|
|
163
|
+
DDataStructure.StructureValue<typeof eventStructure>,
|
|
164
|
+
UserCreatedEvent | UserDeletedEvent,
|
|
165
|
+
"strict"
|
|
166
|
+
>;
|
|
132
167
|
|
|
133
168
|
// Les unions peuvent représenter plusieurs formes d'objets.
|
|
134
169
|
// Des valeurs littérales peuvent être utilisées pour créer une union discriminée.
|
|
135
170
|
|
|
136
|
-
// {
|
|
137
|
-
// readonly fr: string;
|
|
138
|
-
// readonly en: string;
|
|
139
|
-
// }
|
|
140
171
|
const translationsStructure = DDataStructure.record(
|
|
141
172
|
DDataStructure.literal([
|
|
142
173
|
"fr",
|
|
@@ -144,43 +175,50 @@ const translationsStructure = DDataStructure.record(
|
|
|
144
175
|
]),
|
|
145
176
|
DDataStructure.string(),
|
|
146
177
|
);
|
|
178
|
+
type _CheckTranslationsStructure = DCommon.ExpectType<
|
|
179
|
+
DDataStructure.StructureValue<typeof translationsStructure>,
|
|
180
|
+
{
|
|
181
|
+
readonly fr: string;
|
|
182
|
+
readonly en: string;
|
|
183
|
+
},
|
|
184
|
+
"strict"
|
|
185
|
+
>;
|
|
147
186
|
|
|
148
187
|
// `record` représente un objet dont les clés possibles et les valeurs
|
|
149
188
|
// sont elles-mêmes décrites par des structures.
|
|
150
189
|
|
|
151
|
-
// {
|
|
152
|
-
// readonly name?: string | undefined;
|
|
153
|
-
// readonly age?: number | undefined;
|
|
154
|
-
// readonly active?: boolean | undefined;
|
|
155
|
-
// readonly role?: "admin" | "member" | "guest" | undefined;
|
|
156
|
-
// readonly address?: Address | undefined;
|
|
157
|
-
// }
|
|
158
190
|
const updateUserStructure = DDataStructure.partial(
|
|
159
191
|
userStructure,
|
|
160
192
|
);
|
|
193
|
+
type _CheckUpdateUserStructure = DCommon.ExpectType<
|
|
194
|
+
DDataStructure.StructureValue<typeof updateUserStructure>,
|
|
195
|
+
{
|
|
196
|
+
readonly name?: string | undefined;
|
|
197
|
+
readonly age?: number | undefined;
|
|
198
|
+
readonly active?: boolean | undefined;
|
|
199
|
+
readonly role?: "admin" | "member" | "guest" | undefined;
|
|
200
|
+
readonly address?: DDataStructure.StructureValue<typeof addressStructure> | undefined;
|
|
201
|
+
},
|
|
202
|
+
"strict"
|
|
203
|
+
>;
|
|
161
204
|
|
|
162
205
|
// `partial` transforme toutes les propriétés d'un `ObjectStructure`
|
|
163
206
|
// en propriétés optionnelles.
|
|
164
207
|
|
|
165
|
-
// {
|
|
166
|
-
// readonly name: string;
|
|
167
|
-
// readonly bio: string;
|
|
168
|
-
// }
|
|
169
208
|
const requiredProfileStructure = DDataStructure.required(
|
|
170
209
|
profileStructure,
|
|
171
210
|
);
|
|
211
|
+
type _CheckRequiredProfileStructure = DCommon.ExpectType<
|
|
212
|
+
DDataStructure.StructureValue<typeof requiredProfileStructure>,
|
|
213
|
+
{
|
|
214
|
+
readonly name: string;
|
|
215
|
+
readonly bio: string;
|
|
216
|
+
},
|
|
217
|
+
"strict"
|
|
218
|
+
>;
|
|
172
219
|
|
|
173
220
|
// `required` réalise l'opération inverse et rend les propriétés obligatoires.
|
|
174
221
|
|
|
175
|
-
// {
|
|
176
|
-
// readonly name: string;
|
|
177
|
-
// readonly age: number;
|
|
178
|
-
// readonly active: boolean;
|
|
179
|
-
// readonly role: "admin" | "member" | "guest";
|
|
180
|
-
// readonly address: Address;
|
|
181
|
-
// readonly id: string | number;
|
|
182
|
-
// readonly createdAt: string;
|
|
183
|
-
// }
|
|
184
222
|
const persistedUserStructure = DDataStructure.extend(
|
|
185
223
|
userStructure,
|
|
186
224
|
{
|
|
@@ -188,6 +226,19 @@ const persistedUserStructure = DDataStructure.extend(
|
|
|
188
226
|
createdAt: DDataStructure.string(),
|
|
189
227
|
},
|
|
190
228
|
);
|
|
229
|
+
type _CheckPersistedUserStructure = DCommon.ExpectType<
|
|
230
|
+
DDataStructure.StructureValue<typeof persistedUserStructure>,
|
|
231
|
+
{
|
|
232
|
+
readonly name: string;
|
|
233
|
+
readonly age: number;
|
|
234
|
+
readonly active: boolean;
|
|
235
|
+
readonly role: "admin" | "member" | "guest";
|
|
236
|
+
readonly address: DDataStructure.StructureValue<typeof addressStructure>;
|
|
237
|
+
readonly id: string | number;
|
|
238
|
+
readonly createdAt: string;
|
|
239
|
+
},
|
|
240
|
+
"strict"
|
|
241
|
+
>;
|
|
191
242
|
|
|
192
243
|
// `extend` crée un nouvel `ObjectStructure` en ajoutant des propriétés
|
|
193
244
|
// à une structure objet existante.
|