@agnostack/next-shopify 1.14.1 → 1.15.0-beta.2
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/CHANGELOG.md +14 -0
- package/dist/lib/handlers/api/auth.js +11 -15
- package/dist/lib/handlers/api/auth.js.map +1 -1
- package/dist/lib/handlers/api/billing.d.ts.map +1 -1
- package/dist/lib/handlers/api/billing.js +9 -12
- package/dist/lib/handlers/api/billing.js.map +1 -1
- package/dist/lib/handlers/api/callback.js +33 -37
- package/dist/lib/handlers/api/callback.js.map +1 -1
- package/dist/lib/handlers/api/index.js +7 -25
- package/dist/lib/handlers/api/index.js.map +1 -1
- package/dist/lib/handlers/api/uninstall.d.ts.map +1 -1
- package/dist/lib/handlers/api/uninstall.js +8 -11
- package/dist/lib/handlers/api/uninstall.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/appInstallation.js +7 -11
- package/dist/lib/handlers/api/verifiable/appInstallation.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/graph.d.ts.map +1 -1
- package/dist/lib/handlers/api/verifiable/graph.js +22 -25
- package/dist/lib/handlers/api/verifiable/graph.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/index.js +5 -21
- package/dist/lib/handlers/api/verifiable/index.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/proxy.d.ts.map +1 -1
- package/dist/lib/handlers/api/verifiable/proxy.js +32 -38
- package/dist/lib/handlers/api/verifiable/proxy.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/rest.d.ts.map +1 -1
- package/dist/lib/handlers/api/verifiable/rest.js +19 -22
- package/dist/lib/handlers/api/verifiable/rest.js.map +1 -1
- package/dist/lib/handlers/api/verifiable/token.js +23 -26
- package/dist/lib/handlers/api/verifiable/token.js.map +1 -1
- package/dist/lib/handlers/api/webhook.d.ts.map +1 -1
- package/dist/lib/handlers/api/webhook.js +9 -12
- package/dist/lib/handlers/api/webhook.js.map +1 -1
- package/dist/lib/handlers/index.js +2 -18
- package/dist/lib/handlers/index.js.map +1 -1
- package/dist/lib/handlers/ssr/index.js +2 -18
- package/dist/lib/handlers/ssr/index.js.map +1 -1
- package/dist/lib/handlers/ssr/protect.js +17 -24
- package/dist/lib/handlers/ssr/protect.js.map +1 -1
- package/dist/lib/handlers/ssr/wrap.js +6 -10
- package/dist/lib/handlers/ssr/wrap.js.map +1 -1
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +5 -25
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/utils/billing.js +18 -23
- package/dist/lib/utils/billing.js.map +1 -1
- package/dist/lib/utils/crypto.js +15 -25
- package/dist/lib/utils/crypto.js.map +1 -1
- package/dist/lib/utils/firebase.js +17 -29
- package/dist/lib/utils/firebase.js.map +1 -1
- package/dist/lib/utils/headers.js +6 -13
- package/dist/lib/utils/headers.js.map +1 -1
- package/dist/lib/utils/index.d.ts +0 -2
- package/dist/lib/utils/index.js +8 -26
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/session.js +59 -64
- package/dist/lib/utils/session.js.map +1 -1
- package/dist/lib/utils/shopify-api-js/oauth.js +16 -23
- package/dist/lib/utils/shopify-api-js/oauth.js.map +1 -1
- package/dist/lib/utils/shopify.js +25 -37
- package/dist/lib/utils/shopify.js.map +1 -1
- package/dist/lib/utils/token.d.ts +1 -1
- package/dist/lib/utils/token.js +11 -15
- package/dist/lib/utils/token.js.map +1 -1
- package/dist/lib/withShopify.js +77 -81
- package/dist/lib/withShopify.js.map +1 -1
- package/dist/react/hooks/index.js +1 -17
- package/dist/react/hooks/index.js.map +1 -1
- package/dist/react/hooks/useVerification.js +7 -11
- package/dist/react/hooks/useVerification.js.map +1 -1
- package/dist/react/index.js +1 -17
- package/dist/react/index.js.map +1 -1
- package/dist/runtime/index.js +1 -17
- package/dist/runtime/index.js.map +1 -1
- package/dist/shared/constants.js +11 -15
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/datetime.js +83 -110
- package/dist/shared/datetime.js.map +1 -1
- package/dist/shared/display.js +154 -236
- package/dist/shared/display.js.map +1 -1
- package/dist/shared/errors.d.ts +0 -5
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +5 -34
- package/dist/shared/errors.js.map +1 -1
- package/dist/shared/graph.js +11 -14
- package/dist/shared/graph.js.map +1 -1
- package/dist/shared/index.js +10 -26
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/match.js +17 -25
- package/dist/shared/match.js.map +1 -1
- package/dist/shared/request.d.ts +5 -0
- package/dist/shared/request.d.ts.map +1 -1
- package/dist/shared/request.js +32 -15
- package/dist/shared/request.js.map +1 -1
- package/dist/shared/shopify.d.ts +1 -6
- package/dist/shared/shopify.d.ts.map +1 -1
- package/dist/shared/shopify.js +21 -54
- package/dist/shared/shopify.js.map +1 -1
- package/dist/shared/subtlecrypto.js +13 -39
- package/dist/shared/subtlecrypto.js.map +1 -1
- package/dist/shared/verification.js +23 -29
- package/dist/shared/verification.js.map +1 -1
- package/dist/umd/lib/handlers/api/auth.d.ts +2 -0
- package/dist/umd/lib/handlers/api/auth.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/billing.d.ts +2 -0
- package/dist/umd/lib/handlers/api/billing.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/callback.d.ts +2 -0
- package/dist/umd/lib/handlers/api/callback.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/index.d.ts +10 -0
- package/dist/umd/lib/handlers/api/index.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/types.d.ts +1 -0
- package/dist/umd/lib/handlers/api/types.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/uninstall.d.ts +2 -0
- package/dist/umd/lib/handlers/api/uninstall.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/verifiable/appInstallation.d.ts +2 -0
- package/dist/umd/lib/handlers/api/verifiable/appInstallation.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/verifiable/graph.d.ts +2 -0
- package/dist/umd/lib/handlers/api/verifiable/graph.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/verifiable/index.d.ts +6 -0
- package/dist/umd/lib/handlers/api/verifiable/index.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/verifiable/proxy.d.ts +2 -0
- package/dist/umd/lib/handlers/api/verifiable/proxy.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/verifiable/rest.d.ts +2 -0
- package/dist/umd/lib/handlers/api/verifiable/rest.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/verifiable/token.d.ts +4 -0
- package/dist/umd/lib/handlers/api/verifiable/token.d.ts.map +1 -0
- package/dist/umd/lib/handlers/api/webhook.d.ts +2 -0
- package/dist/umd/lib/handlers/api/webhook.d.ts.map +1 -0
- package/dist/umd/lib/handlers/index.d.ts +3 -0
- package/dist/umd/lib/handlers/index.d.ts.map +1 -0
- package/dist/umd/lib/handlers/ssr/index.d.ts +3 -0
- package/dist/umd/lib/handlers/ssr/index.d.ts.map +1 -0
- package/dist/umd/lib/handlers/ssr/protect.d.ts +16 -0
- package/dist/umd/lib/handlers/ssr/protect.d.ts.map +1 -0
- package/dist/umd/lib/handlers/ssr/types.d.ts +1 -0
- package/dist/umd/lib/handlers/ssr/types.d.ts.map +1 -0
- package/dist/umd/lib/handlers/ssr/wrap.d.ts +9 -0
- package/dist/umd/lib/handlers/ssr/wrap.d.ts.map +1 -0
- package/dist/umd/lib/handlers/types.d.ts +1 -0
- package/dist/umd/lib/handlers/types.d.ts.map +1 -0
- package/dist/umd/lib/index.d.ts +6 -0
- package/dist/umd/lib/index.d.ts.map +1 -0
- package/dist/umd/lib/types.d.ts +1 -0
- package/dist/umd/lib/types.d.ts.map +1 -0
- package/dist/umd/lib/utils/billing.d.ts +24 -0
- package/dist/umd/lib/utils/billing.d.ts.map +1 -0
- package/dist/umd/lib/utils/crypto.d.ts +22 -0
- package/dist/umd/lib/utils/crypto.d.ts.map +1 -0
- package/dist/umd/lib/utils/firebase.d.ts +25 -0
- package/dist/umd/lib/utils/firebase.d.ts.map +1 -0
- package/dist/umd/lib/utils/headers.d.ts +5 -0
- package/dist/umd/lib/utils/headers.d.ts.map +1 -0
- package/dist/umd/lib/utils/index.d.ts +9 -0
- package/dist/umd/lib/utils/index.d.ts.map +1 -0
- package/dist/umd/lib/utils/session.d.ts +41 -0
- package/dist/umd/lib/utils/session.d.ts.map +1 -0
- package/dist/umd/lib/utils/shopify-api-js/oauth.d.ts +9 -0
- package/dist/umd/lib/utils/shopify-api-js/oauth.d.ts.map +1 -0
- package/dist/umd/lib/utils/shopify.d.ts +26 -0
- package/dist/umd/lib/utils/shopify.d.ts.map +1 -0
- package/dist/umd/lib/utils/token.d.ts +19 -0
- package/dist/umd/lib/utils/token.d.ts.map +1 -0
- package/dist/umd/lib/utils/types.d.ts +1 -0
- package/dist/umd/lib/utils/types.d.ts.map +1 -0
- package/dist/umd/lib/withShopify.d.ts +6 -0
- package/dist/umd/lib/withShopify.d.ts.map +1 -0
- package/dist/umd/react/hooks/index.d.ts +2 -0
- package/dist/umd/react/hooks/index.d.ts.map +1 -0
- package/dist/umd/react/hooks/useVerification.d.ts +8 -0
- package/dist/umd/react/hooks/useVerification.d.ts.map +1 -0
- package/dist/umd/react/index.d.ts +2 -0
- package/dist/umd/react/index.d.ts.map +1 -0
- package/dist/umd/react/types.d.ts +1 -0
- package/dist/umd/react/types.d.ts.map +1 -0
- package/dist/umd/runtime/index.d.ts +2 -0
- package/dist/umd/runtime/index.d.ts.map +1 -0
- package/dist/umd/runtime/types.d.ts +1 -0
- package/dist/umd/runtime/types.d.ts.map +1 -0
- package/dist/umd/shared/constants.d.ts +211 -0
- package/dist/umd/shared/constants.d.ts.map +1 -0
- package/dist/umd/shared/datetime.d.ts +96 -0
- package/dist/umd/shared/datetime.d.ts.map +1 -0
- package/dist/umd/shared/display.d.ts +102 -0
- package/dist/umd/shared/display.d.ts.map +1 -0
- package/dist/umd/shared/errors.d.ts +19 -0
- package/dist/umd/shared/errors.d.ts.map +1 -0
- package/dist/umd/shared/graph.d.ts +24 -0
- package/dist/umd/shared/graph.d.ts.map +1 -0
- package/dist/umd/shared/index.d.ts +11 -0
- package/dist/umd/shared/index.d.ts.map +1 -0
- package/dist/umd/shared/match.d.ts +6 -0
- package/dist/umd/shared/match.d.ts.map +1 -0
- package/dist/umd/shared/request.d.ts +16 -0
- package/dist/umd/shared/request.d.ts.map +1 -0
- package/dist/umd/shared/shopify.d.ts +31 -0
- package/dist/umd/shared/shopify.d.ts.map +1 -0
- package/dist/umd/shared/subtlecrypto.d.ts +41 -0
- package/dist/umd/shared/subtlecrypto.d.ts.map +1 -0
- package/dist/umd/shared/types.d.ts +1 -0
- package/dist/umd/shared/types.d.ts.map +1 -0
- package/dist/umd/shared/verification.d.ts +24 -0
- package/dist/umd/shared/verification.d.ts.map +1 -0
- package/dist/umd/umd-verification.js +968 -0
- package/dist/umd/umd-verification.js.map +1 -0
- package/dist/umd/verification/errors.d.ts +6 -0
- package/dist/umd/verification/errors.d.ts.map +1 -0
- package/dist/umd/verification/index.d.ts +2 -0
- package/dist/umd/verification/index.d.ts.map +1 -0
- package/dist/umd/verification/rawbody.d.ts.map +1 -0
- package/dist/umd/verification/types.d.ts +1 -0
- package/dist/umd/verification/types.d.ts.map +1 -0
- package/dist/umd/verification/verification.d.ts.map +1 -0
- package/dist/verification/errors.d.ts +6 -0
- package/dist/verification/errors.d.ts.map +1 -0
- package/dist/verification/errors.js +22 -0
- package/dist/verification/errors.js.map +1 -0
- package/dist/verification/index.d.ts +2 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +2 -0
- package/dist/verification/index.js.map +1 -0
- package/dist/verification/rawbody.d.ts +2 -0
- package/dist/verification/rawbody.d.ts.map +1 -0
- package/dist/{lib/utils → verification}/rawbody.js +4 -10
- package/dist/verification/rawbody.js.map +1 -0
- package/dist/verification/types.d.ts +1 -0
- package/dist/verification/types.d.ts.map +1 -0
- package/dist/verification/types.js +1 -0
- package/dist/verification/types.js.map +1 -0
- package/dist/verification/verification.d.ts +8 -0
- package/dist/verification/verification.d.ts.map +1 -0
- package/dist/{lib/utils → verification}/verification.js +20 -21
- package/dist/verification/verification.js.map +1 -0
- package/node_modules/browser-monads-ts/LICENSE +21 -0
- package/node_modules/browser-monads-ts/README.md +46 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.cjs.js +2 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.cjs.js.map +1 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.es.js +12 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.es.js.map +1 -0
- package/node_modules/browser-monads-ts/dist/index.d.ts +5 -0
- package/node_modules/browser-monads-ts/dist/index.d.ts.map +1 -0
- package/node_modules/browser-monads-ts/package.json +79 -0
- package/node_modules/bytes/History.md +97 -0
- package/node_modules/bytes/LICENSE +23 -0
- package/node_modules/bytes/Readme.md +152 -0
- package/node_modules/bytes/index.js +170 -0
- package/node_modules/bytes/package.json +42 -0
- package/node_modules/depd/History.md +103 -0
- package/node_modules/depd/LICENSE +22 -0
- package/node_modules/depd/Readme.md +280 -0
- package/node_modules/depd/index.js +538 -0
- package/node_modules/depd/lib/browser/index.js +77 -0
- package/node_modules/depd/package.json +45 -0
- package/node_modules/http-errors/HISTORY.md +180 -0
- package/node_modules/http-errors/LICENSE +23 -0
- package/node_modules/http-errors/README.md +169 -0
- package/node_modules/http-errors/index.js +289 -0
- package/node_modules/http-errors/package.json +50 -0
- package/node_modules/iconv-lite/Changelog.md +162 -0
- package/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules/iconv-lite/README.md +156 -0
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +555 -0
- package/node_modules/iconv-lite/encodings/dbcs-data.js +176 -0
- package/node_modules/iconv-lite/encodings/index.js +22 -0
- package/node_modules/iconv-lite/encodings/internal.js +188 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules/iconv-lite/encodings/sbcs-data.js +174 -0
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +55 -0
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules/iconv-lite/encodings/utf16.js +177 -0
- package/node_modules/iconv-lite/encodings/utf7.js +290 -0
- package/node_modules/iconv-lite/lib/bom-handling.js +52 -0
- package/node_modules/iconv-lite/lib/extend-node.js +217 -0
- package/node_modules/iconv-lite/lib/index.d.ts +24 -0
- package/node_modules/iconv-lite/lib/index.js +153 -0
- package/node_modules/iconv-lite/lib/streams.js +121 -0
- package/node_modules/iconv-lite/package.json +46 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/nothing-mock/LICENSE +21 -0
- package/node_modules/nothing-mock/README.md +266 -0
- package/node_modules/nothing-mock/dist/nothing-mock.es.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.es.js.map +1 -0
- package/node_modules/nothing-mock/dist/nothing-mock.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.js.map +1 -0
- package/node_modules/nothing-mock/dist/nothing-mock.modern.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.modern.js.map +1 -0
- package/node_modules/nothing-mock/dist/nothing-mock.umd.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.umd.js.map +1 -0
- package/node_modules/nothing-mock/index.d.ts +6 -0
- package/node_modules/nothing-mock/package.json +29 -0
- package/node_modules/nothing-mock/src/index.js +15 -0
- package/node_modules/raw-body/HISTORY.md +308 -0
- package/node_modules/raw-body/LICENSE +22 -0
- package/node_modules/raw-body/README.md +223 -0
- package/node_modules/raw-body/SECURITY.md +24 -0
- package/node_modules/raw-body/index.d.ts +87 -0
- package/node_modules/raw-body/index.js +336 -0
- package/node_modules/raw-body/package.json +49 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/setprototypeof/LICENSE +13 -0
- package/node_modules/setprototypeof/README.md +31 -0
- package/node_modules/setprototypeof/index.d.ts +2 -0
- package/node_modules/setprototypeof/index.js +17 -0
- package/node_modules/setprototypeof/package.json +38 -0
- package/node_modules/setprototypeof/test/index.js +24 -0
- package/node_modules/statuses/HISTORY.md +82 -0
- package/node_modules/statuses/LICENSE +23 -0
- package/node_modules/statuses/README.md +136 -0
- package/node_modules/statuses/codes.json +65 -0
- package/node_modules/statuses/index.js +146 -0
- package/node_modules/statuses/package.json +49 -0
- package/node_modules/toidentifier/HISTORY.md +9 -0
- package/node_modules/toidentifier/LICENSE +21 -0
- package/node_modules/toidentifier/README.md +61 -0
- package/node_modules/toidentifier/index.js +32 -0
- package/node_modules/toidentifier/package.json +38 -0
- package/node_modules/unpipe/HISTORY.md +4 -0
- package/node_modules/unpipe/LICENSE +22 -0
- package/node_modules/unpipe/README.md +43 -0
- package/node_modules/unpipe/index.js +69 -0
- package/node_modules/unpipe/package.json +27 -0
- package/package.json +22 -4
- package/dist/lib/utils/rawbody.d.ts.map +0 -1
- package/dist/lib/utils/rawbody.js.map +0 -1
- package/dist/lib/utils/verification.d.ts.map +0 -1
- package/dist/lib/utils/verification.js.map +0 -1
- /package/dist/{lib/utils → umd/verification}/rawbody.d.ts +0 -0
- /package/dist/{lib/utils → umd/verification}/verification.d.ts +0 -0
package/dist/shared/display.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uppercase = exports.unsnakecase = exports.snakecase = exports.undashcase = exports.dashcase = exports.zencase = exports.replaceSpaces = exports.freeze = exports.isHTML = exports.objectToSortedString = exports.compareEntryKeys = exports.compareString = exports.compareNumber = exports.stringEmpty = exports.stringNotEmpty = exports.stringEmptyOnly = exports.stringNotEmptyOnly = exports.cleanObject = exports.objectContainsAnyValue = exports.nullable = exports.objectNotEmpty = exports.objectEmpty = exports.ensureObject = exports.findLastMatch = exports.arrayNotEmpty = exports.arrayEmpty = exports.ensureArraySet = exports.ensureArray = exports.ensureNumericConstrained = exports.ensureNumericNegatable = exports.ensureNumericOnly = exports.ensureNumeric = exports.isNumericNegatable = exports.isNumericOnly = exports.ensureAlphaNumeric = exports.ensureStringClean = exports.ensureStringAscii = exports.ensureStringOnly = exports.ensureString = exports.safeParse = exports.safeTrim = exports.isTypeEnhanced = exports.isType = exports.isSet = exports.isArray = exports.arrayRandomItem = exports.arrayRandom = exports.nextRandom = exports.random = exports.normalizeShopifyId = void 0;
|
|
4
|
-
exports.getInteger = exports.getGUID = exports.appendQuery = exports.arraysMatch = exports.arrayIncludesAll = exports.querystringToObject = exports.parseProject = exports.parseProjectName = exports.parseKeywordGroups = exports.parseKeywords = exports.isTrue = exports.arrayToObject = exports.normalizeArray = exports.combineCommas = exports.splitCommas = exports.wrappedEncode = exports.ensureExtension = exports.ensureTrailingSlash = exports.ensureLeadingSlash = exports.removeLeadingTrailingSlash = exports.removeTrailingSlash = exports.removeLeadingTrailingQuotes = exports.removeLeadingSlash = exports.titleCase = exports.camelCase = exports.capitalize = exports.slugify = exports.lowercase = void 0;
|
|
5
1
|
/* eslint-disable no-use-before-define */
|
|
6
|
-
|
|
2
|
+
import { v4 as uuidV4 } from 'uuid';
|
|
7
3
|
// #region lib-core
|
|
8
4
|
// TODO!!!: keep in sync between next-shopify and lib-core (and lib-utils-js at bottom)
|
|
9
|
-
const normalizeShopifyId = (shopifyData) => {
|
|
5
|
+
export const normalizeShopifyId = (shopifyData) => {
|
|
10
6
|
var _a, _b;
|
|
11
|
-
const isString =
|
|
7
|
+
const isString = isType(shopifyData, 'string');
|
|
12
8
|
if (isString && !shopifyData.startsWith('gid:')) {
|
|
13
|
-
if (!
|
|
9
|
+
if (!isNumericOnly(shopifyData)) {
|
|
14
10
|
return {};
|
|
15
11
|
}
|
|
16
12
|
return {
|
|
@@ -19,40 +15,37 @@ const normalizeShopifyId = (shopifyData) => {
|
|
|
19
15
|
}
|
|
20
16
|
const { id: _entityId, legacyResourceId } = isString
|
|
21
17
|
? { id: shopifyData }
|
|
22
|
-
:
|
|
23
|
-
if (
|
|
18
|
+
: ensureObject(shopifyData);
|
|
19
|
+
if (stringEmpty(_entityId) && stringEmpty(legacyResourceId)) {
|
|
24
20
|
return {};
|
|
25
21
|
}
|
|
26
|
-
const entity_id =
|
|
22
|
+
const entity_id = ensureString(_entityId);
|
|
27
23
|
const { entity_type, parsedId } = (_b = (_a = entity_id.match(/^gid:\/\/shopify\/(?<entity_type>.*)\/(?<parsedId>[0-9]+).*$/)) === null || _a === void 0 ? void 0 : _a.groups) !== null && _b !== void 0 ? _b : {};
|
|
28
|
-
const id =
|
|
29
|
-
const hasEntityId =
|
|
30
|
-
const hasEntityType =
|
|
31
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({},
|
|
24
|
+
const id = ensureString(parsedId || legacyResourceId);
|
|
25
|
+
const hasEntityId = stringNotEmpty(entity_id);
|
|
26
|
+
const hasEntityType = stringNotEmpty(entity_type);
|
|
27
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, stringNotEmpty(id) && { id }), hasEntityId && { entity_id }), hasEntityType && { entity_type }), (hasEntityId && hasEntityType) && {
|
|
32
28
|
gid: `gid://shopify/${entity_type}/${entity_id}`,
|
|
33
29
|
});
|
|
34
30
|
};
|
|
35
|
-
|
|
36
|
-
const random = (max = 100, min = 1) => {
|
|
31
|
+
export const random = (max = 100, min = 1) => {
|
|
37
32
|
const floor = Math.min(max, min);
|
|
38
33
|
return Math.floor(Math.random() * (max - floor + 1)) + floor;
|
|
39
34
|
};
|
|
40
|
-
|
|
41
|
-
const nextRandom = (max = 100, min = 1) => {
|
|
35
|
+
export const nextRandom = (max = 100, min = 1) => {
|
|
42
36
|
const maximum = Math.max(max, 0);
|
|
43
37
|
const minimum = Math.max(min, 0);
|
|
44
38
|
let randomNumber = maximum;
|
|
45
39
|
if (maximum > minimum) {
|
|
46
40
|
do {
|
|
47
|
-
randomNumber =
|
|
48
|
-
} while (randomNumber ===
|
|
49
|
-
|
|
41
|
+
randomNumber = random(maximum, minimum);
|
|
42
|
+
} while (randomNumber === nextRandom.last);
|
|
43
|
+
nextRandom.last = randomNumber;
|
|
50
44
|
}
|
|
51
45
|
return randomNumber;
|
|
52
46
|
};
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
const values = (0, exports.ensureArray)(_values);
|
|
47
|
+
export const arrayRandom = (_values, _max = 1) => {
|
|
48
|
+
const values = ensureArray(_values);
|
|
56
49
|
const valuesLength = values.length;
|
|
57
50
|
const maxLength = Math.min(_max, valuesLength);
|
|
58
51
|
if (valuesLength <= maxLength) {
|
|
@@ -61,60 +54,53 @@ const arrayRandom = (_values, _max = 1) => {
|
|
|
61
54
|
const arrayLength = valuesLength - 1;
|
|
62
55
|
const randomValues = [];
|
|
63
56
|
do {
|
|
64
|
-
const newVal = values[
|
|
57
|
+
const newVal = values[nextRandom(arrayLength, 0)];
|
|
65
58
|
if (!randomValues.includes(newVal)) {
|
|
66
59
|
randomValues.push(newVal);
|
|
67
60
|
}
|
|
68
61
|
} while (randomValues.length < maxLength);
|
|
69
62
|
return randomValues;
|
|
70
63
|
};
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
exports.arrayRandomItem = arrayRandomItem;
|
|
74
|
-
const isArray = (value) => (
|
|
64
|
+
export const arrayRandomItem = (_values) => (arrayRandom(_values)[0]);
|
|
65
|
+
export const isArray = (value) => (
|
|
75
66
|
// eslint-disable-next-line eqeqeq
|
|
76
67
|
(value != undefined) && Array.isArray(value));
|
|
77
|
-
|
|
78
|
-
const isSet = (value) => (
|
|
68
|
+
export const isSet = (value) => (
|
|
79
69
|
// eslint-disable-next-line eqeqeq
|
|
80
70
|
(value != undefined) && (value instanceof Set));
|
|
81
|
-
|
|
82
|
-
const isType = (value, type) => (
|
|
71
|
+
export const isType = (value, type) => (
|
|
83
72
|
// eslint-disable-next-line eqeqeq, valid-typeof
|
|
84
73
|
(value != undefined) && (typeof value === type));
|
|
85
|
-
|
|
86
|
-
const isTypeEnhanced = (value, type) => {
|
|
74
|
+
export const isTypeEnhanced = (value, type) => {
|
|
87
75
|
switch (true) {
|
|
88
76
|
case (type === 'set'): {
|
|
89
|
-
return
|
|
77
|
+
return isSet(value);
|
|
90
78
|
}
|
|
91
79
|
case (type === 'array'): {
|
|
92
|
-
return (
|
|
93
|
-
!
|
|
80
|
+
return (isArray(value) &&
|
|
81
|
+
!isSet(value));
|
|
94
82
|
}
|
|
95
83
|
case (type === 'object'): {
|
|
96
|
-
return (
|
|
97
|
-
!
|
|
84
|
+
return (isType(value, type) &&
|
|
85
|
+
!isArray(value));
|
|
98
86
|
}
|
|
99
87
|
default: {
|
|
100
|
-
return
|
|
88
|
+
return isType(value, type);
|
|
101
89
|
}
|
|
102
90
|
}
|
|
103
91
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if ((0, exports.isType)(value, 'string')) {
|
|
92
|
+
export const safeTrim = (value) => {
|
|
93
|
+
if (isType(value, 'string')) {
|
|
107
94
|
// eslint-disable-next-line no-param-reassign
|
|
108
95
|
value = value.trim();
|
|
109
96
|
}
|
|
110
97
|
return value;
|
|
111
98
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if ((0, exports.isType)(value, 'string')) {
|
|
99
|
+
export const safeParse = (value, trim) => {
|
|
100
|
+
if (isType(value, 'string')) {
|
|
115
101
|
if (trim) {
|
|
116
102
|
// eslint-disable-next-line no-param-reassign
|
|
117
|
-
value =
|
|
103
|
+
value = safeTrim(value);
|
|
118
104
|
}
|
|
119
105
|
if (value.startsWith('{') || value.startsWith('[') || value.startsWith('"')) {
|
|
120
106
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -124,87 +110,65 @@ const safeParse = (value, trim) => {
|
|
|
124
110
|
// TODO: should this be value ?? {}
|
|
125
111
|
return value;
|
|
126
112
|
};
|
|
127
|
-
|
|
128
|
-
const ensureString = (string) => (string ? `${string}` : '');
|
|
129
|
-
exports.ensureString = ensureString;
|
|
113
|
+
export const ensureString = (string) => (string ? `${string}` : '');
|
|
130
114
|
// HMMM: what if 'string' is an object?
|
|
131
|
-
const ensureStringOnly = (string) => (
|
|
115
|
+
export const ensureStringOnly = (string) => (
|
|
132
116
|
// eslint-disable-next-line eqeqeq
|
|
133
117
|
(string != undefined) ? `${string}` : '');
|
|
134
|
-
|
|
135
|
-
const ensureStringAscii = (string) => (
|
|
118
|
+
export const ensureStringAscii = (string) => (
|
|
136
119
|
// eslint-disable-next-line no-control-regex
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const ensureStringClean = (string) => (
|
|
120
|
+
ensureStringOnly(string).replace(/[^\x00-\x7F]/g, ''));
|
|
121
|
+
export const ensureStringClean = (string) => (
|
|
140
122
|
// eslint-disable-next-line no-control-regex
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const ensureAlphaNumeric = (string) => (
|
|
123
|
+
ensureStringOnly(string).replace(/[^a-z0-9_-]/gi, ''));
|
|
124
|
+
export const ensureAlphaNumeric = (string) => (
|
|
144
125
|
// eslint-disable-next-line no-control-regex
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const isNumericOnly = (value) => {
|
|
126
|
+
ensureStringOnly(string).replace(/[^a-z0-9]/gi, ''));
|
|
127
|
+
export const isNumericOnly = (value) => {
|
|
148
128
|
var _a;
|
|
149
129
|
const [matched] = (_a = `${value}`.match(/^([0-9]+)$/)) !== null && _a !== void 0 ? _a : [];
|
|
150
130
|
// eslint-disable-next-line eqeqeq
|
|
151
131
|
return (matched != undefined);
|
|
152
132
|
};
|
|
153
|
-
|
|
154
|
-
const isNumericNegatable = (value) => {
|
|
133
|
+
export const isNumericNegatable = (value) => {
|
|
155
134
|
var _a;
|
|
156
135
|
const [matched] = (_a = `${value}`.match(/^(-?[0-9]+(\.[0-9]+)?)?$/)) !== null && _a !== void 0 ? _a : [];
|
|
157
136
|
// eslint-disable-next-line eqeqeq
|
|
158
137
|
return (matched != undefined);
|
|
159
138
|
};
|
|
160
|
-
exports.isNumericNegatable = isNumericNegatable;
|
|
161
139
|
// TODO: explore places using ensureNumeric to move to isNumericNegatable
|
|
162
|
-
const ensureNumeric = (string) => (Number(
|
|
163
|
-
|
|
164
|
-
const ensureNumericOnly = (string) => (Number((0, exports.ensureString)(string).replace(/[^0-9]/gi, '')));
|
|
165
|
-
exports.ensureNumericOnly = ensureNumericOnly;
|
|
140
|
+
export const ensureNumeric = (string) => (Number(ensureString(string).replace(/[^0-9.]/gi, '')));
|
|
141
|
+
export const ensureNumericOnly = (string) => (Number(ensureString(string).replace(/[^0-9]/gi, '')));
|
|
166
142
|
// TODO: update regex to handle negative number returns negative. Something like (?!\d\.)(-?\d+(\.\d)?)
|
|
167
|
-
const ensureNumericNegatable = (string) => (Number(
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
return Math.max(min, Math.min((0, exports.ensureNumeric)(value), max));
|
|
143
|
+
export const ensureNumericNegatable = (string) => (Number(ensureString(string).replace(/[^0-9.-]/gi, '')));
|
|
144
|
+
export const ensureNumericConstrained = (value, { min: _min = 0, max: _max = 100 } = {}) => {
|
|
145
|
+
const min = ensureNumericNegatable(_min);
|
|
146
|
+
const max = ensureNumericNegatable(_max);
|
|
147
|
+
return Math.max(min, Math.min(ensureNumeric(value), max));
|
|
173
148
|
};
|
|
174
|
-
|
|
175
|
-
const ensureArray = (array = []) => (
|
|
149
|
+
export const ensureArray = (array = []) => (
|
|
176
150
|
// eslint-disable-next-line no-nested-ternary
|
|
177
151
|
!array ? [] : Array.isArray(array) ? array : [array]);
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
exports.ensureArraySet = ensureArraySet;
|
|
181
|
-
const arrayEmpty = (array, disableEmptyString = false) => (
|
|
152
|
+
export const ensureArraySet = (arrayOrSet) => (ensureArray(isSet(arrayOrSet) ? [...arrayOrSet] : arrayOrSet));
|
|
153
|
+
export const arrayEmpty = (array, disableEmptyString = false) => (
|
|
182
154
|
// eslint-disable-next-line eqeqeq
|
|
183
|
-
!array || !array.length || (array.length === 1 && (array[0] == undefined || (disableEmptyString &&
|
|
184
|
-
|
|
185
|
-
const arrayNotEmpty = (array, disableEmptyString = false) => (
|
|
155
|
+
!array || !array.length || (array.length === 1 && (array[0] == undefined || (disableEmptyString && stringEmpty(array[0])))));
|
|
156
|
+
export const arrayNotEmpty = (array, disableEmptyString = false) => (
|
|
186
157
|
// eslint-disable-next-line eqeqeq
|
|
187
|
-
!
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
exports.findLastMatch = findLastMatch;
|
|
191
|
-
const ensureObject = (object) => (object !== null && object !== void 0 ? object : {});
|
|
192
|
-
exports.ensureObject = ensureObject;
|
|
158
|
+
!arrayEmpty(array) && array[0] != undefined && (!disableEmptyString || stringNotEmpty(array[0])));
|
|
159
|
+
export const findLastMatch = (array, filterCallback = (value) => (value)) => (ensureArray(array).filter(filterCallback).slice(-1)[0]);
|
|
160
|
+
export const ensureObject = (object) => (object !== null && object !== void 0 ? object : {});
|
|
193
161
|
// NOTE: this does not ensure !isType(string)
|
|
194
|
-
const objectEmpty = (object) => (!object || !Object.keys(object).length);
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
exports.objectNotEmpty = objectNotEmpty;
|
|
198
|
-
const nullable = (object) => ((!object || (object === 'null') || (object === undefined) || (object === null))
|
|
162
|
+
export const objectEmpty = (object) => (!object || !Object.keys(object).length);
|
|
163
|
+
export const objectNotEmpty = (object) => (!objectEmpty(object));
|
|
164
|
+
export const nullable = (object) => ((!object || (object === 'null') || (object === undefined) || (object === null))
|
|
199
165
|
? null // TODO: explore undefined here??
|
|
200
166
|
: object);
|
|
201
|
-
|
|
202
|
-
const objectContainsAnyValue = (object) => (Object.values((0, exports.ensureObject)(object)).some((value) => (0, exports.nullable)(value)));
|
|
203
|
-
exports.objectContainsAnyValue = objectContainsAnyValue;
|
|
167
|
+
export const objectContainsAnyValue = (object) => (Object.values(ensureObject(object)).some((value) => nullable(value)));
|
|
204
168
|
const isUndefined = (value) => (
|
|
205
169
|
// eslint-disable-next-line eqeqeq
|
|
206
170
|
value == undefined);
|
|
207
|
-
const cleanObject = (object, allowEmptyLeafs, isEmptyCallback) => (Object.entries(
|
|
171
|
+
export const cleanObject = (object, allowEmptyLeafs, isEmptyCallback) => (Object.entries(ensureObject(object)).reduce((_cleanedObject, [key, _value]) => {
|
|
208
172
|
var _a;
|
|
209
173
|
if (!allowEmptyLeafs && ((_a = isEmptyCallback === null || isEmptyCallback === void 0 ? void 0 : isEmptyCallback(_value)) !== null && _a !== void 0 ? _a : isUndefined(_value))) {
|
|
210
174
|
return _cleanedObject; // skip key if null or undefined
|
|
@@ -217,59 +181,47 @@ const cleanObject = (object, allowEmptyLeafs, isEmptyCallback) => (Object.entrie
|
|
|
217
181
|
]), []);
|
|
218
182
|
return Object.assign(Object.assign({}, _cleanedObject), { [key]: value });
|
|
219
183
|
}, {}));
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
const
|
|
223
|
-
const string = (0, exports.ensureStringOnly)(stringable);
|
|
184
|
+
const cleanObjectValue = (value, allowEmptyLeafs, isEmptyCallback) => (isType(value, 'object') ? cleanObject(value, allowEmptyLeafs, isEmptyCallback) : value);
|
|
185
|
+
export const stringNotEmptyOnly = (stringable) => {
|
|
186
|
+
const string = ensureStringOnly(stringable);
|
|
224
187
|
return ((string.length > 0) && !['null', 'undefined'].includes(string));
|
|
225
188
|
};
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
const stringNotEmpty = (stringable) => {
|
|
230
|
-
const string = (0, exports.ensureString)(stringable);
|
|
189
|
+
export const stringEmptyOnly = (stringable) => (!stringNotEmptyOnly(stringable));
|
|
190
|
+
export const stringNotEmpty = (stringable) => {
|
|
191
|
+
const string = ensureString(stringable);
|
|
231
192
|
return ((string.length > 0) && !['null', 'undefined'].includes(string));
|
|
232
193
|
};
|
|
233
|
-
|
|
234
|
-
const stringEmpty = (stringable) => (!(0, exports.stringNotEmpty)(stringable));
|
|
235
|
-
exports.stringEmpty = stringEmpty;
|
|
194
|
+
export const stringEmpty = (stringable) => (!stringNotEmpty(stringable));
|
|
236
195
|
const splitString = (splitting, index = splitting.length) => {
|
|
237
|
-
const string =
|
|
196
|
+
const string = ensureString(splitting);
|
|
238
197
|
return [string.slice(0, index), string.slice(index)];
|
|
239
198
|
};
|
|
240
|
-
const compareNumber = (number1 = 0, number2 = 0) => (number1 - number2);
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if ((0, exports.stringEmpty)(string1)) {
|
|
199
|
+
export const compareNumber = (number1 = 0, number2 = 0) => (number1 - number2);
|
|
200
|
+
export const compareString = (string1, string2) => {
|
|
201
|
+
if (stringEmpty(string1)) {
|
|
244
202
|
return 1;
|
|
245
203
|
}
|
|
246
|
-
if (
|
|
204
|
+
if (stringEmpty(string2)) {
|
|
247
205
|
return -1;
|
|
248
206
|
}
|
|
249
|
-
return
|
|
207
|
+
return ensureString(string1).localeCompare(string2);
|
|
250
208
|
};
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
const objectToSortedString = (object, separator = '') => (Object.entries((0, exports.ensureObject)(object))
|
|
255
|
-
.sort(exports.compareEntryKeys)
|
|
209
|
+
export const compareEntryKeys = ([string1], [string2]) => (compareString(string1, string2));
|
|
210
|
+
export const objectToSortedString = (object, separator = '') => (Object.entries(ensureObject(object))
|
|
211
|
+
.sort(compareEntryKeys)
|
|
256
212
|
.map(([key, value]) => `${key}=${value}`)
|
|
257
213
|
.join(separator));
|
|
258
|
-
|
|
259
|
-
const isHTML = (string) => {
|
|
214
|
+
export const isHTML = (string) => {
|
|
260
215
|
var _a, _b, _c;
|
|
261
216
|
return ((_c = (((_a = string === null || string === void 0 ? void 0 : string.startsWith) === null || _a === void 0 ? void 0 : _a.call(string, '<')) || ((_b = string === null || string === void 0 ? void 0 : string.startsWith) === null || _b === void 0 ? void 0 : _b.call(string, '\n<')))) !== null && _c !== void 0 ? _c : false);
|
|
262
217
|
};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
console[type](logMessage, !object ? object : JSON.parse(JSON.stringify((0, exports.ensureObject)(object))));
|
|
218
|
+
export const freeze = (logMessage, object, type = 'log') => {
|
|
219
|
+
console[type](logMessage, !object ? object : JSON.parse(JSON.stringify(ensureObject(object))));
|
|
266
220
|
};
|
|
267
|
-
|
|
268
|
-
const replaceSpaces = (string, replacement = '') => (!(0, exports.isType)(string, 'string')
|
|
221
|
+
export const replaceSpaces = (string, replacement = '') => (!isType(string, 'string')
|
|
269
222
|
? ''
|
|
270
223
|
: string.replace(/\s/g, replacement));
|
|
271
|
-
|
|
272
|
-
const recase = (string, replacement = '') => (!(0, exports.isType)(string, 'string')
|
|
224
|
+
const recase = (string, replacement = '') => (!isType(string, 'string')
|
|
273
225
|
? ''
|
|
274
226
|
: string
|
|
275
227
|
.replace(/[^a-zA-Z0-9]+/g, replacement)
|
|
@@ -280,152 +232,126 @@ const recase = (string, replacement = '') => (!(0, exports.isType)(string, 'stri
|
|
|
280
232
|
.replace(/[-_]+/g, replacement)
|
|
281
233
|
.replace(new RegExp(`${replacement}$`), '')
|
|
282
234
|
.toLowerCase());
|
|
283
|
-
const zencase = (string, replacement = '-') => (!
|
|
235
|
+
export const zencase = (string, replacement = '-') => (!isType(string, 'string')
|
|
284
236
|
? ''
|
|
285
|
-
:
|
|
237
|
+
: replaceSpaces(string, replacement)
|
|
286
238
|
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
|
|
287
239
|
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
288
240
|
.replace(new RegExp(`${replacement}$`), '')
|
|
289
241
|
.toLowerCase());
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
exports.snakecase = snakecase;
|
|
297
|
-
const unsnakecase = (string, replacement = ' ') => ((0, exports.ensureString)(string).replace(/_/g, replacement).trim());
|
|
298
|
-
exports.unsnakecase = unsnakecase;
|
|
299
|
-
const uppercase = (string) => ((0, exports.ensureString)(string).toUpperCase());
|
|
300
|
-
exports.uppercase = uppercase;
|
|
301
|
-
const lowercase = (string, defaultValue = '') => (!(0, exports.stringNotEmpty)(string)
|
|
242
|
+
export const dashcase = (string) => (recase(string, '-'));
|
|
243
|
+
export const undashcase = (string, replacement = ' ') => (ensureString(string).replace(/-/g, replacement).trim());
|
|
244
|
+
export const snakecase = (string) => (recase(string, '_'));
|
|
245
|
+
export const unsnakecase = (string, replacement = ' ') => (ensureString(string).replace(/_/g, replacement).trim());
|
|
246
|
+
export const uppercase = (string) => (ensureString(string).toUpperCase());
|
|
247
|
+
export const lowercase = (string, defaultValue = '') => (!stringNotEmpty(string)
|
|
302
248
|
? defaultValue
|
|
303
|
-
:
|
|
304
|
-
|
|
305
|
-
const
|
|
306
|
-
exports.slugify = slugify;
|
|
307
|
-
const capitalize = (string) => {
|
|
249
|
+
: ensureString(string).toLowerCase());
|
|
250
|
+
export const slugify = (string) => (lowercase(dashcase(string)));
|
|
251
|
+
export const capitalize = (string) => {
|
|
308
252
|
const parts = splitString(string, 1);
|
|
309
|
-
return `${
|
|
253
|
+
return `${uppercase(parts[0])}${parts[1]}`;
|
|
310
254
|
};
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
? (0, exports.unsnakecase)((0, exports.undashcase)(string)).replace(/\w\S*/g, (word, charIndex) => {
|
|
255
|
+
export const camelCase = (string) => (stringNotEmpty(string)
|
|
256
|
+
? unsnakecase(undashcase(string)).replace(/\w\S*/g, (word, charIndex) => {
|
|
314
257
|
if (charIndex === 0) {
|
|
315
|
-
return
|
|
258
|
+
return lowercase(word);
|
|
316
259
|
}
|
|
317
|
-
return `${
|
|
260
|
+
return `${uppercase(word.charAt(0))}${lowercase(word.substr(1))}`;
|
|
318
261
|
}).split(' ').join('')
|
|
319
262
|
: '');
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (!(0, exports.stringNotEmpty)(string)) {
|
|
263
|
+
export const titleCase = (string, _overrides) => {
|
|
264
|
+
if (!stringNotEmpty(string)) {
|
|
323
265
|
return '';
|
|
324
266
|
}
|
|
325
267
|
const overrides = Object.assign({ 'add-ons': 'Add-Ons', agnostack: 'agnoStack', ai: 'AI', b2b: 'B2B', b2c: 'B2C', cartcollab: 'CartCollab', 'cartcollab(sm)': 'CartCollab(SM)', chatgpt: 'ChatGPT', covid: 'COVID', covid19: 'COVID-19', 'covid-19': 'COVID-19', crm: 'CRM', elasticpath: 'Elastic Path', ecommerce: 'eCommerce', 'e-commerce': 'eCommerce', faqs: 'FAQs', gpt: 'GPT', 'smile.io': 'Smile.io', 'stamped.io': 'Stamped.io', 'judge.me': 'Judge.me', 'influence.io': 'Influence.io', keepsmallstrong: 'KeepSmallStrong', loyaltylion: 'LoyaltyLion', openai: 'OpenAI', paypal: 'PayPal', 'postscript.io': 'Postscript.io', recharge: 'ReCharge', 'stay.ai': 'Stay.ai', 'stay ai': 'Stay Ai', shipengine: 'ShipEngine', shipperhq: 'ShipperHQ', shipstation: 'ShipStation', taxjar: 'TaxJar', yotpo: 'YotPo' }, _overrides);
|
|
326
|
-
const stringParts =
|
|
268
|
+
const stringParts = lowercase(string)
|
|
327
269
|
.split(' ')
|
|
328
270
|
.reduce((_stringParts, _stringPart) => {
|
|
329
271
|
var _a;
|
|
330
272
|
const stringPart = (_a = overrides[_stringPart]) !== null && _a !== void 0 ? _a : _stringPart
|
|
331
273
|
.replace(/([A-Z]+)/g, ' $1')
|
|
332
274
|
.replace(/\s\s+/g, ' ')
|
|
333
|
-
.replace(/(\b[a-z](?!\s)*)/g, (firstChar) =>
|
|
275
|
+
.replace(/(\b[a-z](?!\s)*)/g, (firstChar) => uppercase(firstChar));
|
|
334
276
|
return [
|
|
335
277
|
..._stringParts,
|
|
336
|
-
...
|
|
278
|
+
...stringNotEmpty(stringPart) ? [stringPart] : []
|
|
337
279
|
];
|
|
338
280
|
}, []);
|
|
339
281
|
return stringParts.join(' ');
|
|
340
282
|
};
|
|
341
|
-
|
|
342
|
-
const
|
|
343
|
-
exports.removeLeadingSlash = removeLeadingSlash;
|
|
344
|
-
const removeLeadingTrailingQuotes = (string) => ((0, exports.ensureString)(string).replace(/^"|"$/g, ''));
|
|
345
|
-
exports.removeLeadingTrailingQuotes = removeLeadingTrailingQuotes;
|
|
283
|
+
export const removeLeadingSlash = (string) => (ensureString(string).replace(/^\//, ''));
|
|
284
|
+
export const removeLeadingTrailingQuotes = (string) => (ensureString(string).replace(/^"|"$/g, ''));
|
|
346
285
|
// TODO: not sure if this should remove multipel at end or just one (as it does now)?
|
|
347
|
-
const removeTrailingSlash = (string) => (
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
exports.ensureLeadingSlash = ensureLeadingSlash;
|
|
353
|
-
const ensureTrailingSlash = (string) => (`${(0, exports.removeTrailingSlash)(string)}/`);
|
|
354
|
-
exports.ensureTrailingSlash = ensureTrailingSlash;
|
|
355
|
-
const ensureExtension = (string, extension) => {
|
|
286
|
+
export const removeTrailingSlash = (string) => (ensureString(string).replace(/\/$/, ''));
|
|
287
|
+
export const removeLeadingTrailingSlash = (string) => (removeTrailingSlash(removeLeadingSlash(string)));
|
|
288
|
+
export const ensureLeadingSlash = (string) => (`/${removeLeadingSlash(string)}`);
|
|
289
|
+
export const ensureTrailingSlash = (string) => (`${removeTrailingSlash(string)}/`);
|
|
290
|
+
export const ensureExtension = (string, extension) => {
|
|
356
291
|
var _a, _b;
|
|
357
|
-
if (
|
|
292
|
+
if (stringEmpty(extension)) {
|
|
358
293
|
return string;
|
|
359
294
|
}
|
|
360
295
|
const filePath = (_b = (_a = string.match(/(.*)\..+$/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : string;
|
|
361
296
|
return `${filePath}.${extension}`;
|
|
362
297
|
};
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
if ((0, exports.stringEmpty)(basePath)) {
|
|
298
|
+
export const wrappedEncode = (basePath, _wrappingPath) => {
|
|
299
|
+
const wrappingPath = ensureString(_wrappingPath);
|
|
300
|
+
if (stringEmpty(basePath)) {
|
|
367
301
|
return wrappingPath;
|
|
368
302
|
}
|
|
369
303
|
return `${basePath}${encodeURIComponent(wrappingPath)}`;
|
|
370
304
|
};
|
|
371
|
-
|
|
372
|
-
const splitCommas = (value) => ((0, exports.ensureString)(value)
|
|
305
|
+
export const splitCommas = (value) => (ensureString(value)
|
|
373
306
|
.replace(/, /g, ',')
|
|
374
307
|
.split(',')
|
|
375
308
|
.reduce((_values, _value) => {
|
|
376
|
-
const __value =
|
|
309
|
+
const __value = safeTrim(_value);
|
|
377
310
|
return [
|
|
378
311
|
..._values,
|
|
379
|
-
...
|
|
312
|
+
...stringNotEmpty(__value) ? [__value] : [] // TODO: explore stringEmptyOnly?
|
|
380
313
|
];
|
|
381
314
|
}, []));
|
|
382
|
-
|
|
383
|
-
const combineCommas = (values) => ([...new Set((0, exports.ensureArray)(values).reduce((_combined, value) => ([
|
|
315
|
+
export const combineCommas = (values) => ([...new Set(ensureArray(values).reduce((_combined, value) => ([
|
|
384
316
|
..._combined,
|
|
385
|
-
...
|
|
317
|
+
...splitCommas(value)
|
|
386
318
|
]), []))]);
|
|
387
|
-
|
|
388
|
-
const
|
|
389
|
-
const inputArray = (0, exports.ensureArray)(input);
|
|
319
|
+
export const normalizeArray = (input, separator = ' ') => {
|
|
320
|
+
const inputArray = ensureArray(input);
|
|
390
321
|
return inputArray.reduce((normalized, _ignore, index) => ([
|
|
391
322
|
...normalized,
|
|
392
323
|
inputArray.slice(0, index + 1).join(separator)
|
|
393
324
|
]), []).reverse();
|
|
394
325
|
};
|
|
395
|
-
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
const string = (0, exports.ensureString)(value);
|
|
400
|
-
return ![...(0, exports.ensureArray)(falsy), '', 'false'].includes(string);
|
|
326
|
+
export const arrayToObject = (arrayable, key) => (ensureArray(arrayable).reduce((_object, item) => (Object.assign(Object.assign({}, _object), { [item === null || item === void 0 ? void 0 : item[key]]: item })), {}));
|
|
327
|
+
export const isTrue = (value, falsy) => {
|
|
328
|
+
const string = ensureString(value);
|
|
329
|
+
return ![...ensureArray(falsy), '', 'false'].includes(string);
|
|
401
330
|
};
|
|
402
|
-
exports.isTrue = isTrue;
|
|
403
331
|
// TODO: move all uses of parseKeywords to parseKeywordGroups
|
|
404
|
-
const parseKeywords = (keywordGroup, previous) => ([...new Set(
|
|
405
|
-
const keywords =
|
|
332
|
+
export const parseKeywords = (keywordGroup, previous) => ([...new Set(ensureArray(keywordGroup).reduce((_parsedKeywords, keyword) => {
|
|
333
|
+
const keywords = splitCommas(keyword);
|
|
406
334
|
return [
|
|
407
335
|
..._parsedKeywords,
|
|
408
|
-
...keywords.filter((_keyword) =>
|
|
336
|
+
...keywords.filter((_keyword) => stringNotEmpty(_keyword))
|
|
409
337
|
];
|
|
410
|
-
},
|
|
411
|
-
|
|
412
|
-
const
|
|
413
|
-
const parsedKeywords = (0, exports.ensureArray)(keywordGroups).reduce((_parsedKeywords, keywordGroup) => ([
|
|
338
|
+
}, ensureArray(previous)))].join(', '));
|
|
339
|
+
export const parseKeywordGroups = (keywordGroups) => {
|
|
340
|
+
const parsedKeywords = ensureArray(keywordGroups).reduce((_parsedKeywords, keywordGroup) => ([
|
|
414
341
|
..._parsedKeywords,
|
|
415
|
-
...
|
|
416
|
-
const keywords =
|
|
342
|
+
...ensureArray(keywordGroup).reduce((_parsedGroupKeywords, keyword) => {
|
|
343
|
+
const keywords = splitCommas(keyword);
|
|
417
344
|
return [
|
|
418
345
|
..._parsedGroupKeywords,
|
|
419
|
-
...keywords.filter((_keyword) =>
|
|
346
|
+
...keywords.filter((_keyword) => stringNotEmpty(_keyword))
|
|
420
347
|
];
|
|
421
348
|
}, [])
|
|
422
349
|
]), []);
|
|
423
350
|
return [...new Set(parsedKeywords)].join(', ');
|
|
424
351
|
};
|
|
425
|
-
|
|
426
|
-
const parseProjectName = (_name) => {
|
|
352
|
+
export const parseProjectName = (_name) => {
|
|
427
353
|
var _a;
|
|
428
|
-
const name =
|
|
354
|
+
const name = ensureString(_name);
|
|
429
355
|
const [, organization, ...parts] = (_a = /(@.*)([\\]+|\/)+(.*)/.exec(name)) !== null && _a !== void 0 ? _a : [];
|
|
430
356
|
const projectName = organization ? name.replace(organization, '').replace('/', '') : name;
|
|
431
357
|
return {
|
|
@@ -435,13 +361,12 @@ const parseProjectName = (_name) => {
|
|
|
435
361
|
projectName,
|
|
436
362
|
};
|
|
437
363
|
};
|
|
438
|
-
|
|
439
|
-
const parseProject = (packageInfo) => {
|
|
364
|
+
export const parseProject = (packageInfo) => {
|
|
440
365
|
const { shortName, owner: _appOwner, name: _name, appName: _appName, keywords, siteName: _siteName } = packageInfo !== null && packageInfo !== void 0 ? packageInfo : {};
|
|
441
|
-
const { name, organization, projectName } =
|
|
366
|
+
const { name, organization, projectName } = parseProjectName(_name);
|
|
442
367
|
const appName = _appName !== null && _appName !== void 0 ? _appName : projectName === null || projectName === void 0 ? void 0 : projectName.slice((projectName === null || projectName === void 0 ? void 0 : projectName.indexOf('-')) + 1);
|
|
443
368
|
const siteName = _siteName !== null && _siteName !== void 0 ? _siteName : projectName === null || projectName === void 0 ? void 0 : projectName.slice((projectName === null || projectName === void 0 ? void 0 : projectName.indexOf('-')) + 1);
|
|
444
|
-
const companyName =
|
|
369
|
+
const companyName = titleCase(organization === null || organization === void 0 ? void 0 : organization.replace('@', ''));
|
|
445
370
|
const appOwner = _appOwner !== null && _appOwner !== void 0 ? _appOwner : companyName;
|
|
446
371
|
return [{
|
|
447
372
|
keywords,
|
|
@@ -453,35 +378,28 @@ const parseProject = (packageInfo) => {
|
|
|
453
378
|
projectName,
|
|
454
379
|
}, organization, name];
|
|
455
380
|
};
|
|
456
|
-
exports.parseProject = parseProject;
|
|
457
381
|
// #endregion lib-core
|
|
458
382
|
// #region lib-utils-js
|
|
459
|
-
const querystringToObject = (queryString) => {
|
|
460
|
-
if (
|
|
383
|
+
export const querystringToObject = (queryString) => {
|
|
384
|
+
if (stringEmpty(queryString)) {
|
|
461
385
|
return {};
|
|
462
386
|
}
|
|
463
387
|
const urlParams = new URLSearchParams(queryString);
|
|
464
388
|
return Object.fromEntries(urlParams);
|
|
465
389
|
};
|
|
466
|
-
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
return (0, exports.ensureArray)(comparison).every((value) => ((0, exports.stringNotEmpty)(value) && values.includes(value)));
|
|
390
|
+
export const arrayIncludesAll = (_values, comparison) => {
|
|
391
|
+
const values = ensureArray(_values);
|
|
392
|
+
return ensureArray(comparison).every((value) => (stringNotEmpty(value) && values.includes(value)));
|
|
470
393
|
};
|
|
471
|
-
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
const basePath = (0, exports.ensureString)(_basePath);
|
|
476
|
-
if ((0, exports.stringEmpty)(queryString)) {
|
|
394
|
+
export const arraysMatch = (array1, array2) => (arrayIncludesAll(array1, array2) && arrayIncludesAll(array2, array1));
|
|
395
|
+
export const appendQuery = (_basePath, queryString) => {
|
|
396
|
+
const basePath = ensureString(_basePath);
|
|
397
|
+
if (stringEmpty(queryString)) {
|
|
477
398
|
return basePath;
|
|
478
399
|
}
|
|
479
400
|
return `${basePath}${basePath.includes('?') ? '&' : '?'}${queryString}`;
|
|
480
401
|
};
|
|
481
|
-
exports.appendQuery = appendQuery;
|
|
482
402
|
// #endregion lib-utils-js
|
|
483
|
-
const getGUID = () => ((
|
|
484
|
-
|
|
485
|
-
const getInteger = () => ((0, exports.getGUID)().replace(/\D/g, ''));
|
|
486
|
-
exports.getInteger = getInteger;
|
|
403
|
+
export const getGUID = () => (uuidV4());
|
|
404
|
+
export const getInteger = () => (getGUID().replace(/\D/g, ''));
|
|
487
405
|
//# sourceMappingURL=display.js.map
|