@sparted/shared-library 1.0.28 → 1.1.0-rc0
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/.circleci/config.yml +40 -0
- package/.eslintignore +1 -0
- package/.eslintrc.json +25 -0
- package/.gitignore +37 -0
- package/.idea/.gitignore +8 -0
- package/.idea/codeStyles/Project.xml +35 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/jsLinters/eslint.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/shared-library.iml +11 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +100 -0
- package/.prettierrc.json +6 -0
- package/CHANGELOG.md +97 -0
- package/README.md +26 -0
- package/dist/business/picture-spot/index.d.ts +2 -0
- package/dist/business/picture-spot/index.js +8 -0
- package/dist/business/picture-spot/index.js.map +1 -0
- package/dist/business/types/content.d.ts +84 -0
- package/dist/business/types/index.d.ts +4 -0
- package/dist/business/types/media.d.ts +16 -0
- package/dist/business/types/multilingual.d.ts +3 -0
- package/dist/business/types/thematic.d.ts +9 -0
- package/dist/package.json +65 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/global.d.ts +2 -0
- package/package.json +2 -3
- package/rollup.config.ts +19 -0
- package/src/array/__tests__/array-to-map.test.ts +50 -0
- package/src/array/__tests__/get-values-from-keys.test.ts +14 -0
- package/src/array/__tests__/inner-join.test.ts +55 -0
- package/src/array/__tests__/left-outter-join.test.ts +55 -0
- package/src/array/array-to-map.ts +32 -0
- package/src/array/get-values-from-keys.ts +3 -0
- package/src/array/index.ts +4 -0
- package/src/array/inner-join.ts +10 -0
- package/src/array/left-outter-join.ts +10 -0
- package/src/business/picture-spot/index.ts +3 -0
- package/src/business/types/content.ts +110 -0
- package/src/business/types/index.ts +4 -0
- package/src/business/types/media.ts +18 -0
- package/src/business/types/multilingual.ts +3 -0
- package/src/business/types/thematic.ts +10 -0
- package/src/cdn/__tests__/cdn.factory.test.ts +150 -0
- package/src/cdn/__tests__/utils.test.ts +528 -0
- package/src/cdn/cdn.factory.ts +70 -0
- package/src/cdn/index.ts +2 -0
- package/src/cdn/types/cdn-factory.type.ts +49 -0
- package/src/cdn/types/index.ts +1 -0
- package/src/cdn/utils/extract-info-from-url.util.ts +25 -0
- package/src/cdn/utils/get-cdn-from-s3-url.util.ts +20 -0
- package/src/cdn/utils/get-cdn-url.util.ts +31 -0
- package/src/cdn/utils/twicpics-transformations.util.ts +9 -0
- package/src/formatting/__tests__/format-number.test.ts +11 -0
- package/src/formatting/format-number.ts +14 -0
- package/src/formatting/index.ts +1 -0
- package/src/fp/__tests__/run-while.test.ts +29 -0
- package/src/fp/index.ts +1 -0
- package/src/fp/run-while.ts +54 -0
- package/src/http/__tests__/build-search-params.test.ts +17 -0
- package/src/http/__tests__/encode-search-object.test.ts +34 -0
- package/src/http/__tests__/fetch-with-timeout.test.ts +50 -0
- package/src/http/build-search-params.ts +18 -0
- package/src/http/encode-search-object.ts +39 -0
- package/src/http/fetch-with-timeout.ts +24 -0
- package/src/http/index.ts +3 -0
- package/src/index.ts +14 -0
- package/src/linked-list/__tests__/apply-diff-linked-list.test.ts +103 -0
- package/src/linked-list/__tests__/create-linked-list.test.ts +204 -0
- package/src/linked-list/__tests__/find-linked-list.test.ts +40 -0
- package/src/linked-list/__tests__/get-linked-list.test.ts +28 -0
- package/src/linked-list/__tests__/insert-linked-list.test.ts +186 -0
- package/src/linked-list/__tests__/linked-list-utils.test.ts +252 -0
- package/src/linked-list/__tests__/reduce-linked-list.test.ts +31 -0
- package/src/linked-list/__tests__/remove-linked-list.test.ts +129 -0
- package/src/linked-list/__tests__/update-linked-list.test.ts +53 -0
- package/src/linked-list/__tests__/while-linked-list.test.ts +58 -0
- package/src/linked-list/apply-diff-linked-list.ts +35 -0
- package/src/linked-list/create-linked-list.ts +79 -0
- package/src/linked-list/find-linked-list.ts +26 -0
- package/src/linked-list/get-linked-list.ts +9 -0
- package/src/linked-list/index.ts +2 -0
- package/src/linked-list/insert-linked-list.ts +50 -0
- package/src/linked-list/linked-list-utils.ts +143 -0
- package/src/linked-list/reduce-linked-list.ts +18 -0
- package/src/linked-list/remove-linked-list.ts +36 -0
- package/src/linked-list/type.ts +38 -0
- package/src/linked-list/update-linked-list.ts +30 -0
- package/src/linked-list/while-linked-list.ts +33 -0
- package/src/math/__tests__/clamp-number.test.ts +30 -0
- package/src/math/__tests__/interpolate.test.ts +28 -0
- package/src/math/__tests__/median.test.ts +27 -0
- package/src/math/__tests__/number-range.test.ts +59 -0
- package/src/math/__tests__/random-number.test.ts +11 -0
- package/src/math/clamp-number.ts +8 -0
- package/src/math/index.ts +5 -0
- package/src/math/interpolate.ts +18 -0
- package/src/math/median.ts +21 -0
- package/src/math/number-range.ts +16 -0
- package/src/math/random-number.ts +10 -0
- package/src/object/__tests__/merge-deep.test.ts +56 -0
- package/src/object/__tests__/strip-properties-from-object.test.ts +65 -0
- package/src/object/index.ts +2 -0
- package/src/object/merge-deep.ts +26 -0
- package/src/object/strip-properties-from-object.ts +26 -0
- package/src/parsing/__tests__/parse-boolean.test.ts +15 -0
- package/src/parsing/__tests__/parse-enum.test.ts +19 -0
- package/src/parsing/__tests__/parse-number.test.ts +20 -0
- package/src/parsing/index.ts +3 -0
- package/src/parsing/parse-boolean.ts +10 -0
- package/src/parsing/parse-enum.ts +16 -0
- package/src/parsing/parse-number.ts +12 -0
- package/src/predicates/__tests__/is-function.test.ts +11 -0
- package/src/predicates/__tests__/is-null.test.ts +11 -0
- package/src/predicates/__tests__/is-object.test.ts +11 -0
- package/src/predicates/__tests__/is-primitive.test.ts +42 -0
- package/src/predicates/__tests__/is-undefined.test.ts +11 -0
- package/src/predicates/__tests__/is-uuid.test.ts +13 -0
- package/src/predicates/index.ts +5 -0
- package/src/predicates/is-function.ts +3 -0
- package/src/predicates/is-null.ts +1 -0
- package/src/predicates/is-object.ts +3 -0
- package/src/predicates/is-primitive.ts +19 -0
- package/src/predicates/is-undefined.ts +3 -0
- package/src/predicates/is-uuid.ts +3 -0
- package/src/promise/__tests__/delay.test.ts +13 -0
- package/src/promise/__tests__/execute-or-resolve-default.test.ts +25 -0
- package/src/promise/__tests__/execute-with-delay.test.ts +24 -0
- package/src/promise/delay.ts +3 -0
- package/src/promise/execute-or-resolve-default.ts +14 -0
- package/src/promise/execute-with-delay.ts +6 -0
- package/src/promise/index.ts +3 -0
- package/src/string/__tests__/is-string-length-within-range.test.ts +23 -0
- package/src/string/__tests__/replace-in-template.test.ts +52 -0
- package/src/string/index.ts +2 -0
- package/src/string/is-string-length-within-range.ts +10 -0
- package/src/string/replace-in-template.ts +45 -0
- package/src/time/__tests__/convert.test.ts +14 -0
- package/src/time/__tests__/format-minutes.test.ts +10 -0
- package/src/time/__tests__/get-time-diff-as-string.test.ts +128 -0
- package/src/time/constants.ts +4 -0
- package/src/time/convert.ts +5 -0
- package/src/time/format-minutes.ts +9 -0
- package/src/time/get-time-diff-as-string.ts +196 -0
- package/src/time/index.ts +4 -0
- package/src/types/function.ts +1 -0
- package/src/types/general.ts +15 -0
- package/src/types/index.ts +4 -0
- package/src/types/object.ts +33 -0
- package/src/types/search.ts +29 -0
- package/tsconfig.json +25 -0
- package/yarn.lock +4040 -0
- /package/{_virtual → dist/_virtual}/_tslib.js +0 -0
- /package/{_virtual → dist/_virtual}/_tslib.js.map +0 -0
- /package/{array → dist/array}/array-to-map.d.ts +0 -0
- /package/{array → dist/array}/array-to-map.js +0 -0
- /package/{array → dist/array}/array-to-map.js.map +0 -0
- /package/{array → dist/array}/get-values-from-keys.d.ts +0 -0
- /package/{array → dist/array}/get-values-from-keys.js +0 -0
- /package/{array → dist/array}/get-values-from-keys.js.map +0 -0
- /package/{array → dist/array}/index.d.ts +0 -0
- /package/{array → dist/array}/index.js +0 -0
- /package/{array → dist/array}/index.js.map +0 -0
- /package/{array → dist/array}/inner-join.d.ts +0 -0
- /package/{array → dist/array}/inner-join.js +0 -0
- /package/{array → dist/array}/inner-join.js.map +0 -0
- /package/{array → dist/array}/left-outter-join.d.ts +0 -0
- /package/{array → dist/array}/left-outter-join.js +0 -0
- /package/{array → dist/array}/left-outter-join.js.map +0 -0
- /package/{cdn → dist/business}/types/index.js +0 -0
- /package/{cdn → dist/business}/types/index.js.map +0 -0
- /package/{cdn → dist/cdn}/cdn.factory.d.ts +0 -0
- /package/{cdn → dist/cdn}/cdn.factory.js +0 -0
- /package/{cdn → dist/cdn}/cdn.factory.js.map +0 -0
- /package/{cdn → dist/cdn}/index.d.ts +0 -0
- /package/{cdn → dist/cdn}/index.js +0 -0
- /package/{cdn → dist/cdn}/index.js.map +0 -0
- /package/{cdn → dist/cdn}/types/cdn-factory.type.d.ts +0 -0
- /package/{cdn → dist/cdn}/types/index.d.ts +0 -0
- /package/{types → dist/cdn/types}/index.js +0 -0
- /package/{types → dist/cdn/types}/index.js.map +0 -0
- /package/{cdn → dist/cdn}/utils/extract-info-from-url.util.d.ts +0 -0
- /package/{cdn → dist/cdn}/utils/extract-info-from-url.util.js +0 -0
- /package/{cdn → dist/cdn}/utils/extract-info-from-url.util.js.map +0 -0
- /package/{cdn → dist/cdn}/utils/get-cdn-from-s3-url.util.d.ts +0 -0
- /package/{cdn → dist/cdn}/utils/get-cdn-from-s3-url.util.js +0 -0
- /package/{cdn → dist/cdn}/utils/get-cdn-from-s3-url.util.js.map +0 -0
- /package/{cdn → dist/cdn}/utils/get-cdn-url.util.d.ts +0 -0
- /package/{cdn → dist/cdn}/utils/get-cdn-url.util.js +0 -0
- /package/{cdn → dist/cdn}/utils/get-cdn-url.util.js.map +0 -0
- /package/{cdn → dist/cdn}/utils/twicpics-transformations.util.d.ts +0 -0
- /package/{cdn → dist/cdn}/utils/twicpics-transformations.util.js +0 -0
- /package/{cdn → dist/cdn}/utils/twicpics-transformations.util.js.map +0 -0
- /package/{formatting → dist/formatting}/format-number.d.ts +0 -0
- /package/{formatting → dist/formatting}/format-number.js +0 -0
- /package/{formatting → dist/formatting}/format-number.js.map +0 -0
- /package/{formatting → dist/formatting}/index.d.ts +0 -0
- /package/{formatting → dist/formatting}/index.js +0 -0
- /package/{formatting → dist/formatting}/index.js.map +0 -0
- /package/{fp → dist/fp}/index.d.ts +0 -0
- /package/{fp → dist/fp}/index.js +0 -0
- /package/{fp → dist/fp}/index.js.map +0 -0
- /package/{fp → dist/fp}/run-while.d.ts +0 -0
- /package/{fp → dist/fp}/run-while.js +0 -0
- /package/{fp → dist/fp}/run-while.js.map +0 -0
- /package/{http → dist/http}/build-search-params.d.ts +0 -0
- /package/{http → dist/http}/build-search-params.js +0 -0
- /package/{http → dist/http}/build-search-params.js.map +0 -0
- /package/{http → dist/http}/encode-search-object.d.ts +0 -0
- /package/{http → dist/http}/encode-search-object.js +0 -0
- /package/{http → dist/http}/encode-search-object.js.map +0 -0
- /package/{http → dist/http}/fetch-with-timeout.d.ts +0 -0
- /package/{http → dist/http}/fetch-with-timeout.js +0 -0
- /package/{http → dist/http}/fetch-with-timeout.js.map +0 -0
- /package/{http → dist/http}/index.d.ts +0 -0
- /package/{http → dist/http}/index.js +0 -0
- /package/{http → dist/http}/index.js.map +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{index.js.map → dist/index.js.map} +0 -0
- /package/{linked-list → dist/linked-list}/apply-diff-linked-list.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/apply-diff-linked-list.js +0 -0
- /package/{linked-list → dist/linked-list}/apply-diff-linked-list.js.map +0 -0
- /package/{linked-list → dist/linked-list}/create-linked-list.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/create-linked-list.js +0 -0
- /package/{linked-list → dist/linked-list}/create-linked-list.js.map +0 -0
- /package/{linked-list → dist/linked-list}/find-linked-list.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/find-linked-list.js +0 -0
- /package/{linked-list → dist/linked-list}/find-linked-list.js.map +0 -0
- /package/{linked-list → dist/linked-list}/get-linked-list.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/get-linked-list.js +0 -0
- /package/{linked-list → dist/linked-list}/get-linked-list.js.map +0 -0
- /package/{linked-list → dist/linked-list}/index.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/index.js +0 -0
- /package/{linked-list → dist/linked-list}/index.js.map +0 -0
- /package/{linked-list → dist/linked-list}/insert-linked-list.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/insert-linked-list.js +0 -0
- /package/{linked-list → dist/linked-list}/insert-linked-list.js.map +0 -0
- /package/{linked-list → dist/linked-list}/linked-list-utils.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/linked-list-utils.js +0 -0
- /package/{linked-list → dist/linked-list}/linked-list-utils.js.map +0 -0
- /package/{linked-list → dist/linked-list}/reduce-linked-list.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/reduce-linked-list.js +0 -0
- /package/{linked-list → dist/linked-list}/reduce-linked-list.js.map +0 -0
- /package/{linked-list → dist/linked-list}/remove-linked-list.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/remove-linked-list.js +0 -0
- /package/{linked-list → dist/linked-list}/remove-linked-list.js.map +0 -0
- /package/{linked-list → dist/linked-list}/type.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/update-linked-list.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/update-linked-list.js +0 -0
- /package/{linked-list → dist/linked-list}/update-linked-list.js.map +0 -0
- /package/{linked-list → dist/linked-list}/while-linked-list.d.ts +0 -0
- /package/{linked-list → dist/linked-list}/while-linked-list.js +0 -0
- /package/{linked-list → dist/linked-list}/while-linked-list.js.map +0 -0
- /package/{math → dist/math}/clamp-number.d.ts +0 -0
- /package/{math → dist/math}/clamp-number.js +0 -0
- /package/{math → dist/math}/clamp-number.js.map +0 -0
- /package/{math → dist/math}/index.d.ts +0 -0
- /package/{math → dist/math}/index.js +0 -0
- /package/{math → dist/math}/index.js.map +0 -0
- /package/{math → dist/math}/interpolate.d.ts +0 -0
- /package/{math → dist/math}/interpolate.js +0 -0
- /package/{math → dist/math}/interpolate.js.map +0 -0
- /package/{math → dist/math}/median.d.ts +0 -0
- /package/{math → dist/math}/median.js +0 -0
- /package/{math → dist/math}/median.js.map +0 -0
- /package/{math → dist/math}/number-range.d.ts +0 -0
- /package/{math → dist/math}/number-range.js +0 -0
- /package/{math → dist/math}/number-range.js.map +0 -0
- /package/{math → dist/math}/random-number.d.ts +0 -0
- /package/{math → dist/math}/random-number.js +0 -0
- /package/{math → dist/math}/random-number.js.map +0 -0
- /package/{object → dist/object}/index.d.ts +0 -0
- /package/{object → dist/object}/index.js +0 -0
- /package/{object → dist/object}/index.js.map +0 -0
- /package/{object → dist/object}/merge-deep.d.ts +0 -0
- /package/{object → dist/object}/merge-deep.js +0 -0
- /package/{object → dist/object}/merge-deep.js.map +0 -0
- /package/{object → dist/object}/strip-properties-from-object.d.ts +0 -0
- /package/{object → dist/object}/strip-properties-from-object.js +0 -0
- /package/{object → dist/object}/strip-properties-from-object.js.map +0 -0
- /package/{parsing → dist/parsing}/index.d.ts +0 -0
- /package/{parsing → dist/parsing}/index.js +0 -0
- /package/{parsing → dist/parsing}/index.js.map +0 -0
- /package/{parsing → dist/parsing}/parse-boolean.d.ts +0 -0
- /package/{parsing → dist/parsing}/parse-boolean.js +0 -0
- /package/{parsing → dist/parsing}/parse-boolean.js.map +0 -0
- /package/{parsing → dist/parsing}/parse-enum.d.ts +0 -0
- /package/{parsing → dist/parsing}/parse-enum.js +0 -0
- /package/{parsing → dist/parsing}/parse-enum.js.map +0 -0
- /package/{parsing → dist/parsing}/parse-number.d.ts +0 -0
- /package/{parsing → dist/parsing}/parse-number.js +0 -0
- /package/{parsing → dist/parsing}/parse-number.js.map +0 -0
- /package/{predicates → dist/predicates}/index.d.ts +0 -0
- /package/{predicates → dist/predicates}/index.js +0 -0
- /package/{predicates → dist/predicates}/index.js.map +0 -0
- /package/{predicates → dist/predicates}/is-function.d.ts +0 -0
- /package/{predicates → dist/predicates}/is-function.js +0 -0
- /package/{predicates → dist/predicates}/is-function.js.map +0 -0
- /package/{predicates → dist/predicates}/is-null.d.ts +0 -0
- /package/{predicates → dist/predicates}/is-null.js +0 -0
- /package/{predicates → dist/predicates}/is-null.js.map +0 -0
- /package/{predicates → dist/predicates}/is-object.d.ts +0 -0
- /package/{predicates → dist/predicates}/is-object.js +0 -0
- /package/{predicates → dist/predicates}/is-object.js.map +0 -0
- /package/{predicates → dist/predicates}/is-primitive.d.ts +0 -0
- /package/{predicates → dist/predicates}/is-primitive.js +0 -0
- /package/{predicates → dist/predicates}/is-primitive.js.map +0 -0
- /package/{predicates → dist/predicates}/is-undefined.d.ts +0 -0
- /package/{predicates → dist/predicates}/is-undefined.js +0 -0
- /package/{predicates → dist/predicates}/is-undefined.js.map +0 -0
- /package/{predicates → dist/predicates}/is-uuid.d.ts +0 -0
- /package/{promise → dist/promise}/delay.d.ts +0 -0
- /package/{promise → dist/promise}/delay.js +0 -0
- /package/{promise → dist/promise}/delay.js.map +0 -0
- /package/{promise → dist/promise}/execute-or-resolve-default.d.ts +0 -0
- /package/{promise → dist/promise}/execute-or-resolve-default.js +0 -0
- /package/{promise → dist/promise}/execute-or-resolve-default.js.map +0 -0
- /package/{promise → dist/promise}/execute-with-delay.d.ts +0 -0
- /package/{promise → dist/promise}/execute-with-delay.js +0 -0
- /package/{promise → dist/promise}/execute-with-delay.js.map +0 -0
- /package/{promise → dist/promise}/index.d.ts +0 -0
- /package/{promise → dist/promise}/index.js +0 -0
- /package/{promise → dist/promise}/index.js.map +0 -0
- /package/{string → dist/string}/index.d.ts +0 -0
- /package/{string → dist/string}/index.js +0 -0
- /package/{string → dist/string}/index.js.map +0 -0
- /package/{string → dist/string}/is-string-length-within-range.d.ts +0 -0
- /package/{string → dist/string}/is-string-length-within-range.js +0 -0
- /package/{string → dist/string}/is-string-length-within-range.js.map +0 -0
- /package/{string → dist/string}/replace-in-template.d.ts +0 -0
- /package/{string → dist/string}/replace-in-template.js +0 -0
- /package/{string → dist/string}/replace-in-template.js.map +0 -0
- /package/{time → dist/time}/constants.d.ts +0 -0
- /package/{time → dist/time}/constants.js +0 -0
- /package/{time → dist/time}/constants.js.map +0 -0
- /package/{time → dist/time}/convert.d.ts +0 -0
- /package/{time → dist/time}/convert.js +0 -0
- /package/{time → dist/time}/convert.js.map +0 -0
- /package/{time → dist/time}/format-minutes.d.ts +0 -0
- /package/{time → dist/time}/format-minutes.js +0 -0
- /package/{time → dist/time}/format-minutes.js.map +0 -0
- /package/{time → dist/time}/get-time-diff-as-string.d.ts +0 -0
- /package/{time → dist/time}/get-time-diff-as-string.js +0 -0
- /package/{time → dist/time}/get-time-diff-as-string.js.map +0 -0
- /package/{time → dist/time}/index.d.ts +0 -0
- /package/{time → dist/time}/index.js +0 -0
- /package/{time → dist/time}/index.js.map +0 -0
- /package/{types → dist/types}/function.d.ts +0 -0
- /package/{types → dist/types}/general.d.ts +0 -0
- /package/{types → dist/types}/index.d.ts +0 -0
- /package/{types → dist/types}/object.d.ts +0 -0
- /package/{types → dist/types}/search.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparted/shared-library",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-rc0",
|
|
4
4
|
"repository": "git@github.com:Sparted/shared-library.git",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Sparted",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"sideEffets": false,
|
|
12
|
-
"main": "index.js",
|
|
13
|
-
"module": "index.js",
|
|
12
|
+
"main": "cjs/index.js",
|
|
14
13
|
"files": [
|
|
15
14
|
"**/*",
|
|
16
15
|
"**/**"
|
package/rollup.config.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { glob } from 'glob';
|
|
2
|
+
import typescript from 'rollup-plugin-typescript2';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
input: glob.sync('./src/**/index.ts'),
|
|
6
|
+
plugins: [
|
|
7
|
+
typescript({
|
|
8
|
+
exclude: ['**/__tests__', '**/*.test.ts'],
|
|
9
|
+
}),
|
|
10
|
+
],
|
|
11
|
+
output: [
|
|
12
|
+
{
|
|
13
|
+
dir: 'dist',
|
|
14
|
+
format: 'cjs',
|
|
15
|
+
sourcemap: true,
|
|
16
|
+
preserveModules: true, // Keep directory structure and files
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { arrayToMap } from '../array-to-map';
|
|
2
|
+
|
|
3
|
+
type Item = {
|
|
4
|
+
id: string,
|
|
5
|
+
bar: number,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
describe('arrayToMap', () => {
|
|
9
|
+
it('should convert array to map with item containing one key', () => {
|
|
10
|
+
const array = [{ id: 'toto' }, { id: 'bonjour' }];
|
|
11
|
+
const map = arrayToMap(array, { selectKey: ({ id }) => id });
|
|
12
|
+
|
|
13
|
+
expect(map).toStrictEqual({
|
|
14
|
+
bonjour: { id: 'bonjour' },
|
|
15
|
+
toto: { id: 'toto' },
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should convert array to map and select right key in item', () => {
|
|
20
|
+
const array = [{ id: 'toto', bar: 1 }, { id: 'bonjour', bar: 2 }];
|
|
21
|
+
const map = arrayToMap(array, { selectKey: ({ bar }) => bar.toString() });
|
|
22
|
+
|
|
23
|
+
expect(map).toStrictEqual({
|
|
24
|
+
1: { id: 'toto', bar: 1 },
|
|
25
|
+
2: { id: 'bonjour', bar: 2 },
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should handle data transformation', () => {
|
|
30
|
+
const item1: Item = { id: 'toto', bar: 1 };
|
|
31
|
+
const item2: Item = { id: 'bonjour', bar: 2 };
|
|
32
|
+
const array = [item1, item2];
|
|
33
|
+
|
|
34
|
+
const modifierFn = jest.fn();
|
|
35
|
+
const map = arrayToMap<Item, string>(array, {
|
|
36
|
+
selectKey: ({ bar }) => bar.toString(),
|
|
37
|
+
dataModifier: ({ id }, currentMap) => {
|
|
38
|
+
modifierFn(currentMap);
|
|
39
|
+
return id;
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
expect(modifierFn).toHaveBeenNthCalledWith(1, {});
|
|
44
|
+
expect(modifierFn).toHaveBeenNthCalledWith(2, { 1: 'toto' });
|
|
45
|
+
expect(map).toStrictEqual({
|
|
46
|
+
1: 'toto',
|
|
47
|
+
2: 'bonjour',
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { valuesFromKeys } from '../get-values-from-keys';
|
|
2
|
+
|
|
3
|
+
describe('valuesFromKeys', () => {
|
|
4
|
+
it('should transform a map to an array with only selected keys', () => {
|
|
5
|
+
const map = {
|
|
6
|
+
uno: 1,
|
|
7
|
+
dos: 2,
|
|
8
|
+
tres: 3,
|
|
9
|
+
quatro: 4,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
expect(valuesFromKeys(['uno', 'tres'], map)).toStrictEqual([1, 3]);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { innerJoin } from '../inner-join';
|
|
2
|
+
|
|
3
|
+
describe('innerJoin', () => {
|
|
4
|
+
it('should return an inner join of simple arrays', () => {
|
|
5
|
+
const arr1 = [1, 2, 3];
|
|
6
|
+
const arr2 = [3, 4, 5];
|
|
7
|
+
|
|
8
|
+
const innerJoinedArr = innerJoin(
|
|
9
|
+
arr1,
|
|
10
|
+
arr2,
|
|
11
|
+
(item) => item,
|
|
12
|
+
(item) => item,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
expect(innerJoinedArr).toEqual([3]);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should return an inner join of complex array', () => {
|
|
19
|
+
const arr1 = [
|
|
20
|
+
{ id: 1, name: 'John' },
|
|
21
|
+
{ id: 2, name: 'Doe' },
|
|
22
|
+
{ id: 3, name: 'Jane' },
|
|
23
|
+
{ id: 4, name: 'Jack' },
|
|
24
|
+
{ id: 5, name: 'Jill' },
|
|
25
|
+
{ id: 6, name: 'Maurice' },
|
|
26
|
+
];
|
|
27
|
+
const arr2 = [
|
|
28
|
+
{ id: 3, name: 'Jane' },
|
|
29
|
+
{ id: 4, name: 'Jack' },
|
|
30
|
+
{ id: 5, name: 'Jill' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const innerJoinedArr = innerJoin(
|
|
34
|
+
arr1,
|
|
35
|
+
arr2,
|
|
36
|
+
(item) => item.id,
|
|
37
|
+
(item) => item.id,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(innerJoinedArr).toEqual([
|
|
41
|
+
{
|
|
42
|
+
id: 3,
|
|
43
|
+
name: 'Jane',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 4,
|
|
47
|
+
name: 'Jack',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 5,
|
|
51
|
+
name: 'Jill',
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { leftOutterJoin } from '../left-outter-join';
|
|
2
|
+
|
|
3
|
+
describe('leftOutterJoin', () => {
|
|
4
|
+
it('should return left outter joined of simple arrays', () => {
|
|
5
|
+
const arr1 = [1, 2, 3];
|
|
6
|
+
const arr2 = [3, 4, 5];
|
|
7
|
+
|
|
8
|
+
const leftOutterJoinedArr = leftOutterJoin(
|
|
9
|
+
arr1,
|
|
10
|
+
arr2,
|
|
11
|
+
(item) => item,
|
|
12
|
+
(item) => item,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
expect(leftOutterJoinedArr).toEqual([1, 2]);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should return left outter joined of complex array', () => {
|
|
19
|
+
const arr1 = [
|
|
20
|
+
{ id: 1, name: 'John' },
|
|
21
|
+
{ id: 2, name: 'Doe' },
|
|
22
|
+
{ id: 3, name: 'Jane' },
|
|
23
|
+
{ id: 4, name: 'Jack' },
|
|
24
|
+
{ id: 5, name: 'Jill' },
|
|
25
|
+
{ id: 6, name: 'Maurice' },
|
|
26
|
+
];
|
|
27
|
+
const arr2 = [
|
|
28
|
+
{ id: 3, name: 'Jane' },
|
|
29
|
+
{ id: 4, name: 'Jack' },
|
|
30
|
+
{ id: 5, name: 'Jill' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const leftOutterJoinedArr = leftOutterJoin(
|
|
34
|
+
arr1,
|
|
35
|
+
arr2,
|
|
36
|
+
(item) => item.id,
|
|
37
|
+
(item) => item.id,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(leftOutterJoinedArr).toEqual([
|
|
41
|
+
{
|
|
42
|
+
id: 1,
|
|
43
|
+
name: 'John',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 2,
|
|
47
|
+
name: 'Doe',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 6,
|
|
51
|
+
name: 'Maurice',
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type ArrayToMapOptions<InitialValue, ModifiedValue = InitialValue> = {
|
|
2
|
+
/**
|
|
3
|
+
* Function to return the key used in the map.
|
|
4
|
+
*/
|
|
5
|
+
selectKey: (value: InitialValue) => string,
|
|
6
|
+
/**
|
|
7
|
+
* Transform the initial data into another value
|
|
8
|
+
*/
|
|
9
|
+
dataModifier?: (value: InitialValue, map: Readonly<Record<string, ModifiedValue>>) => ModifiedValue;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Transform an array to a map.
|
|
14
|
+
*/
|
|
15
|
+
export const arrayToMap = <InitialValue, ModifiedValue = InitialValue>(
|
|
16
|
+
array: ReadonlyArray<InitialValue>,
|
|
17
|
+
options: ArrayToMapOptions<InitialValue, ModifiedValue>,
|
|
18
|
+
) => {
|
|
19
|
+
const { selectKey } = options;
|
|
20
|
+
|
|
21
|
+
return array.reduce<Record<string, ModifiedValue>>((acc, current) => {
|
|
22
|
+
const key = selectKey(current);
|
|
23
|
+
const value = options.dataModifier
|
|
24
|
+
? options.dataModifier(current, acc)
|
|
25
|
+
: current;
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
...acc,
|
|
29
|
+
[key]: value as ModifiedValue,
|
|
30
|
+
};
|
|
31
|
+
}, {});
|
|
32
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const innerJoin = <T, U>(
|
|
2
|
+
arr1: T[],
|
|
3
|
+
arr2: U[],
|
|
4
|
+
selectKey1: (item: T) => string | number,
|
|
5
|
+
selectKey2: (item: U) => string | number,
|
|
6
|
+
) => {
|
|
7
|
+
const arr2Set = new Set(arr2.map(selectKey2));
|
|
8
|
+
|
|
9
|
+
return arr1.filter((item) => arr2Set.has(selectKey1(item)));
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const leftOutterJoin = <T, U>(
|
|
2
|
+
arr1: T[],
|
|
3
|
+
arr2: U[],
|
|
4
|
+
selectKey1: (item: T) => string | number,
|
|
5
|
+
selectKey2: (item: U) => string | number,
|
|
6
|
+
) => {
|
|
7
|
+
const arr2Set = new Set(arr2.map(selectKey2));
|
|
8
|
+
|
|
9
|
+
return arr1.filter((item) => !arr2Set.has(selectKey1(item)));
|
|
10
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { MultilingualLabel } from './multilingual';
|
|
2
|
+
import { Image, Media } from './media';
|
|
3
|
+
import { Thematic } from './thematic';
|
|
4
|
+
|
|
5
|
+
export type ErrorText = {
|
|
6
|
+
type: 'error-text';
|
|
7
|
+
gameMedia?: Media;
|
|
8
|
+
explanationMedia?: Media;
|
|
9
|
+
explanation?: MultilingualLabel;
|
|
10
|
+
wrongText?: MultilingualLabel;
|
|
11
|
+
correctText?: MultilingualLabel;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type MultipleChoiceQuestion = {
|
|
15
|
+
type: 'mcq';
|
|
16
|
+
gameMedia?: Media;
|
|
17
|
+
question?: MultilingualLabel;
|
|
18
|
+
explanation?: MultilingualLabel;
|
|
19
|
+
explanationMedia?: Media;
|
|
20
|
+
multiselect?: boolean;
|
|
21
|
+
choices?: {
|
|
22
|
+
correct: boolean;
|
|
23
|
+
text: MultilingualLabel;
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type NoInteraction = {
|
|
28
|
+
type: 'no-interaction';
|
|
29
|
+
firstMedia?: Media;
|
|
30
|
+
secondMedia?: Media;
|
|
31
|
+
title?: MultilingualLabel;
|
|
32
|
+
text?: MultilingualLabel;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type OpenQuestion = {
|
|
36
|
+
type: 'open-question';
|
|
37
|
+
gameMedia?: Media;
|
|
38
|
+
question?: MultilingualLabel;
|
|
39
|
+
answer?: MultilingualLabel;
|
|
40
|
+
explanation?: MultilingualLabel;
|
|
41
|
+
explanationMedia?: Media;
|
|
42
|
+
levenshteinDistance?: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type OrderingCards = {
|
|
46
|
+
type: 'ordering-cards';
|
|
47
|
+
explanation?: MultilingualLabel;
|
|
48
|
+
question?: MultilingualLabel;
|
|
49
|
+
topLabel?: MultilingualLabel;
|
|
50
|
+
bottomLabel?: MultilingualLabel;
|
|
51
|
+
cards: MultilingualLabel[];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type PictureSpot = {
|
|
55
|
+
type: 'picture-spot';
|
|
56
|
+
image?: Image;
|
|
57
|
+
explanation?: MultilingualLabel;
|
|
58
|
+
items?: {
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
r: number;
|
|
62
|
+
question: MultilingualLabel;
|
|
63
|
+
description: MultilingualLabel;
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type SwipingCards = {
|
|
68
|
+
type: 'swiping-cards';
|
|
69
|
+
explanation?: MultilingualLabel;
|
|
70
|
+
question?: MultilingualLabel;
|
|
71
|
+
zones?: {
|
|
72
|
+
position: 'left' | 'right' | 'top' | 'bottom';
|
|
73
|
+
text: MultilingualLabel;
|
|
74
|
+
}[];
|
|
75
|
+
cards?: {
|
|
76
|
+
image?: Image;
|
|
77
|
+
text?: MultilingualLabel;
|
|
78
|
+
answer: 'left' | 'right' | 'top' | 'bottom';
|
|
79
|
+
}[];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type Game =
|
|
83
|
+
| ErrorText
|
|
84
|
+
| MultipleChoiceQuestion
|
|
85
|
+
| NoInteraction
|
|
86
|
+
| OpenQuestion
|
|
87
|
+
| OrderingCards
|
|
88
|
+
| PictureSpot
|
|
89
|
+
| SwipingCards;
|
|
90
|
+
|
|
91
|
+
export type GameType =
|
|
92
|
+
| 'error-text'
|
|
93
|
+
| 'mcq'
|
|
94
|
+
| 'open-question'
|
|
95
|
+
| 'no-interaction'
|
|
96
|
+
| 'picture-spot'
|
|
97
|
+
| 'swiping-cards'
|
|
98
|
+
| 'ordering-cards';
|
|
99
|
+
|
|
100
|
+
export type BaseContent = {
|
|
101
|
+
id: number;
|
|
102
|
+
identifier: string;
|
|
103
|
+
name: MultilingualLabel;
|
|
104
|
+
thematic: Thematic;
|
|
105
|
+
coverImage?: Image;
|
|
106
|
+
status: string;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type Content = BaseContent &
|
|
110
|
+
(ErrorText | MultipleChoiceQuestion | NoInteraction | OpenQuestion | OrderingCards | PictureSpot | SwipingCards);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type Image = {
|
|
2
|
+
id: number;
|
|
3
|
+
url: string;
|
|
4
|
+
filename: string;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type Video = {
|
|
10
|
+
id: number;
|
|
11
|
+
url: string;
|
|
12
|
+
type: 'Youtube' | 'api.video' | 'Kumullus';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type Media = {
|
|
16
|
+
image?: Image;
|
|
17
|
+
video?: Video;
|
|
18
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCdn,
|
|
3
|
+
imgixTransformationQueries,
|
|
4
|
+
twicpicsTransformationQueries,
|
|
5
|
+
} from '../cdn.factory';
|
|
6
|
+
import type { InstanceMapper } from '../types';
|
|
7
|
+
import { getCdnFromS3UrlFactory } from '../utils/get-cdn-from-s3-url.util';
|
|
8
|
+
import { getCdnUrlFactory } from '../utils/get-cdn-url.util';
|
|
9
|
+
|
|
10
|
+
describe('TransformationQueries', () => {
|
|
11
|
+
it('Imgix - should handle imgix transformation', () => {
|
|
12
|
+
expect(
|
|
13
|
+
imgixTransformationQueries({
|
|
14
|
+
fit: 'crop',
|
|
15
|
+
width: 1,
|
|
16
|
+
height: 1,
|
|
17
|
+
}),
|
|
18
|
+
).toBe('auto=compress%2Cformat&fit=crop&h=1&w=1');
|
|
19
|
+
|
|
20
|
+
expect(imgixTransformationQueries({ fit: 'crop', width: 1 })).toBe(
|
|
21
|
+
'auto=compress%2Cformat&fit=crop&w=1',
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
expect(imgixTransformationQueries({ fit: 'crop', height: 1 })).toBe(
|
|
25
|
+
'auto=compress%2Cformat&fit=crop&h=1',
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(imgixTransformationQueries({ width: 1 })).toBe(
|
|
29
|
+
'auto=compress%2Cformat&w=1',
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
expect(imgixTransformationQueries({ height: 1 })).toBe(
|
|
33
|
+
'auto=compress%2Cformat&h=1',
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(imgixTransformationQueries({ width: 1, height: 1 })).toBe(
|
|
37
|
+
'auto=compress%2Cformat&h=1&w=1',
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(imgixTransformationQueries({ devicePixelRatio: 2 })).toBe(
|
|
41
|
+
'auto=compress%2Cformat&dpr=2',
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
expect(imgixTransformationQueries({ quality: 75 })).toBe(
|
|
45
|
+
'auto=compress%2Cformat&q=75',
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect(imgixTransformationQueries({ quality: 75, compress: false })).toBe(
|
|
49
|
+
'q=75',
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
expect(imgixTransformationQueries({ compress: false })).toStrictEqual('');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should handle twicpics transformation', () => {
|
|
56
|
+
const crop = twicpicsTransformationQueries({
|
|
57
|
+
fit: 'crop',
|
|
58
|
+
width: 1,
|
|
59
|
+
height: 1,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect(crop).toBe('twic=v1/quality=90/crop=1x1');
|
|
63
|
+
|
|
64
|
+
const contain = twicpicsTransformationQueries({
|
|
65
|
+
fit: 'contain',
|
|
66
|
+
width: 1,
|
|
67
|
+
height: 1,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
expect(contain).toBe('twic=v1/quality=90/contain=1x1');
|
|
71
|
+
|
|
72
|
+
const coverOnlyWidth = twicpicsTransformationQueries({ width: 1 });
|
|
73
|
+
|
|
74
|
+
expect(coverOnlyWidth).toBe('twic=v1/quality=90/cover=1x-');
|
|
75
|
+
|
|
76
|
+
const coverOnlyHeight = twicpicsTransformationQueries({ height: 1 });
|
|
77
|
+
|
|
78
|
+
expect(coverOnlyHeight).toBe('twic=v1/quality=90/cover=-x1');
|
|
79
|
+
|
|
80
|
+
const noSize = twicpicsTransformationQueries({
|
|
81
|
+
fit: 'contain',
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(noSize).toBe('twic=v1/quality=90');
|
|
85
|
+
|
|
86
|
+
const quality = twicpicsTransformationQueries({
|
|
87
|
+
quality: 75,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
expect(quality).toBe('twic=v1/quality=75');
|
|
91
|
+
|
|
92
|
+
const devicePixelRatio = twicpicsTransformationQueries({
|
|
93
|
+
height: 100,
|
|
94
|
+
width: 45,
|
|
95
|
+
devicePixelRatio: 2,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
expect(devicePixelRatio).toBe('twic=v1/quality=90/cover=90x200');
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('cdnFactory', () => {
|
|
103
|
+
it('Imgix - should instanciate the right cdn', () => {
|
|
104
|
+
const domain = 'https://sparted.imgix.fr';
|
|
105
|
+
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
106
|
+
const getCdnUrl = getCdnUrlFactory({
|
|
107
|
+
domain,
|
|
108
|
+
instanceMapper,
|
|
109
|
+
transformationQueries: imgixTransformationQueries,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const getCdnFromS3Url = getCdnFromS3UrlFactory({
|
|
113
|
+
getCdnUrl,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const cdn = createCdn({
|
|
117
|
+
type: 'imgix',
|
|
118
|
+
domain: 'https://sparted.imgix.fr/',
|
|
119
|
+
instanceMapper,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
expect(cdn.getCdnUrl.toString()).toBe(getCdnUrl.toString());
|
|
123
|
+
|
|
124
|
+
expect(cdn.getCdnFromS3Url.toString()).toBe(getCdnFromS3Url.toString());
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('Twicpics - should instanciate the right cdn', () => {
|
|
128
|
+
const domain = 'https://sparted.twicpics.fr';
|
|
129
|
+
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
130
|
+
const getCdnUrl = getCdnUrlFactory({
|
|
131
|
+
domain,
|
|
132
|
+
instanceMapper,
|
|
133
|
+
transformationQueries: twicpicsTransformationQueries,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const getCdnFromS3Url = getCdnFromS3UrlFactory({
|
|
137
|
+
getCdnUrl,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const cdn = createCdn({
|
|
141
|
+
type: 'twicpics',
|
|
142
|
+
domain: 'https://sparted.twicpics.fr/',
|
|
143
|
+
instanceMapper: (instanceId) => instanceId,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
expect(cdn.getCdnUrl.toString()).toBe(getCdnUrl.toString());
|
|
147
|
+
|
|
148
|
+
expect(cdn.getCdnFromS3Url.toString()).toBe(getCdnFromS3Url.toString());
|
|
149
|
+
});
|
|
150
|
+
});
|