@duplojs/agents-kit 0.0.0-stage → 0.1.0-beta.3
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 +73 -2
- package/dist/bin/index.d.ts +2 -0
- package/dist/bin/index.mjs +7 -0
- package/dist/bin/install/index.d.ts +2 -0
- package/dist/bin/install/index.mjs +25 -0
- package/dist/bin/install/skill.d.ts +28 -0
- package/dist/bin/install/skill.mjs +58 -0
- package/dist/bin/packagePath.d.ts +2 -0
- package/dist/bin/packagePath.mjs +12 -0
- package/dist/bin/setup/index.d.ts +12 -0
- package/dist/bin/setup/index.mjs +33 -0
- package/dist/bin/setup/instructions.d.ts +8 -0
- package/dist/bin/setup/instructions.mjs +27 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +0 -0
- package/docs/API/10-lang/10-array/10-at.ts +65 -0
- package/docs/API/10-lang/10-array/10-chunk.ts +42 -0
- package/docs/API/10-lang/10-array/10-coalescing.ts +19 -0
- package/docs/API/10-lang/10-array/10-concat.ts +34 -0
- package/docs/API/10-lang/10-array/10-copyWithin.ts +34 -0
- package/docs/API/10-lang/10-array/10-every.ts +25 -0
- package/docs/API/10-lang/10-array/10-fill.ts +34 -0
- package/docs/API/10-lang/10-array/10-fillAll.ts +34 -0
- package/docs/API/10-lang/10-array/10-filter.ts +43 -0
- package/docs/API/10-lang/10-array/10-find.ts +33 -0
- package/docs/API/10-lang/10-array/10-findAndReplace.ts +35 -0
- package/docs/API/10-lang/10-array/10-findAndSpliceDelete.ts +35 -0
- package/docs/API/10-lang/10-array/10-findAndSpliceInsert.ts +35 -0
- package/docs/API/10-lang/10-array/10-findAndSpliceReplace.ts +24 -0
- package/docs/API/10-lang/10-array/10-findDuplicates.ts +19 -0
- package/docs/API/10-lang/10-array/10-findIndex.ts +25 -0
- package/docs/API/10-lang/10-array/10-findLast.ts +33 -0
- package/docs/API/10-lang/10-array/10-findLastIndex.ts +25 -0
- package/docs/API/10-lang/10-array/10-first.ts +21 -0
- package/docs/API/10-lang/10-array/10-flat.ts +22 -0
- package/docs/API/10-lang/10-array/10-flatMap.ts +24 -0
- package/docs/API/10-lang/10-array/10-from.ts +25 -0
- package/docs/API/10-lang/10-array/10-group.ts +27 -0
- package/docs/API/10-lang/10-array/10-groupOutput.ts +30 -0
- package/docs/API/10-lang/10-array/10-includes.ts +24 -0
- package/docs/API/10-lang/10-array/10-indexOf.ts +24 -0
- package/docs/API/10-lang/10-array/10-insert.ts +34 -0
- package/docs/API/10-lang/10-array/10-is.ts +15 -0
- package/docs/API/10-lang/10-array/10-isLastIndex.ts +24 -0
- package/docs/API/10-lang/10-array/10-last.ts +21 -0
- package/docs/API/10-lang/10-array/10-lastIndexOf.ts +24 -0
- package/docs/API/10-lang/10-array/10-length.ts +28 -0
- package/docs/API/10-lang/10-array/10-lengthEqual.ts +39 -0
- package/docs/API/10-lang/10-array/10-map.ts +34 -0
- package/docs/API/10-lang/10-array/10-maxElements.ts +44 -0
- package/docs/API/10-lang/10-array/10-minElements.ts +44 -0
- package/docs/API/10-lang/10-array/10-notIncludes.ts +24 -0
- package/docs/API/10-lang/10-array/10-pop.ts +23 -0
- package/docs/API/10-lang/10-array/10-prepend.ts +34 -0
- package/docs/API/10-lang/10-array/10-push.ts +34 -0
- package/docs/API/10-lang/10-array/10-reduce.ts +28 -0
- package/docs/API/10-lang/10-array/10-reduceFrom.ts +16 -0
- package/docs/API/10-lang/10-array/10-reduceRight.ts +28 -0
- package/docs/API/10-lang/10-array/10-reverse.ts +25 -0
- package/docs/API/10-lang/10-array/10-select.ts +26 -0
- package/docs/API/10-lang/10-array/10-set.ts +24 -0
- package/docs/API/10-lang/10-array/10-shift.ts +23 -0
- package/docs/API/10-lang/10-array/10-slice.ts +24 -0
- package/docs/API/10-lang/10-array/10-some.ts +25 -0
- package/docs/API/10-lang/10-array/10-sort.ts +34 -0
- package/docs/API/10-lang/10-array/10-spliceDelete.ts +34 -0
- package/docs/API/10-lang/10-array/10-spliceInsert.ts +34 -0
- package/docs/API/10-lang/10-array/10-spliceReplace.ts +24 -0
- package/docs/API/10-lang/10-array/10-unshift.ts +34 -0
- package/docs/API/10-lang/10-array/index.llms.md +220 -0
- package/docs/API/10-lang/10-array/index.md +3 -0
- package/docs/API/10-lang/10-chrono/10-addDays.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-addHours.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-addMilliseconds.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-addMinutes.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-addMonths.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-addSeconds.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-addTime.ts +38 -0
- package/docs/API/10-lang/10-chrono/10-addWeeks.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-addYears.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-applyTimezone.ts +29 -0
- package/docs/API/10-lang/10-chrono/10-betweenThanDate.ts +27 -0
- package/docs/API/10-lang/10-chrono/10-betweenThanOrEqualDate.ts +27 -0
- package/docs/API/10-lang/10-chrono/10-betweenThanOrEqualTime.ts +27 -0
- package/docs/API/10-lang/10-chrono/10-betweenThanTime.ts +27 -0
- package/docs/API/10-lang/10-chrono/10-closestTo.ts +48 -0
- package/docs/API/10-lang/10-chrono/10-computeTime.ts +35 -0
- package/docs/API/10-lang/10-chrono/10-createDate.ts +122 -0
- package/docs/API/10-lang/10-chrono/10-createDateOrThrow.ts +39 -0
- package/docs/API/10-lang/10-chrono/10-createTime.ts +86 -0
- package/docs/API/10-lang/10-chrono/10-createTimeOrThrow.ts +28 -0
- package/docs/API/10-lang/10-chrono/10-eachDate.ts +67 -0
- package/docs/API/10-lang/10-chrono/10-equalDate.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-equalTime.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-formatDate.ts +43 -0
- package/docs/API/10-lang/10-chrono/10-formatTime.ts +37 -0
- package/docs/API/10-lang/10-chrono/10-getDayOfMonth.ts +37 -0
- package/docs/API/10-lang/10-chrono/10-getDayOfWeek.ts +30 -0
- package/docs/API/10-lang/10-chrono/10-getDayOfYear.ts +28 -0
- package/docs/API/10-lang/10-chrono/10-getDifference.ts +29 -0
- package/docs/API/10-lang/10-chrono/10-getFirstDayOfMonth.ts +24 -0
- package/docs/API/10-lang/10-chrono/10-getFirstDayOfWeek.ts +24 -0
- package/docs/API/10-lang/10-chrono/10-getHour.ts +28 -0
- package/docs/API/10-lang/10-chrono/10-getLastDayOfMonth.ts +24 -0
- package/docs/API/10-lang/10-chrono/10-getLastDayOfWeek.ts +24 -0
- package/docs/API/10-lang/10-chrono/10-getMilliseconds.ts +24 -0
- package/docs/API/10-lang/10-chrono/10-getMinute.ts +27 -0
- package/docs/API/10-lang/10-chrono/10-getMonth.ts +27 -0
- package/docs/API/10-lang/10-chrono/10-getSecond.ts +27 -0
- package/docs/API/10-lang/10-chrono/10-getTimezoneOffset.ts +28 -0
- package/docs/API/10-lang/10-chrono/10-getWeekOfYear.ts +27 -0
- package/docs/API/10-lang/10-chrono/10-getYear.ts +27 -0
- package/docs/API/10-lang/10-chrono/10-greaterThanDate.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-greaterThanOrEqualDate.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-greaterThanOrEqualTime.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-greaterThanTime.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-isDate.ts +23 -0
- package/docs/API/10-lang/10-chrono/10-isSafeTimeValue.ts +19 -0
- package/docs/API/10-lang/10-chrono/10-isSafeTimestamp.ts +19 -0
- package/docs/API/10-lang/10-chrono/10-isSerializedTheDate.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-isSerializedTheTime.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-isTime.ts +23 -0
- package/docs/API/10-lang/10-chrono/10-lessThanDate.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-lessThanOrEqualDate.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-lessThanOrEqualTime.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-lessThanTime.ts +26 -0
- package/docs/API/10-lang/10-chrono/10-makeSafeTimeValue.ts +19 -0
- package/docs/API/10-lang/10-chrono/10-makeSafeTimestamp.ts +19 -0
- package/docs/API/10-lang/10-chrono/10-maxDate.ts +23 -0
- package/docs/API/10-lang/10-chrono/10-maxTime.ts +23 -0
- package/docs/API/10-lang/10-chrono/10-minDate.ts +23 -0
- package/docs/API/10-lang/10-chrono/10-minTime.ts +23 -0
- package/docs/API/10-lang/10-chrono/10-now.ts +13 -0
- package/docs/API/10-lang/10-chrono/10-round.ts +41 -0
- package/docs/API/10-lang/10-chrono/10-serialize.ts +23 -0
- package/docs/API/10-lang/10-chrono/10-sortDates.ts +32 -0
- package/docs/API/10-lang/10-chrono/10-sortTimes.ts +31 -0
- package/docs/API/10-lang/10-chrono/10-subtractDays.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-subtractHours.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-subtractMilliseconds.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-subtractMinutes.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-subtractMonths.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-subtractSeconds.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-subtractTime.ts +38 -0
- package/docs/API/10-lang/10-chrono/10-subtractWeeks.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-subtractYears.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-toDateISOString.ts +17 -0
- package/docs/API/10-lang/10-chrono/10-toNative.ts +25 -0
- package/docs/API/10-lang/10-chrono/10-toTimeValue.ts +17 -0
- package/docs/API/10-lang/10-chrono/10-toTimestamp.ts +17 -0
- package/docs/API/10-lang/10-chrono/10-today.ts +13 -0
- package/docs/API/10-lang/10-chrono/10-tomorrow.ts +13 -0
- package/docs/API/10-lang/10-chrono/10-yesterday.ts +13 -0
- package/docs/API/10-lang/10-chrono/index.llms.md +332 -0
- package/docs/API/10-lang/10-chrono/index.md +3 -0
- package/docs/API/10-lang/10-common/10-and.ts +45 -0
- package/docs/API/10-lang/10-common/10-asserts.ts +13 -0
- package/docs/API/10-lang/10-common/10-asyncInnerPipe.ts +23 -0
- package/docs/API/10-lang/10-common/10-asyncLoop.ts +25 -0
- package/docs/API/10-lang/10-common/10-asyncPipe.ts +21 -0
- package/docs/API/10-lang/10-common/10-callThen.ts +22 -0
- package/docs/API/10-lang/10-common/10-cast.ts +16 -0
- package/docs/API/10-lang/10-common/10-clone.ts +12 -0
- package/docs/API/10-lang/10-common/10-createAsyncRetry.ts +34 -0
- package/docs/API/10-lang/10-common/10-createBuilder.ts +19 -0
- package/docs/API/10-lang/10-common/10-createEnum.ts +25 -0
- package/docs/API/10-lang/10-common/10-createExternalPromise.ts +13 -0
- package/docs/API/10-lang/10-common/10-createFormData.ts +16 -0
- package/docs/API/10-lang/10-common/10-createInterpolation.ts +12 -0
- package/docs/API/10-lang/10-common/10-createQueue.ts +16 -0
- package/docs/API/10-lang/10-common/10-createTransformer.ts +16 -0
- package/docs/API/10-lang/10-common/10-detachObjectMethod.ts +20 -0
- package/docs/API/10-lang/10-common/10-equal.ts +31 -0
- package/docs/API/10-lang/10-common/10-escapeRegExp.ts +11 -0
- package/docs/API/10-lang/10-common/10-falsy.ts +12 -0
- package/docs/API/10-lang/10-common/10-forward.ts +11 -0
- package/docs/API/10-lang/10-common/10-forwardAsserts.ts +17 -0
- package/docs/API/10-lang/10-common/10-forwardLog.ts +11 -0
- package/docs/API/10-lang/10-common/10-infer.ts +16 -0
- package/docs/API/10-lang/10-common/10-innerPipe.ts +23 -0
- package/docs/API/10-lang/10-common/10-instanceOf.ts +23 -0
- package/docs/API/10-lang/10-common/10-isType.ts +29 -0
- package/docs/API/10-lang/10-common/10-justExec.ts +28 -0
- package/docs/API/10-lang/10-common/10-justReturn.ts +19 -0
- package/docs/API/10-lang/10-common/10-loop.ts +20 -0
- package/docs/API/10-lang/10-common/10-memo.ts +12 -0
- package/docs/API/10-lang/10-common/10-memoObject.ts +11 -0
- package/docs/API/10-lang/10-common/10-memoPromise.ts +16 -0
- package/docs/API/10-lang/10-common/10-or.ts +29 -0
- package/docs/API/10-lang/10-common/10-pipe.ts +21 -0
- package/docs/API/10-lang/10-common/10-pipeCall.ts +20 -0
- package/docs/API/10-lang/10-common/10-prepareAsyncPipe.ts +20 -0
- package/docs/API/10-lang/10-common/10-preparePipe.ts +20 -0
- package/docs/API/10-lang/10-common/10-promiseAll.ts +16 -0
- package/docs/API/10-lang/10-common/10-promiseObject.ts +22 -0
- package/docs/API/10-lang/10-common/10-removeConstraint.ts +13 -0
- package/docs/API/10-lang/10-common/10-shameOnYou.ts +20 -0
- package/docs/API/10-lang/10-common/10-simpleClone.ts +12 -0
- package/docs/API/10-lang/10-common/10-stringToBytes.ts +16 -0
- package/docs/API/10-lang/10-common/10-stringToMillisecond.ts +17 -0
- package/docs/API/10-lang/10-common/10-timeout.ts +11 -0
- package/docs/API/10-lang/10-common/10-toCurriedPredicate.ts +28 -0
- package/docs/API/10-lang/10-common/10-toJSON.ts +15 -0
- package/docs/API/10-lang/10-common/10-toNative.ts +15 -0
- package/docs/API/10-lang/10-common/10-toRegExp.ts +17 -0
- package/docs/API/10-lang/10-common/10-transformer.ts +21 -0
- package/docs/API/10-lang/10-common/10-truthy.ts +12 -0
- package/docs/API/10-lang/10-common/10-useAsyncRetry.ts +31 -0
- package/docs/API/10-lang/10-common/10-when.ts +27 -0
- package/docs/API/10-lang/10-common/10-whenElse.ts +28 -0
- package/docs/API/10-lang/10-common/10-whenNot.ts +26 -0
- package/docs/API/10-lang/10-common/index.llms.md +228 -0
- package/docs/API/10-lang/10-common/index.md +3 -0
- package/docs/API/10-lang/10-dataStructure/10-absolutePath.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-allowedCharacters.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-array.ts +23 -0
- package/docs/API/10-lang/10-dataStructure/10-arrayLengthEqual.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-betweenThan.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-betweenThanOrEqual.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-bigint.ts +22 -0
- package/docs/API/10-lang/10-dataStructure/10-boolean.ts +22 -0
- package/docs/API/10-lang/10-dataStructure/10-createCodec.ts +45 -0
- package/docs/API/10-lang/10-dataStructure/10-createCodecs.ts +134 -0
- package/docs/API/10-lang/10-dataStructure/10-createErrorInterpreter.ts +74 -0
- package/docs/API/10-lang/10-dataStructure/10-date.ts +23 -0
- package/docs/API/10-lang/10-dataStructure/10-email.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-endsWith.ts +24 -0
- package/docs/API/10-lang/10-dataStructure/10-even.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-extend.ts +27 -0
- package/docs/API/10-lang/10-dataStructure/10-greaterThan.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-greaterThanOrEqual.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-include.ts +24 -0
- package/docs/API/10-lang/10-dataStructure/10-integer.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-isNullStructure.ts +12 -0
- package/docs/API/10-lang/10-dataStructure/10-isNullable.ts +12 -0
- package/docs/API/10-lang/10-dataStructure/10-isOptional.ts +12 -0
- package/docs/API/10-lang/10-dataStructure/10-isUndefinedStructure.ts +12 -0
- package/docs/API/10-lang/10-dataStructure/10-lazy.ts +23 -0
- package/docs/API/10-lang/10-dataStructure/10-lessThan.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-lessThanOrEqual.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-literal.ts +19 -0
- package/docs/API/10-lang/10-dataStructure/10-maxCharacters.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-maxElements.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-minCharacters.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-minElements.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-multipleOf.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-negative.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-notEmpty.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-notZero.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-null.ts +22 -0
- package/docs/API/10-lang/10-dataStructure/10-nullable.ts +19 -0
- package/docs/API/10-lang/10-dataStructure/10-number.ts +22 -0
- package/docs/API/10-lang/10-dataStructure/10-numberInString.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-object.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-odd.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-optional.ts +19 -0
- package/docs/API/10-lang/10-dataStructure/10-partial.ts +23 -0
- package/docs/API/10-lang/10-dataStructure/10-path.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-positive.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-record.ts +22 -0
- package/docs/API/10-lang/10-dataStructure/10-refine.ts +27 -0
- package/docs/API/10-lang/10-dataStructure/10-regex.ts +24 -0
- package/docs/API/10-lang/10-dataStructure/10-required.ts +21 -0
- package/docs/API/10-lang/10-dataStructure/10-safe.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-segmentPath.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-startsWith.ts +24 -0
- package/docs/API/10-lang/10-dataStructure/10-strictNegative.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-strictPositive.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-string.ts +22 -0
- package/docs/API/10-lang/10-dataStructure/10-stringLengthEqual.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-time.ts +23 -0
- package/docs/API/10-lang/10-dataStructure/10-trimmed.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-typeStructureIdentifier.ts +33 -0
- package/docs/API/10-lang/10-dataStructure/10-undefined.ts +22 -0
- package/docs/API/10-lang/10-dataStructure/10-union.ts +24 -0
- package/docs/API/10-lang/10-dataStructure/10-unwrapLazy.ts +17 -0
- package/docs/API/10-lang/10-dataStructure/10-url.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/10-uuid.ts +25 -0
- package/docs/API/10-lang/10-dataStructure/index.llms.md +264 -0
- package/docs/API/10-lang/10-dataStructure/index.md +3 -0
- package/docs/API/10-lang/10-either/10-asyncGroup.ts +44 -0
- package/docs/API/10-lang/10-either/10-asyncSafeCallback.ts +23 -0
- package/docs/API/10-lang/10-either/10-error.ts +12 -0
- package/docs/API/10-lang/10-either/10-expect.ts +13 -0
- package/docs/API/10-lang/10-either/10-fail.ts +12 -0
- package/docs/API/10-lang/10-either/10-forwardAssertsSelection.ts +28 -0
- package/docs/API/10-lang/10-either/10-group.ts +58 -0
- package/docs/API/10-lang/10-either/10-hasInformation.ts +24 -0
- package/docs/API/10-lang/10-either/10-isLeft.ts +16 -0
- package/docs/API/10-lang/10-either/10-isRight.ts +16 -0
- package/docs/API/10-lang/10-either/10-isSelected.ts +29 -0
- package/docs/API/10-lang/10-either/10-keepAsRightByInformation.ts +29 -0
- package/docs/API/10-lang/10-either/10-keepAsRightSelection.ts +23 -0
- package/docs/API/10-lang/10-either/10-left.ts +13 -0
- package/docs/API/10-lang/10-either/10-matchInformation.ts +26 -0
- package/docs/API/10-lang/10-either/10-matchInformationOtherwise.ts +27 -0
- package/docs/API/10-lang/10-either/10-none.ts +12 -0
- package/docs/API/10-lang/10-either/10-ok.ts +12 -0
- package/docs/API/10-lang/10-either/10-result.ts +18 -0
- package/docs/API/10-lang/10-either/10-rewriteInformation.ts +24 -0
- package/docs/API/10-lang/10-either/10-right.ts +13 -0
- package/docs/API/10-lang/10-either/10-rightAsyncPipe.ts +69 -0
- package/docs/API/10-lang/10-either/10-rightPipe.ts +72 -0
- package/docs/API/10-lang/10-either/10-safeCallback.ts +29 -0
- package/docs/API/10-lang/10-either/10-some.ts +12 -0
- package/docs/API/10-lang/10-either/10-success.ts +12 -0
- package/docs/API/10-lang/10-either/10-toMaybe.ts +53 -0
- package/docs/API/10-lang/10-either/10-unwrapByInformation.ts +20 -0
- package/docs/API/10-lang/10-either/10-unwrapByInformationOrThrow.ts +19 -0
- package/docs/API/10-lang/10-either/10-unwrapLeft.ts +14 -0
- package/docs/API/10-lang/10-either/10-unwrapLeftOrThrow.ts +17 -0
- package/docs/API/10-lang/10-either/10-unwrapOr.ts +17 -0
- package/docs/API/10-lang/10-either/10-unwrapOtherwise.ts +20 -0
- package/docs/API/10-lang/10-either/10-unwrapRight.ts +14 -0
- package/docs/API/10-lang/10-either/10-unwrapRightOrThrow.ts +17 -0
- package/docs/API/10-lang/10-either/10-unwrapSelection.ts +26 -0
- package/docs/API/10-lang/10-either/10-unwrapSelectionOrThrow.ts +19 -0
- package/docs/API/10-lang/10-either/10-whenHasInformation.ts +35 -0
- package/docs/API/10-lang/10-either/10-whenHasInformationOtherwise.ts +29 -0
- package/docs/API/10-lang/10-either/10-whenIsLeft.ts +20 -0
- package/docs/API/10-lang/10-either/10-whenIsLeftOtherwise.ts +27 -0
- package/docs/API/10-lang/10-either/10-whenIsRight.ts +20 -0
- package/docs/API/10-lang/10-either/10-whenIsRightOtherwise.ts +26 -0
- package/docs/API/10-lang/10-either/10-whenIsSelected.ts +33 -0
- package/docs/API/10-lang/10-either/10-whenIsSelectedOtherwise.ts +35 -0
- package/docs/API/10-lang/10-either/index.llms.md +184 -0
- package/docs/API/10-lang/10-either/index.md +3 -0
- package/docs/API/10-lang/10-generator/10-asyncChunk.ts +55 -0
- package/docs/API/10-lang/10-generator/10-asyncConcat.ts +46 -0
- package/docs/API/10-lang/10-generator/10-asyncFilter.ts +41 -0
- package/docs/API/10-lang/10-generator/10-asyncFlat.ts +37 -0
- package/docs/API/10-lang/10-generator/10-asyncGroup.ts +65 -0
- package/docs/API/10-lang/10-generator/10-asyncLoop.ts +59 -0
- package/docs/API/10-lang/10-generator/10-asyncMap.ts +48 -0
- package/docs/API/10-lang/10-generator/10-asyncReduce.ts +63 -0
- package/docs/API/10-lang/10-generator/10-chunk.ts +44 -0
- package/docs/API/10-lang/10-generator/10-concat.ts +37 -0
- package/docs/API/10-lang/10-generator/10-createExternalAsyncGenerator.ts +29 -0
- package/docs/API/10-lang/10-generator/10-execute.ts +44 -0
- package/docs/API/10-lang/10-generator/10-filter.ts +35 -0
- package/docs/API/10-lang/10-generator/10-flat.ts +25 -0
- package/docs/API/10-lang/10-generator/10-group.ts +44 -0
- package/docs/API/10-lang/10-generator/10-groupOutput.ts +48 -0
- package/docs/API/10-lang/10-generator/10-loop.ts +55 -0
- package/docs/API/10-lang/10-generator/10-map.ts +35 -0
- package/docs/API/10-lang/10-generator/10-reduce.ts +51 -0
- package/docs/API/10-lang/10-generator/10-reduceFrom.ts +30 -0
- package/docs/API/10-lang/10-generator/index.llms.md +84 -0
- package/docs/API/10-lang/10-generator/index.md +3 -0
- package/docs/API/10-lang/index.md +3 -0
- package/docs/API/index.md +3 -0
- package/docs/API.llms.md +31 -0
- package/docs/concepts/01-fundamental/01-constraint/01-use.ts +22 -0
- package/docs/concepts/01-fundamental/01-constraint/10-built-in-constraint.ts +37 -0
- package/docs/concepts/01-fundamental/01-constraint/20-manipulation.ts +38 -0
- package/docs/concepts/01-fundamental/01-constraint/30-cast.ts +62 -0
- package/docs/concepts/01-fundamental/01-constraint/40-custom-constraint.ts +45 -0
- package/docs/concepts/01-fundamental/01-constraint/index.md +3 -0
- package/docs/concepts/01-fundamental/02-currying/01-use.ts +33 -0
- package/docs/concepts/01-fundamental/02-currying/10-built-in-function.ts +178 -0
- package/docs/concepts/01-fundamental/02-currying/20-inner-pipe.ts +39 -0
- package/docs/concepts/01-fundamental/02-currying/30-async-pipe.ts +42 -0
- package/docs/concepts/01-fundamental/02-currying/index.md +3 -0
- package/docs/concepts/01-fundamental/03-either/01-use.ts +21 -0
- package/docs/concepts/01-fundamental/03-either/10-discrimination.ts +79 -0
- package/docs/concepts/01-fundamental/03-either/20-exhaustive-handling.ts +73 -0
- package/docs/concepts/01-fundamental/03-either/30-composition.ts +72 -0
- package/docs/concepts/01-fundamental/03-either/40-result-adaptation.ts +40 -0
- package/docs/concepts/01-fundamental/03-either/50-external-results.ts +59 -0
- package/docs/concepts/01-fundamental/03-either/60-contextual-state.ts +40 -0
- package/docs/concepts/01-fundamental/03-either/index.md +3 -0
- package/docs/concepts/01-fundamental/04-data-structure/01-use.ts +22 -0
- package/docs/concepts/01-fundamental/04-data-structure/10-structure.ts +193 -0
- package/docs/concepts/01-fundamental/04-data-structure/20-constraint.ts +78 -0
- package/docs/concepts/01-fundamental/04-data-structure/30-validation.ts +100 -0
- package/docs/concepts/01-fundamental/04-data-structure/40-codecs.ts +151 -0
- package/docs/concepts/01-fundamental/04-data-structure/50-recursive.ts +48 -0
- package/docs/concepts/01-fundamental/04-data-structure/60-interpret-error.ts +123 -0
- package/docs/concepts/01-fundamental/04-data-structure/index.md +3 -0
- package/docs/concepts/01-fundamental/05-chrono/01-use.ts +14 -0
- package/docs/concepts/01-fundamental/05-chrono/10-creation.ts +59 -0
- package/docs/concepts/01-fundamental/05-chrono/20-manipulation.ts +94 -0
- package/docs/concepts/01-fundamental/05-chrono/30-serialized.ts +73 -0
- package/docs/concepts/01-fundamental/05-chrono/40-timezone.ts +81 -0
- package/docs/concepts/01-fundamental/05-chrono/index.md +3 -0
- package/docs/concepts/01-fundamental/06-modeling/10-new-type.ts +42 -0
- package/docs/concepts/01-fundamental/06-modeling/20-entity.ts +204 -0
- package/docs/concepts/01-fundamental/06-modeling/30-tagged-object.ts +181 -0
- package/docs/concepts/01-fundamental/06-modeling/40-entity-lifecycle.ts +275 -0
- package/docs/concepts/01-fundamental/06-modeling/50-evidence.ts +94 -0
- package/docs/concepts/01-fundamental/06-modeling/60-signed-function.ts +26 -0
- package/docs/concepts/01-fundamental/06-modeling/index.md +3 -0
- package/docs/concepts/01-fundamental/07-discrimination/10-entity.ts +104 -0
- package/docs/concepts/01-fundamental/07-discrimination/20-fact.ts +142 -0
- package/docs/concepts/01-fundamental/07-discrimination/30-tagged-object.ts +105 -0
- package/docs/concepts/01-fundamental/07-discrimination/40-error.ts +57 -0
- package/docs/concepts/01-fundamental/07-discrimination/50-literal.ts +87 -0
- package/docs/concepts/01-fundamental/07-discrimination/60-shape.ts +152 -0
- package/docs/concepts/01-fundamental/07-discrimination/70-predicate.ts +89 -0
- package/docs/concepts/01-fundamental/07-discrimination/index.md +3 -0
- package/docs/concepts/01-fundamental/index.md +1 -0
- package/docs/concepts/02-server/10-file/10-manipulation.ts +40 -0
- package/docs/concepts/02-server/10-file/20-path.ts +56 -0
- package/docs/concepts/02-server/10-file/index.md +3 -0
- package/docs/concepts/02-server/20-http/10-init.ts +31 -0
- package/docs/concepts/02-server/20-http/20-route.ts +174 -0
- package/docs/concepts/02-server/20-http/30-routine.ts +195 -0
- package/docs/concepts/02-server/20-http/40-jwt.ts +137 -0
- package/docs/concepts/02-server/20-http/50-codegen.ts +29 -0
- package/docs/concepts/02-server/20-http/index.md +3 -0
- package/docs/concepts/02-server/30-environment/10-platform.ts +38 -0
- package/docs/concepts/02-server/30-environment/20-variable.ts +41 -0
- package/docs/concepts/02-server/30-environment/index.md +3 -0
- package/docs/concepts/02-server/40-command/10-use.ts +112 -0
- package/docs/concepts/02-server/40-command/20-sub-command.ts +48 -0
- package/docs/concepts/02-server/40-command/index.md +3 -0
- package/docs/concepts/02-server/index.md +1 -0
- package/docs/concepts/03-client/10-http/10-init.ts +64 -0
- package/docs/concepts/03-client/10-http/20-request.ts +244 -0
- package/docs/concepts/03-client/10-http/30-hook.ts +139 -0
- package/docs/concepts/03-client/10-http/index.md +3 -0
- package/docs/concepts/03-client/20-form/10-init.ts +95 -0
- package/docs/concepts/03-client/20-form/20-input.ts +96 -0
- package/docs/concepts/03-client/20-form/30-layout.ts +160 -0
- package/docs/concepts/03-client/20-form/40-template.ts +89 -0
- package/docs/concepts/03-client/20-form/index.md +3 -0
- package/docs/concepts/03-client/index.md +1 -0
- package/docs/concepts/04-tests/01-unit/10-either.ts +136 -0
- package/docs/concepts/04-tests/01-unit/20-server-mocking.ts +53 -0
- package/docs/concepts/04-tests/01-unit/index.md +3 -0
- package/docs/concepts/04-tests/02-e2e/10-init.ts +80 -0
- package/docs/concepts/04-tests/02-e2e/20-architecture.ts +76 -0
- package/docs/concepts/04-tests/02-e2e/30-testing.ts +90 -0
- package/docs/concepts/04-tests/02-e2e/index.md +3 -0
- package/docs/concepts/04-tests/index.md +1 -0
- package/docs/concepts/05-type-driven-design/01-architecture/10-boundaries.md +41 -0
- package/docs/concepts/05-type-driven-design/01-architecture/index.md +3 -0
- package/docs/concepts/05-type-driven-design/02-domains/10-entities.md +58 -0
- package/docs/concepts/05-type-driven-design/02-domains/20-aggregates.md +49 -0
- package/docs/concepts/05-type-driven-design/02-domains/30-repositories.md +41 -0
- package/docs/concepts/05-type-driven-design/02-domains/index.md +3 -0
- package/docs/concepts/05-type-driven-design/03-applications/10-use-case.md +69 -0
- package/docs/concepts/05-type-driven-design/03-applications/index.md +3 -0
- package/docs/concepts/05-type-driven-design/04-infrastructure/10-implementation.md +56 -0
- package/docs/concepts/05-type-driven-design/04-infrastructure/index.md +3 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/index.ts +2 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/ports/book.ts +10 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/ports/client.ts +10 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/ports/email.ts +7 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/ports/index.ts +3 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/useCases/clientGiveBackBook.ts +27 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/useCases/clientRentBook.ts +30 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/useCases/createBook.ts +32 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/applications/useCases/index.ts +2 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/aggregates/clientGiveBackBook.ts +15 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/aggregates/clientRentBook.ts +16 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/aggregates/createBook.ts +21 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/aggregates/index.ts +3 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/facts/create.ts +34 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/facts/index.ts +3 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/facts/rental.ts +31 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/facts/returnBook.ts +30 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/book/index.ts +87 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/client/facts/giveBackBook.ts +33 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/client/facts/index.ts +2 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/client/facts/rentBook.ts +32 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/client/index.ts +82 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/entities/index.ts +2 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/index.ts +3 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/repositories/book.ts +16 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/repositories/client.ts +7 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/repositories/email.ts +12 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/domains/repositories/index.ts +3 -0
- package/docs/concepts/05-type-driven-design/fixtures/business/index.ts +2 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/command/clientRentBook.ts +62 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/command/index.ts +11 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/checkers/bookExist.ts +19 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/checkers/clientExist.ts +19 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/checkers/index.ts +2 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/main.ts +19 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/routes/clientGiveBackBook.ts +37 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/routes/clientRentBook.ts +50 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/http/routes/index.ts +2 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/ports/book.ts +25 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/ports/client.ts +7 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/ports/email.ts +10 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/ports/index.ts +3 -0
- package/docs/concepts/05-type-driven-design/fixtures/infrastructure/useCases/index.ts +12 -0
- package/docs/concepts/05-type-driven-design/index.md +3 -0
- package/docs/concepts.llms.md +475 -0
- package/instructions/coding-conventions.md +8 -0
- package/package.json +96 -3
- package/skills/command/SKILL.md +63 -0
- package/skills/command/references/examples/cli.ts +22 -0
- package/skills/command/references/examples/options-only.ts +27 -0
- package/skills/command/references/examples/preview-command.ts +57 -0
- package/skills/command/references/execution.md +31 -0
- package/skills/command/references/inputs.md +27 -0
- package/skills/fundamental/SKILL.md +80 -0
- package/skills/fundamental/references/composition.md +35 -0
- package/skills/fundamental/references/constraints-and-validation.md +61 -0
- package/skills/fundamental/references/examples/async-composition.ts +15 -0
- package/skills/fundamental/references/examples/cast.ts +18 -0
- package/skills/fundamental/references/examples/composition.ts +40 -0
- package/skills/fundamental/references/examples/environment-initialization.ts +19 -0
- package/skills/fundamental/references/examples/error-propagation.ts +24 -0
- package/skills/fundamental/references/examples/generic-inference.ts +31 -0
- package/skills/fundamental/references/examples/guaranteed-array-access.ts +31 -0
- package/skills/fundamental/references/examples/independent-inputs.ts +18 -0
- package/skills/fundamental/references/examples/infer.ts +21 -0
- package/skills/fundamental/references/examples/input-validation.ts +37 -0
- package/skills/fundamental/references/examples/safe-declarations.ts +25 -0
- package/skills/fundamental/references/results-and-errors.md +59 -0
- package/skills/http-client/SKILL.md +50 -0
- package/skills/http-client/references/configuration.md +9 -0
- package/skills/http-client/references/examples/client-expectations.ts +84 -0
- package/skills/http-client/references/examples/client-streams.ts +74 -0
- package/skills/http-client/references/examples/external-client.ts +78 -0
- package/skills/http-client/references/hooks.md +7 -0
- package/skills/http-client/references/responses.md +39 -0
- package/skills/http-client/references/streams.md +10 -0
- package/skills/http-server/SKILL.md +66 -0
- package/skills/http-server/references/code-generation.md +31 -0
- package/skills/http-server/references/examples/authentication.ts +42 -0
- package/skills/http-server/references/examples/contracts.ts +19 -0
- package/skills/http-server/references/examples/generate-sdk.ts +36 -0
- package/skills/http-server/references/examples/initialize.ts +29 -0
- package/skills/http-server/references/examples/minimal-route.ts +18 -0
- package/skills/http-server/references/examples/protected-route.ts +31 -0
- package/skills/http-server/references/examples/rename-user-route.ts +54 -0
- package/skills/http-server/references/examples/user-checker.ts +26 -0
- package/skills/http-server/references/examples/user-route.ts +38 -0
- package/skills/http-server/references/initialization.md +33 -0
- package/skills/http-server/references/reusable-flows.md +40 -0
- package/skills/http-server/references/routes-and-floor.md +38 -0
- package/skills/modeling/SKILL.md +76 -0
- package/skills/modeling/references/domain.md +33 -0
- package/skills/modeling/references/orchestration.md +36 -0
- package/skills/server/SKILL.md +55 -0
- package/skills/server/references/environment.md +30 -0
- package/skills/server/references/examples/environment.ts +41 -0
- package/skills/server/references/examples/file-structure.ts +26 -0
- package/skills/server/references/examples/files.ts +52 -0
- package/skills/server/references/files.md +38 -0
- package/skills/server/references/structures.md +15 -0
- package/skills/test/SKILL.md +70 -0
- package/skills/test/references/examples/results.ts +95 -0
- package/skills/test/references/examples/server.ts +59 -0
- package/skills/test/references/results.md +21 -0
- package/skills/test/references/server.md +17 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @title Décoder un chemin en fichier existant de taille bornée.
|
|
3
|
+
*
|
|
4
|
+
* Le codec construit l'interface ; les contraintes consultent le disque.
|
|
5
|
+
*/
|
|
6
|
+
import * as DSDataStructure from "@duplojs/server/dataStructure";
|
|
7
|
+
import type * as DSFile from "@duplojs/server/file";
|
|
8
|
+
import type * as DDataStructure from "@duplojs/lang/dataStructure";
|
|
9
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
10
|
+
|
|
11
|
+
const inputFile = DSDataStructure.file([
|
|
12
|
+
DSDataStructure.fileExist(),
|
|
13
|
+
DSDataStructure.size({ max: "1mb" }),
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
type _CheckValue = DCommon.ExpectType<
|
|
17
|
+
DDataStructure.StructureValue<typeof inputFile>,
|
|
18
|
+
DSFile.FileInterface,
|
|
19
|
+
"strict"
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export function decodeInputFile(value: unknown) {
|
|
23
|
+
// Retourne decode-success avec l'interface, ou decode-error.
|
|
24
|
+
// Une simple string n'est pas la valeur déjà décodée du contrat.
|
|
25
|
+
return inputFile.asyncDecode(DSDataStructure.codecsString, value);
|
|
26
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @title Conserver les erreurs des opérations de fichiers.
|
|
3
|
+
*
|
|
4
|
+
* Tolérer uniquement l'absence attendue et séquencer une écriture dépendante.
|
|
5
|
+
*/
|
|
6
|
+
import * as DSFile from "@duplojs/server/file";
|
|
7
|
+
import * as DPath from "@duplojs/lang/path";
|
|
8
|
+
import * as DEither from "@duplojs/lang/either";
|
|
9
|
+
import * as DPattern from "@duplojs/lang/pattern";
|
|
10
|
+
import type * as DCommon from "@duplojs/lang/common";
|
|
11
|
+
|
|
12
|
+
export async function readTextOrEmpty(path: string & DPath.Path) {
|
|
13
|
+
const result = await DSFile.readTextFile(path);
|
|
14
|
+
|
|
15
|
+
if (DEither.isRight(result)) {
|
|
16
|
+
const text = DEither.unwrapRight(result);
|
|
17
|
+
|
|
18
|
+
type _CheckText = DCommon.ExpectType<typeof text, string, "strict">;
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const error = DEither.unwrapLeft(result);
|
|
23
|
+
|
|
24
|
+
type _CheckError = DCommon.ExpectType<typeof error, DSFile.ReadTextFileErrors, "strict">;
|
|
25
|
+
|
|
26
|
+
return DPattern.matchWithErrorOtherwise(
|
|
27
|
+
error,
|
|
28
|
+
{
|
|
29
|
+
// L'absence est le seul cas pour lequel ce scénario choisit un défaut.
|
|
30
|
+
"file-system-read-text-file-not-found": () => DEither.right("file-system-read-text-file", ""),
|
|
31
|
+
},
|
|
32
|
+
() => result,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function writeReport(directory: string & DPath.Path, text: string) {
|
|
37
|
+
const target = DPath.resolveRelative([directory, DPath.declarePath("report.txt")]);
|
|
38
|
+
const result = await DEither.rightAsyncPipe(
|
|
39
|
+
DSFile.ensureDirectory(directory),
|
|
40
|
+
// Cette écriture ne s'exécute pas si la préparation du dossier échoue.
|
|
41
|
+
() => DSFile.writeTextFile(target, text),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
type _CheckResult = DCommon.ExpectType<
|
|
45
|
+
typeof result,
|
|
46
|
+
| DSFile.WriteTextFileResult
|
|
47
|
+
| Extract<DSFile.EnsureDirectoryResult, DEither.Left>,
|
|
48
|
+
"strict"
|
|
49
|
+
>;
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Fichiers, chemins et erreurs
|
|
2
|
+
|
|
3
|
+
## Choisir l'opération
|
|
4
|
+
|
|
5
|
+
Choisir l'opération selon le résultat nécessaire et vérifier sa signature publique. Pour une capacité absente de cette sélection, rechercher le mécanisme dans `docs/concepts.llms.md` :
|
|
6
|
+
|
|
7
|
+
| Besoin | API à considérer |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| Lire ou écrire du texte, du binaire ou du JSON | `readTextFile` / `writeTextFile`, `readFile` / `writeFile`, `readJsonFile` / `writeJsonFile` |
|
|
10
|
+
| Ajouter du contenu sans remplacer le précédent | `appendTextFile`, `appendFile` |
|
|
11
|
+
| Créer un dossier et ses parents si nécessaire | `ensureDirectory` |
|
|
12
|
+
| Créer un fichier absent sans tronquer un fichier existant | `ensureFile` ; préparer le dossier parent séparément |
|
|
13
|
+
| Créer une ressource temporaire | `makeTemporaryFile`, `makeTemporaryDirectory` |
|
|
14
|
+
| Lister des chemins ou obtenir des interfaces d'entrées | `readDirectory`, `walkDirectory` |
|
|
15
|
+
| Obtenir les métadonnées de la ressource ou du lien lui-même | `stat`, `linkStat` |
|
|
16
|
+
| Copier, déplacer, renommer ou supprimer | `copy`, `move`, `rename`, `relocate`, `remove` selon leur contrat et leurs options |
|
|
17
|
+
|
|
18
|
+
`readDirectory` renvoie des chemins relatifs au dossier lu par défaut ; demander `absolute: true` pour des chemins absolus, et `recursive: true` pour descendre dans les sous-dossiers. `walkDirectory` renvoie un générateur d'interfaces de fichiers, dossiers ou entrées inconnues ; choisir explicitement la récursivité et discriminer les interfaces avant d'employer leurs opérations spécifiques.
|
|
19
|
+
|
|
20
|
+
`exists` retourne un `Either`, pas un booléen. Pour distinguer un fichier d'un dossier et conserver les diagnostics d'échec, utiliser `stat` ou `createEntryInterface`. Les raccourcis `isFile()` / `isFolder()` des interfaces renvoient `false` lorsqu'ils ne peuvent pas confirmer la nature de la ressource ; ils ne permettent pas de récupérer tous les diagnostics.
|
|
21
|
+
|
|
22
|
+
## Séparer chemin, référence et état du disque
|
|
23
|
+
|
|
24
|
+
Une string dynamique doit être validée par `DPath.create`, `createAbsolute` ou `createSegment` selon son usage. Utiliser les fonctions de résolution de `DPath` pour assembler les chemins. La validité du chemin reste une garantie sur sa représentation ; elle ne prouve pas l'accès au système de fichiers.
|
|
25
|
+
|
|
26
|
+
`createFileInterface` et `createFolderInterface` construisent une référence sans créer ni inspecter la ressource. `createEntryInterface` effectue une inspection pour choisir l'interface appropriée. Les méthodes des interfaces délèguent aux opérations du domaine ; lire ou écrire le contenu passe par les fonctions qui prennent leur `.path`. Les opérations de déplacement ou de renommage renvoient la nouvelle interface dans leur résultat de réussite : utiliser ce résultat pour les opérations suivantes.
|
|
27
|
+
|
|
28
|
+
Une vérification préalable d'existence ne garantit pas la réussite de la lecture ou de l'écriture suivante. Traiter le résultat de l'opération effective, même après validation d'une précondition.
|
|
29
|
+
|
|
30
|
+
## Préserver les diagnostics et arrêter sur échec
|
|
31
|
+
|
|
32
|
+
Pour une opération telle que `readTextFile`, le résultat porte `file-system-read-text-file` en réussite ou `file-system-read-text-file-error` en échec. La valeur du `Left` est une union de `DuploJSError` portant les identifiants précis, tels que `file-system-read-text-file-not-found` et `file-system-read-text-file-permission-denied`. Ces identifiants précis ne sont pas les informations du `Left` extérieur.
|
|
33
|
+
|
|
34
|
+
Après sélection du `Left` avec `DEither`, utiliser `DPattern.matchWithError` pour couvrir toutes les erreurs déclarées, ou `matchWithErrorOtherwise` pour traiter un cas et conserver les autres. Ne pas dépendre du message d'erreur ni des codes natifs du runtime. Voir [lecture avec absence explicitement tolérée et écriture séquencée](examples/files.ts).
|
|
35
|
+
|
|
36
|
+
Pour plusieurs opérations dépendantes, composer avec `DEither.rightAsyncPipe` : la première erreur est conservée et les étapes suivantes ne s'exécutent pas. Chaque étape reçoit la valeur déballée du `Right` précédent. Consulter les concepts `Either` pour les règles de composition et d'adaptation des résultats.
|
|
37
|
+
|
|
38
|
+
`readJsonFile` parse le JSON et en retourne une valeur `DCommon.Json` ; il ne prouve pas le contrat de l'application. Faire ensuite vérifier cette valeur par une data structure, en conservant la différence entre échec de lecture et contenu invalide.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Structures et contraintes de ressources
|
|
2
|
+
|
|
3
|
+
`DSDataStructure.file()` et `folder()` étendent les data structures de `@duplojs/lang/dataStructure` avec des valeurs `DSFile.FileInterface` et `FolderInterface`. Employer les structures fondamentales de `lang` pour les objets et les valeurs ordinaires, puis les structures serveur pour les ressources du système de fichiers.
|
|
4
|
+
|
|
5
|
+
Choisir la validation d'après la représentation reçue :
|
|
6
|
+
|
|
7
|
+
- Une interface déjà construite se vérifie avec `asyncCheck` lorsque des contraintes asynchrones sont présentes. Un objet ordinaire portant seulement une propriété `path` n'est pas une interface de fichier DuploJS.
|
|
8
|
+
- Un chemin textuel se décode avec `asyncDecode(DSDataStructure.codecsString, valeur)`. Le codec normalise le chemin et construit une interface ; sans contrainte supplémentaire, il ne consulte pas la ressource sur le disque.
|
|
9
|
+
- Pour le transport sous forme JSON, les codecs serveur `codecsJson` représentent aussi les interfaces par leur chemin.
|
|
10
|
+
|
|
11
|
+
Ajouter `fileExist()` pour exiger un fichier existant ou `folderExist()` pour exiger un dossier existant. Ces contraintes inspectent les métadonnées et distinguent fichier et dossier. `size({ min, max })` vérifie la taille d'un fichier en octets ; les bornes acceptent des nombres ou les unités textuelles reconnues par l'écosystème. Ces contraintes nécessitent l'exécution asynchrone de la structure. Voir [décodage d'un chemin avec contraintes de fichier](examples/file-structure.ts).
|
|
12
|
+
|
|
13
|
+
La validation d'une ressource porte sur son état au moment de la vérification. Elle ne réserve pas le fichier et ne dispense pas de traiter le résultat des I/O suivantes. Une structure de fichier ne valide pas non plus ses données internes : lire le texte ou le JSON avec `DSFile`, puis appliquer la structure du contenu attendu.
|
|
14
|
+
|
|
15
|
+
Le type MIME fourni par une `FileInterface` est déduit de l'extension ; il ne constitue pas une inspection du contenu. Ne pas en déduire une preuve sur les octets du fichier.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: duplojs-test
|
|
3
|
+
description: "Écrire ou corriger des tests DuploJS : vérifier les résultats Either et le typage, isoler les capacités serveur ou organiser un parcours E2E avec @duplojs/playwright."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tester avec DuploJS
|
|
7
|
+
|
|
8
|
+
## Trouver les concepts
|
|
9
|
+
|
|
10
|
+
Appliquer la démarche du skill et lire les ressources indiquées lorsque leur condition est rencontrée. Pour rechercher un concept ou un mécanisme non couvert, consulter `docs/concepts.llms.md` du package `@duplojs/agents-kit`.
|
|
11
|
+
|
|
12
|
+
Le setup indique ce chemin dans `AGENTS.md` ou `CLAUDE.md`, relativement à leur dossier. Les chemins `docs/` partent du package installé, même avec `--copy`. Les références du skill partent de son dossier ; les liens d'un document se résolvent depuis ce document.
|
|
13
|
+
|
|
14
|
+
Si le chemin du routeur manque, le retrouver depuis le projet consommateur :
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
node --input-type=module -e 'import { fileURLToPath } from "node:url"; console.log(fileURLToPath(import.meta.resolve("@duplojs/agents-kit/docs/concepts.llms.md")))'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Partir du contrat testé
|
|
21
|
+
|
|
22
|
+
Lire la signature et les résultats possibles de la fonction avant d'écrire ses assertions. Préparer les données avec les outils DuploJS et conserver le type de retour complet jusqu'à la sélection du résultat attendu. Utiliser les imports publics des domaines avec leur namespace long.
|
|
23
|
+
|
|
24
|
+
Les outils du runner gardent leur rôle pour les assertions et les spies ; les exemples utilisent Vitest. Ce skill apporte les pratiques propres à DuploJS, à adapter au runner et à l'organisation du projet consommateur.
|
|
25
|
+
|
|
26
|
+
| Garantie à vérifier | Démarche et ressource à lire |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| Une branche de résultat et sa valeur à l'exécution | Sélectionner le résultat puis écrire l'assertion : [Résultats, sélecteurs et typage](references/results.md) et l'[exemple autonome](references/examples/results.ts). |
|
|
29
|
+
| L'inférence, le narrowing ou l'évolution d'un contrat | Ajouter les vérifications de type adaptées et exécuter le contrôle TypeScript des tests. Pour les formes curifiées et les assertions de type, lire `docs/concepts/04-tests/01-unit/10-either.ts`. |
|
|
30
|
+
| Un traitement utilisant une capacité serveur à isoler | Injecter l'implémentation de test : [Remplacer les fonctions serveur](references/server.md) et l'[exemple de lecture](references/examples/server.ts). |
|
|
31
|
+
| Un parcours dans le navigateur | Suivre la démarche E2E ci-dessous ; ses objets de pages et composants portent les interactions du scénario. |
|
|
32
|
+
|
|
33
|
+
## Sélectionner le résultat attendu et vérifier sa valeur
|
|
34
|
+
|
|
35
|
+
Un résultat `Either` porte une information et une valeur. Dans un test, `DEither.unwrapByInformationOrThrow` permet de sélectionner l'information attendue, de faire échouer immédiatement le test si une autre information est obtenue, puis de récupérer la valeur avec son type précis. Utiliser ce mécanisme aussi pour un échec attendu : sélectionner son information, puis vérifier l'erreur ou la donnée qu'il contient.
|
|
36
|
+
|
|
37
|
+
Choisir l'outil selon l'intention :
|
|
38
|
+
|
|
39
|
+
| Intention du test | Outil |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| Attendre une information précise | `DEither.unwrapByInformationOrThrow` |
|
|
42
|
+
| Accepter ou rejeter explicitement chaque information possible | `DEither.unwrapSelectionOrThrow` |
|
|
43
|
+
| Vérifier seulement le côté du résultat, sans information précise | `DEither.unwrapRightOrThrow` ou `DEither.unwrapLeftOrThrow` |
|
|
44
|
+
| Vérifier dans le typage qu'une valeur est déjà un `Either`, sans l'extraire | `DEither.expect` |
|
|
45
|
+
|
|
46
|
+
Les variantes qui lèvent sont utiles dans les tests : une branche inattendue doit les interrompre. Après l'extraction, écrire une assertion sur le contenu ; la sélection ne prouve pas que la valeur est correcte. Éviter un simple unwrap qui perdrait l'information attendue ou une assertion placée uniquement dans un `if` qui pourrait ne jamais s'exécuter. Cette pratique de test ne justifie pas de remplacer les résultats sûrs du code applicatif par des exceptions.
|
|
47
|
+
|
|
48
|
+
## Surveiller l'évolution des résultats
|
|
49
|
+
|
|
50
|
+
Utiliser `DEither.unwrapSelectionOrThrow` lorsqu'un test doit imposer une décision à chaque ajout d'information au contrat. Lui transmettre le résultat complet et décider explicitement des cas acceptés ou rejetés. Une sélection par information précise suffit lorsque le scénario n'a pas cette responsabilité de surveillance.
|
|
51
|
+
|
|
52
|
+
Pour un point de surveillance exhaustif, lire la section correspondante de la référence sur les résultats avant de construire le sélecteur : le contrôle doit recevoir l'union complète. Exécuter le contrôle TypeScript des tests ; le runner seul ne garantit pas cette surveillance.
|
|
53
|
+
|
|
54
|
+
## Isoler les dépendances serveur
|
|
55
|
+
|
|
56
|
+
Pour les capacités de `@duplojs/server` exposées via son mécanisme d'implémentation, préférer `setEnvironment("TEST")` et `TESTImplementation.set` aux mocks de modules ou aux spies sur leurs exports. Enregistrer chaque fonction effectivement appelée, y compris indirectement : une implémentation absente lève une erreur, sans repli vers le runtime natif.
|
|
57
|
+
|
|
58
|
+
Nettoyer le registre et rétablir l'environnement après chaque test, même en échec ; éviter les tests concurrents qui modifient ce même état. La référence serveur détaille ce cycle et les retours typés à injecter. Les autres dépendances peuvent utiliser les mocks habituels du runner.
|
|
59
|
+
|
|
60
|
+
## Vérifier les garanties de typage
|
|
61
|
+
|
|
62
|
+
Quand l'inférence ou le narrowing fait partie du contrat testé, ajouter `DCommon.ExpectType` avec `"strict"` à côté des assertions runtime. Vérifier une API curifiée dans `DCommon.pipe` ou `DCommon.asyncPipe` ; pour un predicate, vérifier le narrowing dans un `if`, ou dans `DCommon.when` pour la forme curifiée. Réserver `@ts-expect-error` aux usages que le contrat doit refuser, avec une explication.
|
|
63
|
+
|
|
64
|
+
Une vérification de type et une assertion runtime contrôlent des garanties différentes. Préparer les arguments indépendants avant le pipe, récupérer son résultat dans une variable puis écrire l'assertion séparément. Exécuter le contrôle TypeScript lorsque des garanties de type sont vérifiées, puis les tests runtime concernés.
|
|
65
|
+
|
|
66
|
+
## Organiser un parcours E2E
|
|
67
|
+
|
|
68
|
+
Avec `@duplojs/playwright`, construire le contexte avec `Website`, les écrans avec `createPage` et leurs zones réutilisables avec `createComponent`. Garder les locators dans ces objets, puis exprimer les scénarios par leurs éléments, méthodes nommées et helpers `Actions` / `Assertions`.
|
|
69
|
+
|
|
70
|
+
Les concepts sous `docs/concepts/04-tests/02-e2e/` se lisent selon l'intervention : `10-init.ts` pour initialiser le client, `20-architecture.ts` pour créer ou modifier pages et composants, `30-testing.ts` pour écrire le parcours et ses assertions. Reprendre les objets existants lorsque le scénario les utilise déjà.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
|
+
import * as DEither from "@duplojs/lang/either";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
interface User {
|
|
6
|
+
id: number;
|
|
7
|
+
email: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Les résultats possibles sont inférés à partir des branches de la fonction.
|
|
11
|
+
function findUserByEmail(email: string) {
|
|
12
|
+
if (email === "") {
|
|
13
|
+
return DEither.error(new Error("Email is required"));
|
|
14
|
+
}
|
|
15
|
+
const user = {
|
|
16
|
+
id: 1,
|
|
17
|
+
email: "jane@duplo.dev",
|
|
18
|
+
};
|
|
19
|
+
if (email === user.email) {
|
|
20
|
+
return DEither.result("user.found", user);
|
|
21
|
+
}
|
|
22
|
+
return DEither.left("user.notfound", email);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe("findUserByEmail", () => {
|
|
26
|
+
it("selects the expected information and checks its value", () => {
|
|
27
|
+
const result = findUserByEmail("jane@duplo.dev");
|
|
28
|
+
const user = DEither.unwrapByInformationOrThrow(result, "user.found");
|
|
29
|
+
|
|
30
|
+
expect(user).toStrictEqual({
|
|
31
|
+
id: 1,
|
|
32
|
+
email: "jane@duplo.dev",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
type _CheckUser = DCommon.ExpectType<typeof user, User, "strict">;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("extracts an expected business failure", () => {
|
|
39
|
+
const result = findUserByEmail("missing@duplo.dev");
|
|
40
|
+
const email = DEither.unwrapByInformationOrThrow(result, "user.notfound");
|
|
41
|
+
|
|
42
|
+
expect(email).toBe("missing@duplo.dev");
|
|
43
|
+
|
|
44
|
+
type _CheckEmail = DCommon.ExpectType<typeof email, string, "strict">;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("checks an expected error payload", () => {
|
|
48
|
+
const result = findUserByEmail("");
|
|
49
|
+
const error = DEither.unwrapByInformationOrThrow(result, "error");
|
|
50
|
+
|
|
51
|
+
expect(error).toBeInstanceOf(Error);
|
|
52
|
+
expect(error.message).toBe("Email is required");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("monitors all possible information before extracting the user", () => {
|
|
56
|
+
const result = findUserByEmail("jane@duplo.dev");
|
|
57
|
+
// Une nouvelle information dans les résultats inférés de la fonction
|
|
58
|
+
// impose de revoir les cas acceptés ou rejetés à cet endroit.
|
|
59
|
+
const user = DEither.unwrapSelectionOrThrow(result, {
|
|
60
|
+
"user.found": true,
|
|
61
|
+
"user.notfound": false,
|
|
62
|
+
error: false,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
expect(user).toStrictEqual({
|
|
66
|
+
id: 1,
|
|
67
|
+
email: "jane@duplo.dev",
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
type _CheckUser = DCommon.ExpectType<typeof user, User, "strict">;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("fails when an excluded information is returned", () => {
|
|
74
|
+
const result = findUserByEmail("missing@duplo.dev");
|
|
75
|
+
|
|
76
|
+
expect(
|
|
77
|
+
() => DEither.unwrapSelectionOrThrow(result, {
|
|
78
|
+
"user.found": true,
|
|
79
|
+
"user.notfound": false,
|
|
80
|
+
error: false,
|
|
81
|
+
}),
|
|
82
|
+
).toThrow(DEither.HasNotSelectedInformationError);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("preserves inference when selecting in a pipe", () => {
|
|
86
|
+
const user = DCommon.pipe(
|
|
87
|
+
findUserByEmail("jane@duplo.dev"),
|
|
88
|
+
DEither.unwrapByInformationOrThrow("user.found"),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
expect(user.email).toBe("jane@duplo.dev");
|
|
92
|
+
|
|
93
|
+
type _CheckUser = DCommon.ExpectType<typeof user, User, "strict">;
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
|
+
import * as DEither from "@duplojs/lang/either";
|
|
3
|
+
import * as DPath from "@duplojs/lang/path";
|
|
4
|
+
import { TESTImplementation, setEnvironment } from "@duplojs/server";
|
|
5
|
+
import * as DSFile from "@duplojs/server/file";
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
|
+
|
|
8
|
+
// Le traitement utilise l'API publique ; les tests remplacent seulement l'I/O.
|
|
9
|
+
function loadGreeting(path: string & DPath.Path) {
|
|
10
|
+
return DEither.rightAsyncPipe(
|
|
11
|
+
DSFile.readTextFile(path),
|
|
12
|
+
(name) => DEither.result("greeting.loaded", `Hello ${name}`),
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const inputPath = DPath.declarePath("fixtures/name.txt");
|
|
17
|
+
|
|
18
|
+
describe("loadGreeting", () => {
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
setEnvironment("TEST");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
TESTImplementation.clear();
|
|
25
|
+
// Cette suite cible Node ; rétablir BUN ou DENO dans une suite adaptée.
|
|
26
|
+
setEnvironment("NODE");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("uses the injected server implementation", async() => {
|
|
30
|
+
const readTextFile = vi.fn(() => Promise.resolve(DEither.right("file-system-read-text-file", "Jane")));
|
|
31
|
+
TESTImplementation.set("readTextFile", readTextFile);
|
|
32
|
+
|
|
33
|
+
const result = await loadGreeting(inputPath);
|
|
34
|
+
const greeting = DEither.unwrapByInformationOrThrow(result, "greeting.loaded");
|
|
35
|
+
|
|
36
|
+
expect(greeting).toBe("Hello Jane");
|
|
37
|
+
expect(readTextFile).toHaveBeenCalledExactlyOnceWith(inputPath);
|
|
38
|
+
|
|
39
|
+
type _CheckGreeting = DCommon.ExpectType<typeof greeting, `Hello ${string}`, "strict">;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("preserves the I/O failure", async() => {
|
|
43
|
+
// Reconstituer une erreur publique par son identifiant, sans cast ni
|
|
44
|
+
// import de classe privée. Sa compatibilité est vérifiée à l'injection.
|
|
45
|
+
class PermissionDenied extends DCommon.DuploJSError.parentClass("file-system-read-text-file-permission-denied", Error) {}
|
|
46
|
+
const cause = new Error("Read denied");
|
|
47
|
+
const failure = new PermissionDenied(cause);
|
|
48
|
+
const readTextFile = vi.fn(() => Promise.resolve(DEither.left("file-system-read-text-file-error", failure)));
|
|
49
|
+
TESTImplementation.set("readTextFile", readTextFile);
|
|
50
|
+
|
|
51
|
+
const result = await loadGreeting(inputPath);
|
|
52
|
+
const error = DEither.unwrapByInformationOrThrow(result, "file-system-read-text-file-error");
|
|
53
|
+
|
|
54
|
+
expect(error).toBe(failure);
|
|
55
|
+
expect(DCommon.DuploJSError.hasIdentifier(error, "file-system-read-text-file-permission-denied")).toBe(true);
|
|
56
|
+
expect(error.cause).toBe(cause);
|
|
57
|
+
expect(readTextFile).toHaveBeenCalledExactlyOnceWith(inputPath);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Résultats, sélecteurs et typage
|
|
2
|
+
|
|
3
|
+
Consulter [l'exemple exécutable de résultats](examples/results.ts) pour sélectionner une réussite, un échec attendu et vérifier l'extraction typée. La fonction de recherche y sert uniquement de petit contrat autonome à adapter à la fonction réellement testée.
|
|
4
|
+
|
|
5
|
+
## Une information attendue
|
|
6
|
+
|
|
7
|
+
`unwrapByInformationOrThrow` vérifie que l'information du résultat fait partie de la sélection demandée et extrait sa valeur. Sélectionner l'information précise plutôt que le seul côté `Right` ou `Left` lorsque plusieurs issues partagent ce côté. Pour un résultat asynchrone, attendre le résultat avant de l'extraire, ou utiliser la forme curifiée dans `DCommon.asyncPipe`.
|
|
8
|
+
|
|
9
|
+
Après l'extraction, vérifier la valeur avec le runner : propriétés d'un objet, contenu d'une collection, erreur ou cause attendue. Pour une erreur DuploJS, son identifiant peut être vérifié avec `DCommon.DuploJSError.hasIdentifier` ; l'information du `Left` et l'identifiant de l'erreur qu'il contient sont deux contrats distincts.
|
|
10
|
+
|
|
11
|
+
`DEither.expect` conserve exactement un type déjà contraint à un `Either` ; il ne valide pas une donnée inconnue au runtime.
|
|
12
|
+
|
|
13
|
+
## Un point de surveillance exhaustif
|
|
14
|
+
|
|
15
|
+
Le sélecteur de `unwrapSelectionOrThrow` doit contenir toutes les informations de l'union reçue, avec des booléens littéraux : `true` extrait la valeur et `false` fait échouer le test si cette information apparaît. Les clés étrangères à l'union sont refusées. Accepter plusieurs informations n'a de sens que si le même scénario tolère réellement leurs résultats ; la valeur extraite prend alors l'union des valeurs acceptées.
|
|
16
|
+
|
|
17
|
+
L'ajout d'une information au type de retour rend le sélecteur incomplet et provoque une erreur de typage. Il ne se met pas à jour automatiquement : décider si le scénario accepte ou rejette la nouvelle information, généralement avec une seule entrée à `true`. L'exemple vérifie cette surveillance à partir des résultats inférés de la fonction.
|
|
18
|
+
|
|
19
|
+
Ne pas réécrire manuellement une union réduite aux résultats déjà connus et ne pas filtrer le résultat avant de l'envoyer au sélecteur : le contrôle porte sur le type reçu à cet endroit. Les sélecteurs surveillent les informations ; une évolution de valeur ou de sous-type d'erreur nécessite les vérifications adaptées sur le contenu et son type.
|
|
20
|
+
|
|
21
|
+
La compilation vérifie la complétude du sélecteur et `DCommon.ExpectType` vérifie les types obtenus. Le runner vérifie les valeurs et l'échec sur les informations exclues. Lancer ces deux validations dans le projet consommateur.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Remplacer les fonctions serveur
|
|
2
|
+
|
|
3
|
+
Lire [l'exemple de fonction utilisant une lecture serveur](examples/server.ts) pour tester un traitement applicatif sans accès réel au système de fichiers. Rechercher aussi « Remplacer les implémentations serveur » dans le routeur conceptuel pour un exemple de commande avec des arguments de processus contrôlés.
|
|
4
|
+
|
|
5
|
+
## Injecter la capacité utilisée
|
|
6
|
+
|
|
7
|
+
`setEnvironment` et `TESTImplementation` sont des exports directs de `@duplojs/server`, sans sous-export dédié. Importer les domaines tels que `DSFile` depuis leurs sous-exports habituels.
|
|
8
|
+
|
|
9
|
+
Activer l'environnement `TEST`, puis enregistrer les implémentations avec `TESTImplementation.set`. Les noms et signatures autorisés sont typés à partir des fonctions serveur disponibles. Fournir leurs résultats `Either` attendus, y compris dans les scénarios d'échec. Enregistrer aussi les capacités appelées indirectement par le traitement ; seules les fonctions qui passent par le mécanisme d'implémentation serveur sont remplaçables ainsi.
|
|
10
|
+
|
|
11
|
+
Utiliser un spy du runner comme implémentation injectée pour vérifier les arguments et le nombre d'appels. Le traitement testé continue d'appeler l'API serveur publique. Pour tester la propagation d'un échec, injecter cet échec, sélectionner son information dans le résultat applicatif et vérifier la valeur ou la cause propagée.
|
|
12
|
+
|
|
13
|
+
## Rétablir l'état partagé
|
|
14
|
+
|
|
15
|
+
Le registre et l'environnement sont partagés. Dans `afterEach`, appeler `TESTImplementation.clear()` et rétablir l'environnement attendu par la suite même après une assertion en échec. L'exemple rétablit `NODE` parce qu'il vise une suite Vitest exécutée sous Node ; adapter ce choix pour Bun ou Deno. Ne pas exécuter concurremment des tests qui modifient ce même état.
|
|
16
|
+
|
|
17
|
+
Une implémentation absente en environnement `TEST` provoque une exception. Corriger l'enregistrement manquant si cet appel fait partie du scénario. Un test d'intégration qui doit vérifier les I/O réelles conserve son environnement natif et utilise des ressources temporaires adaptées.
|