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