@sparted/shared-library 1.9.5 → 1.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -6
- package/.circleci/config.yml +0 -40
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -25
- package/.gitignore +0 -37
- package/.prettierrc.json +0 -6
- package/CHANGELOG.md +0 -457
- package/README.md +0 -26
- package/dist/package.json +0 -25
- package/global.d.ts +0 -2
- package/rollup.config.ts +0 -19
- package/sparted-shared-library-v1.7.93.tgz +0 -0
- package/src/array/__tests__/array-to-map.test.ts +0 -50
- package/src/array/__tests__/get-values-from-keys.test.ts +0 -14
- package/src/array/__tests__/inner-join.test.ts +0 -55
- package/src/array/__tests__/left-outter-join.test.ts +0 -55
- package/src/array/array-to-map.ts +0 -32
- package/src/array/get-values-from-keys.ts +0 -3
- package/src/array/index.ts +0 -4
- package/src/array/inner-join.ts +0 -10
- package/src/array/left-outter-join.ts +0 -10
- package/src/business/campaign/__tests__/compute-current-session.test.ts +0 -189
- package/src/business/campaign/__tests__/compute-intense-calendar.test.ts +0 -134
- package/src/business/campaign/__tests__/find-next-available-date.test.ts +0 -82
- package/src/business/campaign/__tests__/get-calendar-dession-dates-from-campaign.test.ts +0 -123
- package/src/business/campaign/index.ts +0 -1
- package/src/business/campaign/live-campaign.ts +0 -133
- package/src/business/course/index.ts +0 -1
- package/src/business/course/microknowledge-max-lengths.ts +0 -12
- package/src/business/index.ts +0 -4
- package/src/business/picture-spot/index.ts +0 -3
- package/src/business/types/achievement.ts +0 -41
- package/src/business/types/activity.ts +0 -64
- package/src/business/types/audience.ts +0 -23
- package/src/business/types/battle.ts +0 -17
- package/src/business/types/breaking-news.ts +0 -43
- package/src/business/types/campaign.ts +0 -163
- package/src/business/types/content.ts +0 -261
- package/src/business/types/document.ts +0 -17
- package/src/business/types/index.ts +0 -14
- package/src/business/types/media.ts +0 -18
- package/src/business/types/multilingual.ts +0 -47
- package/src/business/types/player.ts +0 -28
- package/src/business/types/score.ts +0 -61
- package/src/business/types/thematic.ts +0 -12
- package/src/business/types/user-engagement.ts +0 -11
- package/src/cdn/__tests__/cdn.factory.test.ts +0 -150
- package/src/cdn/__tests__/utils.test.ts +0 -528
- package/src/cdn/cdn.factory.ts +0 -70
- package/src/cdn/index.ts +0 -2
- package/src/cdn/types/cdn-factory.type.ts +0 -49
- package/src/cdn/types/index.ts +0 -1
- package/src/cdn/utils/extract-info-from-url.util.ts +0 -25
- package/src/cdn/utils/get-cdn-from-s3-url.util.ts +0 -20
- package/src/cdn/utils/get-cdn-url.util.ts +0 -31
- package/src/cdn/utils/twicpics-transformations.util.ts +0 -9
- package/src/chrono/get-approximated-session-time.ts +0 -27
- package/src/chrono/index.ts +0 -1
- package/src/color/__tests__/get-contrast-color.test.ts +0 -22
- package/src/color/get-contrast-color.ts +0 -18
- package/src/color/index.ts +0 -1
- package/src/crypto/__tests__/aes256.test.ts +0 -23
- package/src/crypto/aes256.ts +0 -22
- package/src/crypto/index.ts +0 -1
- package/src/date/__tests__/get-iso-day-number.test.ts +0 -34
- package/src/date/__tests__/get-remaining-time.test.ts +0 -78
- package/src/date/__tests__/get-start-of-day.test.ts +0 -92
- package/src/date/__tests__/is-same-date.test.ts +0 -50
- package/src/date/__tests__/shift-date-by.test.ts +0 -76
- package/src/date/__tests__/to-utc-date-string.test.ts +0 -28
- package/src/date/add-days.ts +0 -5
- package/src/date/difference-in-days.ts +0 -6
- package/src/date/get-iso-day-number.ts +0 -1
- package/src/date/get-next-day.ts +0 -6
- package/src/date/get-remaining-time.ts +0 -24
- package/src/date/get-start-of-day.ts +0 -11
- package/src/date/index.ts +0 -10
- package/src/date/is-same-date.ts +0 -7
- package/src/date/shift-date-by.ts +0 -17
- package/src/date/to-plain-date-string.ts +0 -1
- package/src/date/to-utc-date-string.ts +0 -3
- package/src/formatting/__tests__/format-number.test.ts +0 -11
- package/src/formatting/format-number.ts +0 -14
- package/src/formatting/index.ts +0 -1
- package/src/fp/__tests__/run-while.test.ts +0 -29
- package/src/fp/index.ts +0 -1
- package/src/fp/run-while.ts +0 -54
- package/src/http/__tests__/build-search-params.test.ts +0 -17
- package/src/http/__tests__/encode-search-object.test.ts +0 -34
- package/src/http/__tests__/fetch-with-timeout.test.ts +0 -50
- package/src/http/build-search-params.ts +0 -16
- package/src/http/encode-search-object.ts +0 -42
- package/src/http/fetch-with-timeout.ts +0 -27
- package/src/http/index.ts +0 -3
- package/src/index.ts +0 -19
- package/src/linked-list/__tests__/apply-diff-linked-list.test.ts +0 -103
- package/src/linked-list/__tests__/create-linked-list.test.ts +0 -204
- package/src/linked-list/__tests__/find-linked-list.test.ts +0 -40
- package/src/linked-list/__tests__/get-linked-list.test.ts +0 -28
- package/src/linked-list/__tests__/insert-linked-list.test.ts +0 -186
- package/src/linked-list/__tests__/linked-list-utils.test.ts +0 -252
- package/src/linked-list/__tests__/reduce-linked-list.test.ts +0 -31
- package/src/linked-list/__tests__/remove-linked-list.test.ts +0 -129
- package/src/linked-list/__tests__/update-linked-list.test.ts +0 -53
- package/src/linked-list/__tests__/while-linked-list.test.ts +0 -58
- package/src/linked-list/apply-diff-linked-list.ts +0 -35
- package/src/linked-list/create-linked-list.ts +0 -79
- package/src/linked-list/find-linked-list.ts +0 -26
- package/src/linked-list/get-linked-list.ts +0 -9
- package/src/linked-list/index.ts +0 -2
- package/src/linked-list/insert-linked-list.ts +0 -50
- package/src/linked-list/linked-list-utils.ts +0 -143
- package/src/linked-list/reduce-linked-list.ts +0 -18
- package/src/linked-list/remove-linked-list.ts +0 -36
- package/src/linked-list/type.ts +0 -38
- package/src/linked-list/update-linked-list.ts +0 -30
- package/src/linked-list/while-linked-list.ts +0 -33
- package/src/math/__tests__/clamp-number.test.ts +0 -30
- package/src/math/__tests__/interpolate.test.ts +0 -28
- package/src/math/__tests__/median.test.ts +0 -27
- package/src/math/__tests__/number-range.test.ts +0 -59
- package/src/math/__tests__/random-number.test.ts +0 -11
- package/src/math/clamp-number.ts +0 -8
- package/src/math/index.ts +0 -5
- package/src/math/interpolate.ts +0 -18
- package/src/math/median.ts +0 -21
- package/src/math/number-range.ts +0 -16
- package/src/math/random-number.ts +0 -10
- package/src/object/__tests__/merge-deep.test.ts +0 -56
- package/src/object/__tests__/strip-properties-from-object.test.ts +0 -65
- package/src/object/index.ts +0 -2
- package/src/object/merge-deep.ts +0 -26
- package/src/object/strip-properties-from-object.ts +0 -26
- package/src/parsing/__tests__/parse-boolean.test.ts +0 -15
- package/src/parsing/__tests__/parse-enum.test.ts +0 -19
- package/src/parsing/__tests__/parse-number.test.ts +0 -20
- package/src/parsing/index.ts +0 -3
- package/src/parsing/parse-boolean.ts +0 -10
- package/src/parsing/parse-enum.ts +0 -16
- package/src/parsing/parse-number.ts +0 -12
- package/src/predicates/__tests__/is-function.test.ts +0 -11
- package/src/predicates/__tests__/is-null.test.ts +0 -11
- package/src/predicates/__tests__/is-object.test.ts +0 -11
- package/src/predicates/__tests__/is-primitive.test.ts +0 -42
- package/src/predicates/__tests__/is-undefined.test.ts +0 -11
- package/src/predicates/__tests__/is-uuid.test.ts +0 -13
- package/src/predicates/index.ts +0 -5
- package/src/predicates/is-function.ts +0 -3
- package/src/predicates/is-null.ts +0 -1
- package/src/predicates/is-object.ts +0 -3
- package/src/predicates/is-primitive.ts +0 -19
- package/src/predicates/is-undefined.ts +0 -3
- package/src/predicates/is-uuid.ts +0 -3
- package/src/promise/__tests__/delay.test.ts +0 -13
- package/src/promise/__tests__/execute-or-resolve-default.test.ts +0 -25
- package/src/promise/__tests__/execute-with-delay.test.ts +0 -24
- package/src/promise/delay.ts +0 -3
- package/src/promise/execute-or-resolve-default.ts +0 -14
- package/src/promise/execute-with-delay.ts +0 -6
- package/src/promise/index.ts +0 -3
- package/src/string/__tests__/is-string-length-within-range.test.ts +0 -23
- package/src/string/__tests__/replace-in-template.test.ts +0 -52
- package/src/string/index.ts +0 -2
- package/src/string/is-string-length-within-range.ts +0 -10
- package/src/string/replace-in-template.ts +0 -45
- package/src/time/__tests__/convert.test.ts +0 -14
- package/src/time/__tests__/format-minutes.test.ts +0 -10
- package/src/time/__tests__/get-time-diff-as-string.test.ts +0 -128
- package/src/time/constants.ts +0 -4
- package/src/time/convert.ts +0 -5
- package/src/time/format-minutes.ts +0 -9
- package/src/time/get-time-diff-as-string.ts +0 -196
- package/src/time/index.ts +0 -4
- package/src/types/function.ts +0 -1
- package/src/types/general.ts +0 -15
- package/src/types/index.ts +0 -4
- package/src/types/object.ts +0 -33
- package/src/types/search.ts +0 -36
- package/tmp-lib.tgz +0 -0
- package/tsconfig.json +0 -25
- package/yarn.lock +0 -4280
- /package/{dist/_virtual → _virtual}/_tslib.js +0 -0
- /package/{dist/_virtual → _virtual}/_tslib.js.map +0 -0
- /package/{dist/array → array}/array-to-map.d.ts +0 -0
- /package/{dist/array → array}/array-to-map.js +0 -0
- /package/{dist/array → array}/array-to-map.js.map +0 -0
- /package/{dist/array → array}/get-values-from-keys.d.ts +0 -0
- /package/{dist/array → array}/get-values-from-keys.js +0 -0
- /package/{dist/array → array}/get-values-from-keys.js.map +0 -0
- /package/{dist/array → array}/index.d.ts +0 -0
- /package/{dist/array → array}/index.js +0 -0
- /package/{dist/array → array}/index.js.map +0 -0
- /package/{dist/array → array}/inner-join.d.ts +0 -0
- /package/{dist/array → array}/inner-join.js +0 -0
- /package/{dist/array → array}/inner-join.js.map +0 -0
- /package/{dist/array → array}/left-outter-join.d.ts +0 -0
- /package/{dist/array → array}/left-outter-join.js +0 -0
- /package/{dist/array → array}/left-outter-join.js.map +0 -0
- /package/{dist/business → business}/campaign/index.d.ts +0 -0
- /package/{dist/business → business}/campaign/index.js +0 -0
- /package/{dist/business → business}/campaign/index.js.map +0 -0
- /package/{dist/business → business}/campaign/live-campaign.d.ts +0 -0
- /package/{dist/business → business}/campaign/live-campaign.js +0 -0
- /package/{dist/business → business}/campaign/live-campaign.js.map +0 -0
- /package/{dist/business → business}/course/index.d.ts +0 -0
- /package/{dist/business → business}/course/index.js +0 -0
- /package/{dist/business → business}/course/index.js.map +0 -0
- /package/{dist/business → business}/course/microknowledge-max-lengths.d.ts +0 -0
- /package/{dist/business → business}/course/microknowledge-max-lengths.js +0 -0
- /package/{dist/business → business}/course/microknowledge-max-lengths.js.map +0 -0
- /package/{dist/business → business}/index.d.ts +0 -0
- /package/{dist/business → business}/index.js +0 -0
- /package/{dist/business → business}/index.js.map +0 -0
- /package/{dist/business → business}/picture-spot/index.d.ts +0 -0
- /package/{dist/business → business}/picture-spot/index.js +0 -0
- /package/{dist/business → business}/picture-spot/index.js.map +0 -0
- /package/{dist/business → business}/types/achievement.d.ts +0 -0
- /package/{dist/business → business}/types/activity.d.ts +0 -0
- /package/{dist/business → business}/types/activity.js +0 -0
- /package/{dist/business → business}/types/activity.js.map +0 -0
- /package/{dist/business → business}/types/audience.d.ts +0 -0
- /package/{dist/business → business}/types/battle.d.ts +0 -0
- /package/{dist/business → business}/types/breaking-news.d.ts +0 -0
- /package/{dist/business → business}/types/campaign.d.ts +0 -0
- /package/{dist/business → business}/types/campaign.js +0 -0
- /package/{dist/business → business}/types/campaign.js.map +0 -0
- /package/{dist/business → business}/types/content.d.ts +0 -0
- /package/{dist/business → business}/types/content.js +0 -0
- /package/{dist/business → business}/types/content.js.map +0 -0
- /package/{dist/business → business}/types/document.d.ts +0 -0
- /package/{dist/business → business}/types/index.d.ts +0 -0
- /package/{dist/business → business}/types/index.js +0 -0
- /package/{dist/business → business}/types/index.js.map +0 -0
- /package/{dist/business → business}/types/media.d.ts +0 -0
- /package/{dist/business → business}/types/multilingual.d.ts +0 -0
- /package/{dist/business → business}/types/multilingual.js +0 -0
- /package/{dist/business → business}/types/multilingual.js.map +0 -0
- /package/{dist/business → business}/types/player.d.ts +0 -0
- /package/{dist/business → business}/types/score.d.ts +0 -0
- /package/{dist/business → business}/types/score.js +0 -0
- /package/{dist/business → business}/types/score.js.map +0 -0
- /package/{dist/business → business}/types/thematic.d.ts +0 -0
- /package/{dist/business → business}/types/user-engagement.d.ts +0 -0
- /package/{dist/cdn → cdn}/cdn.factory.d.ts +0 -0
- /package/{dist/cdn → cdn}/cdn.factory.js +0 -0
- /package/{dist/cdn → cdn}/cdn.factory.js.map +0 -0
- /package/{dist/cdn → cdn}/index.d.ts +0 -0
- /package/{dist/cdn → cdn}/index.js +0 -0
- /package/{dist/cdn → cdn}/index.js.map +0 -0
- /package/{dist/cdn → cdn}/types/cdn-factory.type.d.ts +0 -0
- /package/{dist/cdn → cdn}/types/index.d.ts +0 -0
- /package/{dist/cdn → cdn}/types/index.js +0 -0
- /package/{dist/cdn → cdn}/types/index.js.map +0 -0
- /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.d.ts +0 -0
- /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.js +0 -0
- /package/{dist/cdn → cdn}/utils/extract-info-from-url.util.js.map +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.d.ts +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.js +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-from-s3-url.util.js.map +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-url.util.d.ts +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-url.util.js +0 -0
- /package/{dist/cdn → cdn}/utils/get-cdn-url.util.js.map +0 -0
- /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.d.ts +0 -0
- /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.js +0 -0
- /package/{dist/cdn → cdn}/utils/twicpics-transformations.util.js.map +0 -0
- /package/{dist/chrono → chrono}/get-approximated-session-time.d.ts +0 -0
- /package/{dist/chrono → chrono}/get-approximated-session-time.js +0 -0
- /package/{dist/chrono → chrono}/get-approximated-session-time.js.map +0 -0
- /package/{dist/chrono → chrono}/index.d.ts +0 -0
- /package/{dist/chrono → chrono}/index.js +0 -0
- /package/{dist/chrono → chrono}/index.js.map +0 -0
- /package/{dist/color → color}/get-contrast-color.d.ts +0 -0
- /package/{dist/color → color}/get-contrast-color.js +0 -0
- /package/{dist/color → color}/get-contrast-color.js.map +0 -0
- /package/{dist/color → color}/index.d.ts +0 -0
- /package/{dist/color → color}/index.js +0 -0
- /package/{dist/color → color}/index.js.map +0 -0
- /package/{dist/crypto → crypto}/aes256.d.ts +0 -0
- /package/{dist/crypto → crypto}/aes256.js +0 -0
- /package/{dist/crypto → crypto}/aes256.js.map +0 -0
- /package/{dist/crypto → crypto}/index.d.ts +0 -0
- /package/{dist/crypto → crypto}/index.js +0 -0
- /package/{dist/crypto → crypto}/index.js.map +0 -0
- /package/{dist/date → date}/add-days.d.ts +0 -0
- /package/{dist/date → date}/add-days.js +0 -0
- /package/{dist/date → date}/add-days.js.map +0 -0
- /package/{dist/date → date}/difference-in-days.d.ts +0 -0
- /package/{dist/date → date}/difference-in-days.js +0 -0
- /package/{dist/date → date}/difference-in-days.js.map +0 -0
- /package/{dist/date → date}/get-iso-day-number.d.ts +0 -0
- /package/{dist/date → date}/get-iso-day-number.js +0 -0
- /package/{dist/date → date}/get-iso-day-number.js.map +0 -0
- /package/{dist/date → date}/get-next-day.d.ts +0 -0
- /package/{dist/date → date}/get-next-day.js +0 -0
- /package/{dist/date → date}/get-next-day.js.map +0 -0
- /package/{dist/date → date}/get-remaining-time.d.ts +0 -0
- /package/{dist/date → date}/get-remaining-time.js +0 -0
- /package/{dist/date → date}/get-remaining-time.js.map +0 -0
- /package/{dist/date → date}/get-start-of-day.d.ts +0 -0
- /package/{dist/date → date}/get-start-of-day.js +0 -0
- /package/{dist/date → date}/get-start-of-day.js.map +0 -0
- /package/{dist/date → date}/index.d.ts +0 -0
- /package/{dist/date → date}/index.js +0 -0
- /package/{dist/date → date}/index.js.map +0 -0
- /package/{dist/date → date}/is-same-date.d.ts +0 -0
- /package/{dist/date → date}/is-same-date.js +0 -0
- /package/{dist/date → date}/is-same-date.js.map +0 -0
- /package/{dist/date → date}/shift-date-by.d.ts +0 -0
- /package/{dist/date → date}/shift-date-by.js +0 -0
- /package/{dist/date → date}/shift-date-by.js.map +0 -0
- /package/{dist/date → date}/to-plain-date-string.d.ts +0 -0
- /package/{dist/date → date}/to-plain-date-string.js +0 -0
- /package/{dist/date → date}/to-plain-date-string.js.map +0 -0
- /package/{dist/date → date}/to-utc-date-string.d.ts +0 -0
- /package/{dist/date → date}/to-utc-date-string.js +0 -0
- /package/{dist/date → date}/to-utc-date-string.js.map +0 -0
- /package/{dist/formatting → formatting}/format-number.d.ts +0 -0
- /package/{dist/formatting → formatting}/format-number.js +0 -0
- /package/{dist/formatting → formatting}/format-number.js.map +0 -0
- /package/{dist/formatting → formatting}/index.d.ts +0 -0
- /package/{dist/formatting → formatting}/index.js +0 -0
- /package/{dist/formatting → formatting}/index.js.map +0 -0
- /package/{dist/fp → fp}/index.d.ts +0 -0
- /package/{dist/fp → fp}/index.js +0 -0
- /package/{dist/fp → fp}/index.js.map +0 -0
- /package/{dist/fp → fp}/run-while.d.ts +0 -0
- /package/{dist/fp → fp}/run-while.js +0 -0
- /package/{dist/fp → fp}/run-while.js.map +0 -0
- /package/{dist/http → http}/build-search-params.d.ts +0 -0
- /package/{dist/http → http}/build-search-params.js +0 -0
- /package/{dist/http → http}/build-search-params.js.map +0 -0
- /package/{dist/http → http}/encode-search-object.d.ts +0 -0
- /package/{dist/http → http}/encode-search-object.js +0 -0
- /package/{dist/http → http}/encode-search-object.js.map +0 -0
- /package/{dist/http → http}/fetch-with-timeout.d.ts +0 -0
- /package/{dist/http → http}/fetch-with-timeout.js +0 -0
- /package/{dist/http → http}/fetch-with-timeout.js.map +0 -0
- /package/{dist/http → http}/index.d.ts +0 -0
- /package/{dist/http → http}/index.js +0 -0
- /package/{dist/http → http}/index.js.map +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
- /package/{dist/linked-list → linked-list}/apply-diff-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/apply-diff-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/apply-diff-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/create-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/create-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/create-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/find-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/find-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/find-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/get-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/get-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/get-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/index.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/index.js +0 -0
- /package/{dist/linked-list → linked-list}/index.js.map +0 -0
- /package/{dist/linked-list → linked-list}/insert-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/insert-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/insert-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/linked-list-utils.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/linked-list-utils.js +0 -0
- /package/{dist/linked-list → linked-list}/linked-list-utils.js.map +0 -0
- /package/{dist/linked-list → linked-list}/reduce-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/reduce-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/reduce-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/remove-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/remove-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/remove-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/type.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/update-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/update-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/update-linked-list.js.map +0 -0
- /package/{dist/linked-list → linked-list}/while-linked-list.d.ts +0 -0
- /package/{dist/linked-list → linked-list}/while-linked-list.js +0 -0
- /package/{dist/linked-list → linked-list}/while-linked-list.js.map +0 -0
- /package/{dist/math → math}/clamp-number.d.ts +0 -0
- /package/{dist/math → math}/clamp-number.js +0 -0
- /package/{dist/math → math}/clamp-number.js.map +0 -0
- /package/{dist/math → math}/index.d.ts +0 -0
- /package/{dist/math → math}/index.js +0 -0
- /package/{dist/math → math}/index.js.map +0 -0
- /package/{dist/math → math}/interpolate.d.ts +0 -0
- /package/{dist/math → math}/interpolate.js +0 -0
- /package/{dist/math → math}/interpolate.js.map +0 -0
- /package/{dist/math → math}/median.d.ts +0 -0
- /package/{dist/math → math}/median.js +0 -0
- /package/{dist/math → math}/median.js.map +0 -0
- /package/{dist/math → math}/number-range.d.ts +0 -0
- /package/{dist/math → math}/number-range.js +0 -0
- /package/{dist/math → math}/number-range.js.map +0 -0
- /package/{dist/math → math}/random-number.d.ts +0 -0
- /package/{dist/math → math}/random-number.js +0 -0
- /package/{dist/math → math}/random-number.js.map +0 -0
- /package/{dist/object → object}/index.d.ts +0 -0
- /package/{dist/object → object}/index.js +0 -0
- /package/{dist/object → object}/index.js.map +0 -0
- /package/{dist/object → object}/merge-deep.d.ts +0 -0
- /package/{dist/object → object}/merge-deep.js +0 -0
- /package/{dist/object → object}/merge-deep.js.map +0 -0
- /package/{dist/object → object}/strip-properties-from-object.d.ts +0 -0
- /package/{dist/object → object}/strip-properties-from-object.js +0 -0
- /package/{dist/object → object}/strip-properties-from-object.js.map +0 -0
- /package/{dist/parsing → parsing}/index.d.ts +0 -0
- /package/{dist/parsing → parsing}/index.js +0 -0
- /package/{dist/parsing → parsing}/index.js.map +0 -0
- /package/{dist/parsing → parsing}/parse-boolean.d.ts +0 -0
- /package/{dist/parsing → parsing}/parse-boolean.js +0 -0
- /package/{dist/parsing → parsing}/parse-boolean.js.map +0 -0
- /package/{dist/parsing → parsing}/parse-enum.d.ts +0 -0
- /package/{dist/parsing → parsing}/parse-enum.js +0 -0
- /package/{dist/parsing → parsing}/parse-enum.js.map +0 -0
- /package/{dist/parsing → parsing}/parse-number.d.ts +0 -0
- /package/{dist/parsing → parsing}/parse-number.js +0 -0
- /package/{dist/parsing → parsing}/parse-number.js.map +0 -0
- /package/{dist/predicates → predicates}/index.d.ts +0 -0
- /package/{dist/predicates → predicates}/index.js +0 -0
- /package/{dist/predicates → predicates}/index.js.map +0 -0
- /package/{dist/predicates → predicates}/is-function.d.ts +0 -0
- /package/{dist/predicates → predicates}/is-function.js +0 -0
- /package/{dist/predicates → predicates}/is-function.js.map +0 -0
- /package/{dist/predicates → predicates}/is-null.d.ts +0 -0
- /package/{dist/predicates → predicates}/is-null.js +0 -0
- /package/{dist/predicates → predicates}/is-null.js.map +0 -0
- /package/{dist/predicates → predicates}/is-object.d.ts +0 -0
- /package/{dist/predicates → predicates}/is-object.js +0 -0
- /package/{dist/predicates → predicates}/is-object.js.map +0 -0
- /package/{dist/predicates → predicates}/is-primitive.d.ts +0 -0
- /package/{dist/predicates → predicates}/is-primitive.js +0 -0
- /package/{dist/predicates → predicates}/is-primitive.js.map +0 -0
- /package/{dist/predicates → predicates}/is-undefined.d.ts +0 -0
- /package/{dist/predicates → predicates}/is-undefined.js +0 -0
- /package/{dist/predicates → predicates}/is-undefined.js.map +0 -0
- /package/{dist/predicates → predicates}/is-uuid.d.ts +0 -0
- /package/{dist/promise → promise}/delay.d.ts +0 -0
- /package/{dist/promise → promise}/delay.js +0 -0
- /package/{dist/promise → promise}/delay.js.map +0 -0
- /package/{dist/promise → promise}/execute-or-resolve-default.d.ts +0 -0
- /package/{dist/promise → promise}/execute-or-resolve-default.js +0 -0
- /package/{dist/promise → promise}/execute-or-resolve-default.js.map +0 -0
- /package/{dist/promise → promise}/execute-with-delay.d.ts +0 -0
- /package/{dist/promise → promise}/execute-with-delay.js +0 -0
- /package/{dist/promise → promise}/execute-with-delay.js.map +0 -0
- /package/{dist/promise → promise}/index.d.ts +0 -0
- /package/{dist/promise → promise}/index.js +0 -0
- /package/{dist/promise → promise}/index.js.map +0 -0
- /package/{dist/string → string}/index.d.ts +0 -0
- /package/{dist/string → string}/index.js +0 -0
- /package/{dist/string → string}/index.js.map +0 -0
- /package/{dist/string → string}/is-string-length-within-range.d.ts +0 -0
- /package/{dist/string → string}/is-string-length-within-range.js +0 -0
- /package/{dist/string → string}/is-string-length-within-range.js.map +0 -0
- /package/{dist/string → string}/replace-in-template.d.ts +0 -0
- /package/{dist/string → string}/replace-in-template.js +0 -0
- /package/{dist/string → string}/replace-in-template.js.map +0 -0
- /package/{dist/time → time}/constants.d.ts +0 -0
- /package/{dist/time → time}/constants.js +0 -0
- /package/{dist/time → time}/constants.js.map +0 -0
- /package/{dist/time → time}/convert.d.ts +0 -0
- /package/{dist/time → time}/convert.js +0 -0
- /package/{dist/time → time}/convert.js.map +0 -0
- /package/{dist/time → time}/format-minutes.d.ts +0 -0
- /package/{dist/time → time}/format-minutes.js +0 -0
- /package/{dist/time → time}/format-minutes.js.map +0 -0
- /package/{dist/time → time}/get-time-diff-as-string.d.ts +0 -0
- /package/{dist/time → time}/get-time-diff-as-string.js +0 -0
- /package/{dist/time → time}/get-time-diff-as-string.js.map +0 -0
- /package/{dist/time → time}/index.d.ts +0 -0
- /package/{dist/time → time}/index.js +0 -0
- /package/{dist/time → time}/index.js.map +0 -0
- /package/{dist/types → types}/function.d.ts +0 -0
- /package/{dist/types → types}/general.d.ts +0 -0
- /package/{dist/types → types}/index.d.ts +0 -0
- /package/{dist/types → types}/index.js +0 -0
- /package/{dist/types → types}/index.js.map +0 -0
- /package/{dist/types → types}/object.d.ts +0 -0
- /package/{dist/types → types}/search.d.ts +0 -0
|
@@ -1,528 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
imgixTransformationQueries,
|
|
3
|
-
twicpicsTransformationQueries,
|
|
4
|
-
} from '../cdn.factory';
|
|
5
|
-
import { extractInfoFromUrl } from '../utils/extract-info-from-url.util';
|
|
6
|
-
import { genCacheVersionQuery, getCdnUrlFactory } from '../utils/get-cdn-url.util';
|
|
7
|
-
import { getCdnFromS3UrlFactory } from '../utils/get-cdn-from-s3-url.util';
|
|
8
|
-
import type { InstanceMapper } from '../types';
|
|
9
|
-
|
|
10
|
-
describe('extract-info-from-url', () => {
|
|
11
|
-
it('should handle non-aws s3 url', () => {
|
|
12
|
-
const info = extractInfoFromUrl('https://www.google.com');
|
|
13
|
-
|
|
14
|
-
expect(info).toBeUndefined();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should handle all aws s3 url', () => {
|
|
18
|
-
const { instanceId: instanceIdEW1, path: pathEW1 } = extractInfoFromUrl(
|
|
19
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
20
|
-
) ?? {};
|
|
21
|
-
|
|
22
|
-
expect(instanceIdEW1).toBe('check');
|
|
23
|
-
expect(pathEW1).toBe('/path/to/something');
|
|
24
|
-
|
|
25
|
-
const { instanceId: instanceIdAmazonaws, path: pathAmazonaws } = extractInfoFromUrl(
|
|
26
|
-
'https://sparted-prod-check.s3.amazonaws.com/path/to/something',
|
|
27
|
-
) ?? {};
|
|
28
|
-
|
|
29
|
-
expect(instanceIdAmazonaws).toBe('check');
|
|
30
|
-
expect(pathAmazonaws).toBe('/path/to/something');
|
|
31
|
-
|
|
32
|
-
const { instanceId: instanceIdCloud, path: pathCloud } = extractInfoFromUrl(
|
|
33
|
-
'https://sparted-prod-check.s3.fr-par.scw.cloud/path/to/something',
|
|
34
|
-
) ?? {};
|
|
35
|
-
|
|
36
|
-
expect(instanceIdCloud).toBe('check');
|
|
37
|
-
expect(pathCloud).toBe('/path/to/something');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should handle any param and not crash', () => {
|
|
41
|
-
// @ts-ignore - Passing wrong param to fn in test
|
|
42
|
-
expect(extractInfoFromUrl()).toBeUndefined();
|
|
43
|
-
// @ts-ignore - Passing wrong param to fn in test
|
|
44
|
-
expect(extractInfoFromUrl([])).toBeUndefined();
|
|
45
|
-
// @ts-ignore - Passing wrong param to fn in test
|
|
46
|
-
expect(extractInfoFromUrl({})).toBeUndefined();
|
|
47
|
-
expect(extractInfoFromUrl('')).toBeUndefined();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('getCdnUrlFactory', () => {
|
|
52
|
-
it('Imgix - should generate url without params', () => {
|
|
53
|
-
const domain = 'https://sparted.imgix.fr';
|
|
54
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
55
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
56
|
-
domain,
|
|
57
|
-
instanceMapper,
|
|
58
|
-
transformationQueries: imgixTransformationQueries,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
expect(getCdnUrl('test', '/path/to/something')).toBe(
|
|
62
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat',
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('Twicpics - should generate url without params', () => {
|
|
67
|
-
const domain = 'https://sparted.twicpics.fr';
|
|
68
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
69
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
70
|
-
domain,
|
|
71
|
-
instanceMapper,
|
|
72
|
-
transformationQueries: twicpicsTransformationQueries,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
expect(getCdnUrl('test', '/path/to/something')).toBe(
|
|
76
|
-
'https://sparted.twicpics.fr/prod/test/path/to/something?twic=v1/quality=70',
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('Imgix - should generate url with cache param', () => {
|
|
81
|
-
const domain = 'https://sparted.imgix.fr';
|
|
82
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
83
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
84
|
-
domain,
|
|
85
|
-
instanceMapper,
|
|
86
|
-
transformationQueries: imgixTransformationQueries,
|
|
87
|
-
cacheVersion: 3,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
expect(getCdnUrl('test', '/path/to/something')).toBe(
|
|
91
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat&v=3',
|
|
92
|
-
);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('Twicpics - should generate url with cache param', () => {
|
|
96
|
-
const domain = 'https://sparted.twicpics.fr';
|
|
97
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
98
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
99
|
-
domain,
|
|
100
|
-
instanceMapper,
|
|
101
|
-
transformationQueries: twicpicsTransformationQueries,
|
|
102
|
-
cacheVersion: 3,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
expect(getCdnUrl('test', '/path/to/something')).toBe(
|
|
106
|
-
'https://sparted.twicpics.fr/prod/test/path/to/something?twic=v1/quality=70&v=3',
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('Imgix - should generate url of image as thumbnail', () => {
|
|
111
|
-
const domain = 'https://sparted.imgix.fr';
|
|
112
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
113
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
114
|
-
domain,
|
|
115
|
-
instanceMapper,
|
|
116
|
-
transformationQueries: imgixTransformationQueries,
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
expect(getCdnUrl('test', '/path/to/something', { asThumbnail: true })).toBe(
|
|
120
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat&h=300&w=300',
|
|
121
|
-
);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('Twicpics - should generate url of image as thumbnail', () => {
|
|
125
|
-
const domain = 'https://sparted.twicpics.fr';
|
|
126
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
127
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
128
|
-
domain,
|
|
129
|
-
instanceMapper,
|
|
130
|
-
transformationQueries: twicpicsTransformationQueries,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
expect(getCdnUrl('test', '/path/to/something', { asThumbnail: true })).toBe(
|
|
134
|
-
'https://sparted.twicpics.fr/prod/test/path/to/something?twic=v1/quality=70/cover=300x300',
|
|
135
|
-
);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('Imgix - should generate url with params', () => {
|
|
139
|
-
const domain = 'https://sparted.imgix.fr';
|
|
140
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
141
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
142
|
-
domain,
|
|
143
|
-
instanceMapper,
|
|
144
|
-
transformationQueries: imgixTransformationQueries,
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
expect(
|
|
148
|
-
getCdnUrl('test', '/path/to/something', {
|
|
149
|
-
transformation: { fit: 'crop', height: 1, width: 1 },
|
|
150
|
-
}),
|
|
151
|
-
).toBe(
|
|
152
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat&fit=crop&h=1&w=1',
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
expect(
|
|
156
|
-
getCdnUrl('test', '/path/to/something', {
|
|
157
|
-
transformation: { fit: 'crop', width: 1 },
|
|
158
|
-
}),
|
|
159
|
-
).toBe(
|
|
160
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat&fit=crop&w=1',
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
expect(
|
|
164
|
-
getCdnUrl('test', '/path/to/something', {
|
|
165
|
-
transformation: { fit: 'crop', height: 1 },
|
|
166
|
-
}),
|
|
167
|
-
).toBe(
|
|
168
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat&fit=crop&h=1',
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
expect(
|
|
172
|
-
getCdnUrl('test', '/path/to/something', { transformation: { width: 1 } }),
|
|
173
|
-
).toBe(
|
|
174
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat&w=1',
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
expect(
|
|
178
|
-
getCdnUrl('test', '/path/to/something', { transformation: { height: 1 } }),
|
|
179
|
-
).toBe(
|
|
180
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat&h=1',
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
expect(
|
|
184
|
-
getCdnUrl('test', '/path/to/something', {
|
|
185
|
-
transformation: { height: 1, width: 1 },
|
|
186
|
-
}),
|
|
187
|
-
).toBe(
|
|
188
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat&h=1&w=1',
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
expect(
|
|
192
|
-
getCdnUrl('test', '/path/to/something', {
|
|
193
|
-
transformation: { devicePixelRatio: 2 },
|
|
194
|
-
}),
|
|
195
|
-
).toBe(
|
|
196
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat&dpr=2',
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
expect(
|
|
200
|
-
getCdnUrl('test', '/path/to/something', {
|
|
201
|
-
transformation: { quality: 75 },
|
|
202
|
-
}),
|
|
203
|
-
).toBe(
|
|
204
|
-
'https://sparted.imgix.fr/prod/test/path/to/something?auto=compress%2Cformat&q=75',
|
|
205
|
-
);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('Twicpics - should generate url of image as thumbnail', () => {
|
|
209
|
-
const domain = 'https://sparted.twicpics.fr';
|
|
210
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
211
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
212
|
-
domain,
|
|
213
|
-
instanceMapper,
|
|
214
|
-
transformationQueries: twicpicsTransformationQueries,
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
expect(
|
|
218
|
-
getCdnUrl('test', '/path/to/something', {
|
|
219
|
-
transformation: { fit: 'crop', height: 1, width: 1 },
|
|
220
|
-
}),
|
|
221
|
-
).toBe(
|
|
222
|
-
'https://sparted.twicpics.fr/prod/test/path/to/something?twic=v1/quality=70/crop=1x1',
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
expect(
|
|
226
|
-
getCdnUrl('test', '/path/to/something', {
|
|
227
|
-
transformation: { fit: 'contain', height: 1, width: 1 },
|
|
228
|
-
}),
|
|
229
|
-
).toBe(
|
|
230
|
-
'https://sparted.twicpics.fr/prod/test/path/to/something?twic=v1/quality=70/contain=1x1',
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
expect(
|
|
234
|
-
getCdnUrl('test', '/path/to/something', { transformation: { width: 1 } }),
|
|
235
|
-
).toBe(
|
|
236
|
-
'https://sparted.twicpics.fr/prod/test/path/to/something?twic=v1/quality=70/cover=1x-',
|
|
237
|
-
);
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
describe('getCdnFromS3UrlFactory', () => {
|
|
242
|
-
it('Imgix - should handle non-aws s3 url', () => {
|
|
243
|
-
const domain = 'https://sparted.imgix.fr';
|
|
244
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
245
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
246
|
-
domain,
|
|
247
|
-
instanceMapper,
|
|
248
|
-
transformationQueries: imgixTransformationQueries,
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
const getCdnFromS3Url = getCdnFromS3UrlFactory({
|
|
252
|
-
getCdnUrl,
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
expect(getCdnFromS3Url('https://www.google.com')).toBe(
|
|
256
|
-
'https://www.google.com',
|
|
257
|
-
);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it('Twicpics - should handle non-aws s3 url', () => {
|
|
261
|
-
const domain = 'https://sparted.twicpics.fr';
|
|
262
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
263
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
264
|
-
domain,
|
|
265
|
-
instanceMapper,
|
|
266
|
-
transformationQueries: twicpicsTransformationQueries,
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
const getCdnFromS3Url = getCdnFromS3UrlFactory({
|
|
270
|
-
getCdnUrl,
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
expect(getCdnFromS3Url('https://www.google.com')).toBe(
|
|
274
|
-
'https://www.google.com',
|
|
275
|
-
);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it('Imgix - should handle all aws s3 url with no params', () => {
|
|
279
|
-
const domain = 'https://sparted.imgix.fr';
|
|
280
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
281
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
282
|
-
domain,
|
|
283
|
-
instanceMapper,
|
|
284
|
-
transformationQueries: imgixTransformationQueries,
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
const getCdnFromS3Url = getCdnFromS3UrlFactory({
|
|
288
|
-
getCdnUrl,
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
expect(
|
|
292
|
-
getCdnFromS3Url(
|
|
293
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
294
|
-
),
|
|
295
|
-
).toBe(
|
|
296
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat',
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
expect(
|
|
300
|
-
getCdnFromS3Url(
|
|
301
|
-
'https://sparted-prod-check.s3.amazonaws.com/path/to/something',
|
|
302
|
-
),
|
|
303
|
-
).toBe(
|
|
304
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat',
|
|
305
|
-
);
|
|
306
|
-
|
|
307
|
-
expect(
|
|
308
|
-
getCdnFromS3Url(
|
|
309
|
-
'https://sparted-prod-check.s3.fr-par.scw.cloud/path/to/something',
|
|
310
|
-
),
|
|
311
|
-
).toBe(
|
|
312
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat',
|
|
313
|
-
);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
it('Twicpics - should handle all aws s3 url with no params', () => {
|
|
317
|
-
const domain = 'https://sparted.twicpics.fr';
|
|
318
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
319
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
320
|
-
domain,
|
|
321
|
-
instanceMapper,
|
|
322
|
-
transformationQueries: twicpicsTransformationQueries,
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
const getCdnFromS3Url = getCdnFromS3UrlFactory({
|
|
326
|
-
getCdnUrl,
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
expect(
|
|
330
|
-
getCdnFromS3Url(
|
|
331
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
332
|
-
),
|
|
333
|
-
).toBe('https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/quality=70');
|
|
334
|
-
|
|
335
|
-
expect(
|
|
336
|
-
getCdnFromS3Url(
|
|
337
|
-
'https://sparted-prod-check.s3.amazonaws.com/path/to/something',
|
|
338
|
-
),
|
|
339
|
-
).toBe('https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/quality=70');
|
|
340
|
-
|
|
341
|
-
expect(
|
|
342
|
-
getCdnFromS3Url(
|
|
343
|
-
'https://sparted-prod-check.s3.fr-par.scw.cloud/path/to/something',
|
|
344
|
-
),
|
|
345
|
-
).toBe('https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/quality=70');
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
it('Imgix - should handle params', () => {
|
|
349
|
-
const domain = 'https://sparted.imgix.fr';
|
|
350
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
351
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
352
|
-
domain,
|
|
353
|
-
instanceMapper,
|
|
354
|
-
transformationQueries: imgixTransformationQueries,
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
const getCdnFromS3Url = getCdnFromS3UrlFactory({
|
|
358
|
-
getCdnUrl,
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
expect(
|
|
362
|
-
getCdnFromS3Url(
|
|
363
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
364
|
-
{
|
|
365
|
-
transformation: { fit: 'crop', height: 1, width: 1 },
|
|
366
|
-
},
|
|
367
|
-
),
|
|
368
|
-
).toBe(
|
|
369
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat&fit=crop&h=1&w=1',
|
|
370
|
-
);
|
|
371
|
-
|
|
372
|
-
expect(
|
|
373
|
-
getCdnFromS3Url(
|
|
374
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
375
|
-
{
|
|
376
|
-
transformation: { fit: 'crop', width: 1 },
|
|
377
|
-
},
|
|
378
|
-
),
|
|
379
|
-
).toBe(
|
|
380
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat&fit=crop&w=1',
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
expect(
|
|
384
|
-
getCdnFromS3Url(
|
|
385
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
386
|
-
{
|
|
387
|
-
transformation: { fit: 'crop', height: 1 },
|
|
388
|
-
},
|
|
389
|
-
),
|
|
390
|
-
).toBe(
|
|
391
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat&fit=crop&h=1',
|
|
392
|
-
);
|
|
393
|
-
|
|
394
|
-
expect(
|
|
395
|
-
getCdnFromS3Url(
|
|
396
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
397
|
-
{
|
|
398
|
-
transformation: { width: 1 },
|
|
399
|
-
},
|
|
400
|
-
),
|
|
401
|
-
).toBe(
|
|
402
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat&w=1',
|
|
403
|
-
);
|
|
404
|
-
|
|
405
|
-
expect(
|
|
406
|
-
getCdnFromS3Url(
|
|
407
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
408
|
-
{
|
|
409
|
-
transformation: { height: 1 },
|
|
410
|
-
},
|
|
411
|
-
),
|
|
412
|
-
).toBe(
|
|
413
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat&h=1',
|
|
414
|
-
);
|
|
415
|
-
|
|
416
|
-
expect(
|
|
417
|
-
getCdnFromS3Url(
|
|
418
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
419
|
-
{
|
|
420
|
-
transformation: { height: 1, width: 1 },
|
|
421
|
-
},
|
|
422
|
-
),
|
|
423
|
-
).toBe(
|
|
424
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat&h=1&w=1',
|
|
425
|
-
);
|
|
426
|
-
|
|
427
|
-
expect(
|
|
428
|
-
getCdnFromS3Url(
|
|
429
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
430
|
-
{
|
|
431
|
-
transformation: { devicePixelRatio: 2 },
|
|
432
|
-
},
|
|
433
|
-
),
|
|
434
|
-
).toBe(
|
|
435
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat&dpr=2',
|
|
436
|
-
);
|
|
437
|
-
|
|
438
|
-
expect(
|
|
439
|
-
getCdnFromS3Url(
|
|
440
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
441
|
-
{
|
|
442
|
-
transformation: { quality: 75 },
|
|
443
|
-
},
|
|
444
|
-
),
|
|
445
|
-
).toBe(
|
|
446
|
-
'https://sparted.imgix.fr/prod/check/path/to/something?auto=compress%2Cformat&q=75',
|
|
447
|
-
);
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
it('Twicpics - should handle params', () => {
|
|
451
|
-
const domain = 'https://sparted.twicpics.fr';
|
|
452
|
-
const instanceMapper: InstanceMapper = (instanceId) => `/prod/${instanceId}`;
|
|
453
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
454
|
-
domain,
|
|
455
|
-
instanceMapper,
|
|
456
|
-
transformationQueries: twicpicsTransformationQueries,
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
const getCdnFromS3Url = getCdnFromS3UrlFactory({
|
|
460
|
-
getCdnUrl,
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
expect(
|
|
464
|
-
getCdnFromS3Url(
|
|
465
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
466
|
-
{
|
|
467
|
-
transformation: { fit: 'crop', height: 1, width: 1 },
|
|
468
|
-
},
|
|
469
|
-
),
|
|
470
|
-
).toBe(
|
|
471
|
-
'https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/quality=70/crop=1x1',
|
|
472
|
-
);
|
|
473
|
-
|
|
474
|
-
expect(
|
|
475
|
-
getCdnFromS3Url(
|
|
476
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
477
|
-
{
|
|
478
|
-
transformation: { fit: 'contain', height: 1, width: 1 },
|
|
479
|
-
},
|
|
480
|
-
),
|
|
481
|
-
).toBe(
|
|
482
|
-
'https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/quality=70/contain=1x1',
|
|
483
|
-
);
|
|
484
|
-
|
|
485
|
-
expect(
|
|
486
|
-
getCdnFromS3Url(
|
|
487
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
488
|
-
{
|
|
489
|
-
transformation: { width: 1 },
|
|
490
|
-
},
|
|
491
|
-
),
|
|
492
|
-
).toBe(
|
|
493
|
-
'https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/quality=70/cover=1x-',
|
|
494
|
-
);
|
|
495
|
-
|
|
496
|
-
expect(
|
|
497
|
-
getCdnFromS3Url(
|
|
498
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
499
|
-
{
|
|
500
|
-
transformation: { width: 1, output: 'webp' },
|
|
501
|
-
},
|
|
502
|
-
),
|
|
503
|
-
).toBe(
|
|
504
|
-
'https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/quality=70/cover=1x-/output=webp',
|
|
505
|
-
);
|
|
506
|
-
|
|
507
|
-
expect(
|
|
508
|
-
getCdnFromS3Url(
|
|
509
|
-
'https://sparted-prod-check.s3.eu-west-1/path/to/something',
|
|
510
|
-
{
|
|
511
|
-
transformation: { fit: 'contain', height: 300, width: 200, output: 'png' },
|
|
512
|
-
},
|
|
513
|
-
),
|
|
514
|
-
).toBe(
|
|
515
|
-
'https://sparted.twicpics.fr/prod/check/path/to/something?twic=v1/quality=70/contain=200x300/output=png',
|
|
516
|
-
);
|
|
517
|
-
});
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
describe('cacheVersionQuery', () => {
|
|
521
|
-
it('should return cache version query', () => {
|
|
522
|
-
expect(genCacheVersionQuery(2)).toBe('v=2');
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
it('should return empty string if cache version is not provided', () => {
|
|
526
|
-
expect(genCacheVersionQuery()).toBe('');
|
|
527
|
-
});
|
|
528
|
-
});
|
package/src/cdn/cdn.factory.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { buildSearchParams } from '../http/build-search-params';
|
|
2
|
-
import type { CdnConfig, CdnType, TransformationQueries, TwicpicsTransformationChain } from './types';
|
|
3
|
-
import { getCdnFromS3UrlFactory } from './utils/get-cdn-from-s3-url.util';
|
|
4
|
-
import { getCdnUrlFactory } from './utils/get-cdn-url.util';
|
|
5
|
-
import { twicpicsTransformationChainToString } from './utils/twicpics-transformations.util';
|
|
6
|
-
|
|
7
|
-
export const imgixTransformationQueries: TransformationQueries = ({
|
|
8
|
-
fit,
|
|
9
|
-
width,
|
|
10
|
-
height,
|
|
11
|
-
quality,
|
|
12
|
-
compress = true,
|
|
13
|
-
devicePixelRatio,
|
|
14
|
-
}) => {
|
|
15
|
-
const params = {
|
|
16
|
-
auto: compress ? 'compress,format' : undefined,
|
|
17
|
-
fit: fit === 'crop' ? 'crop' : undefined,
|
|
18
|
-
dpr: Number.isFinite(devicePixelRatio) ? devicePixelRatio : undefined,
|
|
19
|
-
h: Number.isFinite(height) ? height : undefined,
|
|
20
|
-
w: Number.isFinite(width) ? width : undefined,
|
|
21
|
-
q: quality !== undefined && quality >= 0 && quality <= 100 ? quality : undefined,
|
|
22
|
-
};
|
|
23
|
-
const searchParams = buildSearchParams(params).toString();
|
|
24
|
-
|
|
25
|
-
return searchParams ? `${searchParams}` : '';
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const twicpicsTransformationQueries: TransformationQueries = (params) => {
|
|
29
|
-
const quality = params.quality || 70;
|
|
30
|
-
const transformations: TwicpicsTransformationChain = [['quality', quality]];
|
|
31
|
-
const dpr = params.devicePixelRatio || 1;
|
|
32
|
-
|
|
33
|
-
const width = params.width ? Math.round(params.width * dpr) : '-';
|
|
34
|
-
const height = params.height ? Math.round(params.height * dpr) : '-';
|
|
35
|
-
const fit = params.fit || 'cover';
|
|
36
|
-
|
|
37
|
-
if (params.width !== undefined || params.height !== undefined) {
|
|
38
|
-
transformations.push([fit, `${width}x${height}`]);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (params.output !== undefined) {
|
|
42
|
-
transformations.push(['output', params.output]);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return twicpicsTransformationChainToString(transformations);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param type cdn provider: 'twicpics' | 'imgix'
|
|
51
|
-
* @param domain provider domain
|
|
52
|
-
* @param instanceMapper domain + the result of the instanceMapper will form the base path
|
|
53
|
-
* @param cacheVersion
|
|
54
|
-
* @returns \{ getCdnUrl, transformationQueries \}
|
|
55
|
-
*/
|
|
56
|
-
export const createCdn = <T extends CdnType>({ type, domain, instanceMapper, cacheVersion }: CdnConfig<T>) => {
|
|
57
|
-
const getCdnUrl = getCdnUrlFactory({
|
|
58
|
-
domain,
|
|
59
|
-
instanceMapper,
|
|
60
|
-
transformationQueries: type === 'imgix' ? imgixTransformationQueries : twicpicsTransformationQueries,
|
|
61
|
-
cacheVersion,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
getCdnUrl,
|
|
66
|
-
getCdnFromS3Url: getCdnFromS3UrlFactory({
|
|
67
|
-
getCdnUrl,
|
|
68
|
-
}),
|
|
69
|
-
};
|
|
70
|
-
};
|
package/src/cdn/index.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export type BaseUrlMapperFunc = (instanceId: string) => string;
|
|
2
|
-
|
|
3
|
-
export type Transformation = {
|
|
4
|
-
fit?: 'crop' | 'contain';
|
|
5
|
-
width?: number;
|
|
6
|
-
height?: number;
|
|
7
|
-
devicePixelRatio?: number;
|
|
8
|
-
quality?: number;
|
|
9
|
-
/**
|
|
10
|
-
* Only for imgix transformations. Default is true.
|
|
11
|
-
*/
|
|
12
|
-
compress?: boolean;
|
|
13
|
-
output?: 'jpeg' | 'png' | 'webp' | 'image';
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type CdnParams = {
|
|
17
|
-
asThumbnail?: boolean;
|
|
18
|
-
transformation?: Transformation;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type TransformationQueries = (params: Transformation) => string;
|
|
22
|
-
|
|
23
|
-
type TwicpicsOutputTransformation = ['output', Transformation['output']];
|
|
24
|
-
|
|
25
|
-
type TwicpicsFitTransformation = ['cover' | 'crop' | 'contain', string] | ['quality', number];
|
|
26
|
-
|
|
27
|
-
export type TwicpicsTransformation = TwicpicsOutputTransformation | TwicpicsFitTransformation;
|
|
28
|
-
|
|
29
|
-
export type TwicpicsTransformationChain = TwicpicsTransformation[];
|
|
30
|
-
|
|
31
|
-
export type GetCdnUrl = (instanceId: string, path: `/${string}`, params?: CdnParams) => string;
|
|
32
|
-
|
|
33
|
-
export type GetCdnFromS3Url = (url: string, params?: CdnParams) => string;
|
|
34
|
-
|
|
35
|
-
export type InstanceMapper = (instanceId: string) => string;
|
|
36
|
-
|
|
37
|
-
export type CdnType = 'twicpics' | 'imgix';
|
|
38
|
-
|
|
39
|
-
export type CdnConfig<T extends CdnType> = {
|
|
40
|
-
type: T;
|
|
41
|
-
domain: `https://${string}`;
|
|
42
|
-
instanceMapper: InstanceMapper;
|
|
43
|
-
cacheVersion?: T extends 'twicpics' ? number : undefined;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type Cdn = {
|
|
47
|
-
getCdnUrl: GetCdnUrl;
|
|
48
|
-
getCdnFromS3Url: GetCdnFromS3Url;
|
|
49
|
-
};
|
package/src/cdn/types/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './cdn-factory.type';
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
type ExtractInfoFromUrl = (url: string) =>
|
|
2
|
-
| {
|
|
3
|
-
instanceId: string;
|
|
4
|
-
path: `/${string}`;
|
|
5
|
-
}
|
|
6
|
-
| undefined;
|
|
7
|
-
|
|
8
|
-
const S3_URL_RE = /https:\/\/sparted-prod-([^.]+)\.s3(\.eu-west-1)?(\.amazonaws\.com)?(\.fr-par\.scw\.cloud)?(\/[^?]+)/;
|
|
9
|
-
|
|
10
|
-
export const extractInfoFromUrl: ExtractInfoFromUrl = (url) => {
|
|
11
|
-
if (typeof url !== 'string') {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const matchS3Url = url.match(S3_URL_RE);
|
|
16
|
-
|
|
17
|
-
if (!matchS3Url) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const instanceId = matchS3Url[1];
|
|
22
|
-
const path = matchS3Url[5] as `/${string}`;
|
|
23
|
-
|
|
24
|
-
return { instanceId, path };
|
|
25
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { GetCdnFromS3Url, GetCdnUrl } from '../types';
|
|
2
|
-
import { extractInfoFromUrl } from './extract-info-from-url.util';
|
|
3
|
-
|
|
4
|
-
type FactoryConfig = {
|
|
5
|
-
getCdnUrl: GetCdnUrl;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export function getCdnFromS3UrlFactory(config: FactoryConfig): GetCdnFromS3Url {
|
|
9
|
-
return (url, params) => {
|
|
10
|
-
const { getCdnUrl } = config;
|
|
11
|
-
|
|
12
|
-
const info = extractInfoFromUrl(url);
|
|
13
|
-
if (info === undefined) {
|
|
14
|
-
return url;
|
|
15
|
-
}
|
|
16
|
-
const { instanceId, path } = info;
|
|
17
|
-
|
|
18
|
-
return getCdnUrl(instanceId, path, params);
|
|
19
|
-
};
|
|
20
|
-
}
|