@snagsolutions/sdk 0.1.0-alpha.230 → 0.1.0-alpha.232
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 +16 -0
- package/README.md +42 -112
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +21 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +101 -0
- package/_shims/auto/types.js +3 -0
- package/_shims/auto/types.mjs +3 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +14 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +83 -0
- package/_shims/index.js +17 -0
- package/_shims/index.mjs +11 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +89 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +56 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +41 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +37 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +78 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +71 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +83 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +255 -0
- package/core.d.ts.map +1 -0
- package/core.js +929 -0
- package/core.js.map +1 -0
- package/core.mjs +897 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +46 -1
- package/error.d.ts.map +1 -1
- package/error.js +110 -3
- package/error.js.map +1 -1
- package/error.mjs +96 -1
- package/error.mjs.map +1 -1
- package/index.d.mts +138 -6
- package/index.d.ts +137 -5
- package/index.d.ts.map +1 -1
- package/index.js +136 -12
- package/index.js.map +1 -1
- package/index.mjs +109 -5
- package/index.mjs.map +1 -1
- package/internal/qs/formats.d.ts +0 -1
- package/internal/qs/formats.d.ts.map +1 -1
- package/internal/qs/formats.js +2 -4
- package/internal/qs/formats.js.map +1 -1
- package/internal/qs/formats.mjs +1 -2
- package/internal/qs/formats.mjs.map +1 -1
- package/internal/qs/index.d.ts.map +1 -1
- package/internal/qs/stringify.d.ts.map +1 -1
- package/internal/qs/stringify.js +19 -16
- package/internal/qs/stringify.js.map +1 -1
- package/internal/qs/stringify.mjs +19 -17
- package/internal/qs/stringify.mjs.map +1 -1
- package/internal/qs/utils.d.ts +0 -1
- package/internal/qs/utils.d.ts.map +1 -1
- package/internal/qs/utils.js +21 -22
- package/internal/qs/utils.js.map +1 -1
- package/internal/qs/utils.mjs +12 -12
- package/internal/qs/utils.mjs.map +1 -1
- package/package.json +65 -101
- package/resource.d.ts +5 -1
- package/resource.d.ts.map +1 -1
- package/resource.js +8 -3
- package/resource.js.map +1 -1
- package/resource.mjs +6 -1
- package/resource.mjs.map +1 -1
- package/resources/assets.d.ts +3 -4
- package/resources/assets.d.ts.map +1 -1
- package/resources/assets.js +1 -1
- package/resources/assets.js.map +1 -1
- package/resources/assets.mjs +1 -1
- package/resources/assets.mjs.map +1 -1
- package/resources/auctions/auctions.d.ts +6 -6
- package/resources/auctions/auctions.d.ts.map +1 -1
- package/resources/auctions/auctions.js +29 -11
- package/resources/auctions/auctions.js.map +1 -1
- package/resources/auctions/auctions.mjs +5 -9
- package/resources/auctions/auctions.mjs.map +1 -1
- package/resources/auctions/index.d.ts.map +1 -1
- package/resources/auctions/website-user-attributes/index.d.ts.map +1 -1
- package/resources/auctions/website-user-attributes/values.d.ts +4 -5
- package/resources/auctions/website-user-attributes/values.d.ts.map +1 -1
- package/resources/auctions/website-user-attributes/values.js +1 -1
- package/resources/auctions/website-user-attributes/values.js.map +1 -1
- package/resources/auctions/website-user-attributes/values.mjs +1 -1
- package/resources/auctions/website-user-attributes/values.mjs.map +1 -1
- package/resources/auctions/website-user-attributes/website-user-attributes.d.ts +6 -6
- package/resources/auctions/website-user-attributes/website-user-attributes.d.ts.map +1 -1
- package/resources/auctions/website-user-attributes/website-user-attributes.js +31 -15
- package/resources/auctions/website-user-attributes/website-user-attributes.js.map +1 -1
- package/resources/auctions/website-user-attributes/website-user-attributes.mjs +7 -13
- package/resources/auctions/website-user-attributes/website-user-attributes.mjs.map +1 -1
- package/resources/auctions/website-user-attributes.d.ts.map +1 -1
- package/resources/auctions/website-user-attributes.js +15 -2
- package/resources/auctions/website-user-attributes.js.map +1 -1
- package/resources/auctions.d.ts.map +1 -1
- package/resources/auctions.js +15 -2
- package/resources/auctions.js.map +1 -1
- package/resources/auth.d.ts +52 -5
- package/resources/auth.d.ts.map +1 -1
- package/resources/auth.js +11 -5
- package/resources/auth.js.map +1 -1
- package/resources/auth.mjs +11 -5
- package/resources/auth.mjs.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/loyalty/account-streaks.d.ts +3 -4
- package/resources/loyalty/account-streaks.d.ts.map +1 -1
- package/resources/loyalty/account-streaks.js +1 -1
- package/resources/loyalty/account-streaks.js.map +1 -1
- package/resources/loyalty/account-streaks.mjs +1 -1
- package/resources/loyalty/account-streaks.mjs.map +1 -1
- package/resources/loyalty/accounts.d.ts +5 -5
- package/resources/loyalty/accounts.d.ts.map +1 -1
- package/resources/loyalty/accounts.js +6 -11
- package/resources/loyalty/accounts.js.map +1 -1
- package/resources/loyalty/accounts.mjs +6 -11
- package/resources/loyalty/accounts.mjs.map +1 -1
- package/resources/loyalty/badges.d.ts +12 -9
- package/resources/loyalty/badges.d.ts.map +1 -1
- package/resources/loyalty/badges.js +18 -44
- package/resources/loyalty/badges.js.map +1 -1
- package/resources/loyalty/badges.mjs +18 -44
- package/resources/loyalty/badges.mjs.map +1 -1
- package/resources/loyalty/currencies.d.ts +4 -5
- package/resources/loyalty/currencies.d.ts.map +1 -1
- package/resources/loyalty/currencies.js +1 -1
- package/resources/loyalty/currencies.js.map +1 -1
- package/resources/loyalty/currencies.mjs +1 -1
- package/resources/loyalty/currencies.mjs.map +1 -1
- package/resources/loyalty/index.d.ts.map +1 -1
- package/resources/loyalty/loyalty.d.ts +1 -1
- package/resources/loyalty/loyalty.d.ts.map +1 -1
- package/resources/loyalty/loyalty.js +35 -13
- package/resources/loyalty/loyalty.js.map +1 -1
- package/resources/loyalty/loyalty.mjs +1 -1
- package/resources/loyalty/multipliers.d.ts +10 -9
- package/resources/loyalty/multipliers.d.ts.map +1 -1
- package/resources/loyalty/multipliers.js +14 -26
- package/resources/loyalty/multipliers.js.map +1 -1
- package/resources/loyalty/multipliers.mjs +14 -26
- package/resources/loyalty/multipliers.mjs.map +1 -1
- package/resources/loyalty/questions-responses.d.ts +5 -5
- package/resources/loyalty/questions-responses.d.ts.map +1 -1
- package/resources/loyalty/questions-responses.js +5 -11
- package/resources/loyalty/questions-responses.js.map +1 -1
- package/resources/loyalty/questions-responses.mjs +5 -11
- package/resources/loyalty/questions-responses.mjs.map +1 -1
- package/resources/loyalty/questions.d.ts +5 -6
- package/resources/loyalty/questions.d.ts.map +1 -1
- package/resources/loyalty/questions.js +2 -3
- package/resources/loyalty/questions.js.map +1 -1
- package/resources/loyalty/questions.mjs +2 -3
- package/resources/loyalty/questions.mjs.map +1 -1
- package/resources/loyalty/rule-edits.d.ts +4 -5
- package/resources/loyalty/rule-edits.d.ts.map +1 -1
- package/resources/loyalty/rule-edits.js +2 -3
- package/resources/loyalty/rule-edits.js.map +1 -1
- package/resources/loyalty/rule-edits.mjs +2 -3
- package/resources/loyalty/rule-edits.mjs.map +1 -1
- package/resources/loyalty/rule-groups.d.ts +8 -7
- package/resources/loyalty/rule-groups.d.ts.map +1 -1
- package/resources/loyalty/rule-groups.js +10 -24
- package/resources/loyalty/rule-groups.js.map +1 -1
- package/resources/loyalty/rule-groups.mjs +10 -24
- package/resources/loyalty/rule-groups.mjs.map +1 -1
- package/resources/loyalty/rules.d.ts +12 -9
- package/resources/loyalty/rules.d.ts.map +1 -1
- package/resources/loyalty/rules.js +18 -48
- package/resources/loyalty/rules.js.map +1 -1
- package/resources/loyalty/rules.mjs +18 -48
- package/resources/loyalty/rules.mjs.map +1 -1
- package/resources/loyalty/transactions/index.d.ts.map +1 -1
- package/resources/loyalty/transactions/posts.d.ts +5 -5
- package/resources/loyalty/transactions/posts.d.ts.map +1 -1
- package/resources/loyalty/transactions/posts.js +6 -14
- package/resources/loyalty/transactions/posts.js.map +1 -1
- package/resources/loyalty/transactions/posts.mjs +6 -14
- package/resources/loyalty/transactions/posts.mjs.map +1 -1
- package/resources/loyalty/transactions/rule-statuses.d.ts +5 -5
- package/resources/loyalty/transactions/rule-statuses.d.ts.map +1 -1
- package/resources/loyalty/transactions/rule-statuses.js +5 -10
- package/resources/loyalty/transactions/rule-statuses.js.map +1 -1
- package/resources/loyalty/transactions/rule-statuses.mjs +5 -10
- package/resources/loyalty/transactions/rule-statuses.mjs.map +1 -1
- package/resources/loyalty/transactions/transactions.d.ts +8 -8
- package/resources/loyalty/transactions/transactions.d.ts.map +1 -1
- package/resources/loyalty/transactions/transactions.js +30 -14
- package/resources/loyalty/transactions/transactions.js.map +1 -1
- package/resources/loyalty/transactions/transactions.mjs +5 -11
- package/resources/loyalty/transactions/transactions.mjs.map +1 -1
- package/resources/loyalty/transactions.d.ts.map +1 -1
- package/resources/loyalty/transactions.js +15 -2
- package/resources/loyalty/transactions.js.map +1 -1
- package/resources/loyalty.d.ts.map +1 -1
- package/resources/loyalty.js +15 -2
- package/resources/loyalty.js.map +1 -1
- package/resources/minting/allowlist.d.ts +4 -5
- package/resources/minting/allowlist.d.ts.map +1 -1
- package/resources/minting/allowlist.js +1 -1
- package/resources/minting/allowlist.js.map +1 -1
- package/resources/minting/allowlist.mjs +1 -1
- package/resources/minting/allowlist.mjs.map +1 -1
- package/resources/minting/contracts.d.ts +5 -5
- package/resources/minting/contracts.d.ts.map +1 -1
- package/resources/minting/contracts.js +5 -9
- package/resources/minting/contracts.js.map +1 -1
- package/resources/minting/contracts.mjs +5 -9
- package/resources/minting/contracts.mjs.map +1 -1
- package/resources/minting/index.d.ts.map +1 -1
- package/resources/minting/minting.d.ts +4 -5
- package/resources/minting/minting.d.ts.map +1 -1
- package/resources/minting/minting.js +27 -5
- package/resources/minting/minting.js.map +1 -1
- package/resources/minting/minting.mjs +1 -1
- package/resources/minting/minting.mjs.map +1 -1
- package/resources/minting/status.d.ts +4 -5
- package/resources/minting/status.d.ts.map +1 -1
- package/resources/minting/status.js +3 -4
- package/resources/minting/status.js.map +1 -1
- package/resources/minting/status.mjs +3 -4
- package/resources/minting/status.mjs.map +1 -1
- package/resources/minting.d.ts.map +1 -1
- package/resources/minting.js +15 -2
- package/resources/minting.js.map +1 -1
- package/resources/referral/index.d.ts.map +1 -1
- package/resources/referral/referral.d.ts +3 -4
- package/resources/referral/referral.d.ts.map +1 -1
- package/resources/referral/referral.js +25 -3
- package/resources/referral/referral.js.map +1 -1
- package/resources/referral/referral.mjs +1 -1
- package/resources/referral/referral.mjs.map +1 -1
- package/resources/referral/users.d.ts +5 -5
- package/resources/referral/users.d.ts.map +1 -1
- package/resources/referral/users.js +5 -9
- package/resources/referral/users.js.map +1 -1
- package/resources/referral/users.mjs +5 -9
- package/resources/referral/users.mjs.map +1 -1
- package/resources/referral.d.ts.map +1 -1
- package/resources/referral.js +15 -2
- package/resources/referral.js.map +1 -1
- package/resources/token-claims.d.ts +10 -9
- package/resources/token-claims.d.ts.map +1 -1
- package/resources/token-claims.js +16 -16
- package/resources/token-claims.js.map +1 -1
- package/resources/token-claims.mjs +16 -16
- package/resources/token-claims.mjs.map +1 -1
- package/resources/users/index.d.ts.map +1 -1
- package/resources/users/metadatas.d.ts +6 -5
- package/resources/users/metadatas.d.ts.map +1 -1
- package/resources/users/metadatas.js +8 -17
- package/resources/users/metadatas.js.map +1 -1
- package/resources/users/metadatas.mjs +8 -17
- package/resources/users/metadatas.mjs.map +1 -1
- package/resources/users/users.d.ts +13 -9
- package/resources/users/users.d.ts.map +1 -1
- package/resources/users/users.js +29 -11
- package/resources/users/users.js.map +1 -1
- package/resources/users/users.mjs +5 -9
- package/resources/users/users.mjs.map +1 -1
- package/resources/users.d.ts.map +1 -1
- package/resources/users.js +15 -2
- package/resources/users.js.map +1 -1
- package/resources/websites/index.d.ts.map +1 -1
- package/resources/websites/website-collections.d.ts +4 -5
- package/resources/websites/website-collections.d.ts.map +1 -1
- package/resources/websites/website-collections.js +2 -3
- package/resources/websites/website-collections.js.map +1 -1
- package/resources/websites/website-collections.mjs +2 -3
- package/resources/websites/website-collections.mjs.map +1 -1
- package/resources/websites/website-user-roles.d.ts +4 -5
- package/resources/websites/website-user-roles.d.ts.map +1 -1
- package/resources/websites/website-user-roles.js +1 -1
- package/resources/websites/website-user-roles.js.map +1 -1
- package/resources/websites/website-user-roles.mjs +1 -1
- package/resources/websites/website-user-roles.mjs.map +1 -1
- package/resources/websites/websites.d.ts +5 -5
- package/resources/websites/websites.d.ts.map +1 -1
- package/resources/websites/websites.js +30 -13
- package/resources/websites/websites.js.map +1 -1
- package/resources/websites/websites.mjs +5 -10
- package/resources/websites/websites.mjs.map +1 -1
- package/resources/websites.d.ts.map +1 -1
- package/resources/websites.js +15 -2
- package/resources/websites.js.map +1 -1
- package/resources.d.ts.map +1 -1
- package/resources.js +15 -2
- package/resources.js.map +1 -1
- package/shims/node.d.ts +30 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +31 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +5 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +31 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +5 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +101 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +83 -0
- package/src/_shims/index.js +17 -0
- package/src/_shims/index.mjs +11 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +81 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +67 -0
- package/src/_shims/web-runtime.ts +103 -0
- package/src/_shims/web-types.d.ts +83 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +1243 -0
- package/src/error.ts +130 -2
- package/src/index.ts +342 -5
- package/src/internal/qs/formats.ts +1 -2
- package/src/internal/qs/stringify.ts +20 -17
- package/src/internal/qs/utils.ts +14 -14
- package/src/resource.ts +11 -2
- package/src/resources/assets.ts +6 -4
- package/src/resources/auctions/auctions.ts +17 -9
- package/src/resources/auctions/website-user-attributes/values.ts +4 -5
- package/src/resources/auctions/website-user-attributes/website-user-attributes.ts +20 -13
- package/src/resources/auth.ts +107 -8
- package/src/resources/index.ts +7 -1
- package/src/resources/loyalty/account-streaks.ts +4 -5
- package/src/resources/loyalty/accounts.ts +14 -10
- package/src/resources/loyalty/badges.ts +53 -22
- package/src/resources/loyalty/currencies.ts +4 -5
- package/src/resources/loyalty/loyalty.ts +1 -1
- package/src/resources/loyalty/multipliers.ts +35 -19
- package/src/resources/loyalty/questions-responses.ts +16 -8
- package/src/resources/loyalty/questions.ts +7 -9
- package/src/resources/loyalty/rule-edits.ts +6 -8
- package/src/resources/loyalty/rule-groups.ts +34 -15
- package/src/resources/loyalty/rules.ts +56 -22
- package/src/resources/loyalty/transactions/posts.ts +17 -9
- package/src/resources/loyalty/transactions/rule-statuses.ts +15 -7
- package/src/resources/loyalty/transactions/transactions.ts +24 -14
- package/src/resources/minting/allowlist.ts +7 -5
- package/src/resources/minting/contracts.ts +12 -7
- package/src/resources/minting/minting.ts +8 -6
- package/src/resources/minting/status.ts +10 -8
- package/src/resources/referral/referral.ts +4 -5
- package/src/resources/referral/users.ts +12 -7
- package/src/resources/token-claims.ts +39 -26
- package/src/resources/users/metadatas.ts +19 -9
- package/src/resources/users/users.ts +30 -11
- package/src/resources/websites/website-collections.ts +6 -8
- package/src/resources/websites/website-user-roles.ts +8 -6
- package/src/resources/websites/websites.ts +12 -7
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/tsconfig.json +2 -2
- package/src/uploads.ts +255 -2
- package/src/version.ts +1 -1
- package/uploads.d.ts +74 -1
- package/uploads.d.ts.map +1 -1
- package/uploads.js +168 -3
- package/uploads.js.map +1 -1
- package/uploads.mjs +157 -1
- package/uploads.mjs.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/api-promise.d.mts +0 -2
- package/api-promise.d.mts.map +0 -1
- package/api-promise.d.ts +0 -2
- package/api-promise.d.ts.map +0 -1
- package/api-promise.js +0 -6
- package/api-promise.js.map +0 -1
- package/api-promise.mjs +0 -2
- package/api-promise.mjs.map +0 -1
- package/client.d.mts +0 -202
- package/client.d.mts.map +0 -1
- package/client.d.ts +0 -202
- package/client.d.ts.map +0 -1
- package/client.js +0 -478
- package/client.js.map +0 -1
- package/client.mjs +0 -474
- package/client.mjs.map +0 -1
- package/core/api-promise.d.mts +0 -46
- package/core/api-promise.d.mts.map +0 -1
- package/core/api-promise.d.ts +0 -46
- package/core/api-promise.d.ts.map +0 -1
- package/core/api-promise.js +0 -74
- package/core/api-promise.js.map +0 -1
- package/core/api-promise.mjs +0 -70
- package/core/api-promise.mjs.map +0 -1
- package/core/error.d.mts +0 -46
- package/core/error.d.mts.map +0 -1
- package/core/error.d.ts +0 -46
- package/core/error.d.ts.map +0 -1
- package/core/error.js +0 -113
- package/core/error.js.map +0 -1
- package/core/error.mjs +0 -97
- package/core/error.mjs.map +0 -1
- package/core/resource.d.mts +0 -6
- package/core/resource.d.mts.map +0 -1
- package/core/resource.d.ts +0 -6
- package/core/resource.d.ts.map +0 -1
- package/core/resource.js +0 -11
- package/core/resource.js.map +0 -1
- package/core/resource.mjs +0 -7
- package/core/resource.mjs.map +0 -1
- package/core/uploads.d.mts +0 -3
- package/core/uploads.d.mts.map +0 -1
- package/core/uploads.d.ts +0 -3
- package/core/uploads.d.ts.map +0 -1
- package/core/uploads.js +0 -6
- package/core/uploads.js.map +0 -1
- package/core/uploads.mjs +0 -2
- package/core/uploads.mjs.map +0 -1
- package/error.d.mts +0 -2
- package/error.d.mts.map +0 -1
- package/index.d.mts.map +0 -1
- package/internal/builtin-types.d.mts +0 -73
- package/internal/builtin-types.d.mts.map +0 -1
- package/internal/builtin-types.d.ts +0 -73
- package/internal/builtin-types.d.ts.map +0 -1
- package/internal/builtin-types.js +0 -4
- package/internal/builtin-types.js.map +0 -1
- package/internal/builtin-types.mjs +0 -3
- package/internal/builtin-types.mjs.map +0 -1
- package/internal/detect-platform.d.mts +0 -15
- package/internal/detect-platform.d.mts.map +0 -1
- package/internal/detect-platform.d.ts +0 -15
- package/internal/detect-platform.d.ts.map +0 -1
- package/internal/detect-platform.js +0 -162
- package/internal/detect-platform.js.map +0 -1
- package/internal/detect-platform.mjs +0 -157
- package/internal/detect-platform.mjs.map +0 -1
- package/internal/errors.d.mts +0 -3
- package/internal/errors.d.mts.map +0 -1
- package/internal/errors.d.ts +0 -3
- package/internal/errors.d.ts.map +0 -1
- package/internal/errors.js +0 -41
- package/internal/errors.js.map +0 -1
- package/internal/errors.mjs +0 -36
- package/internal/errors.mjs.map +0 -1
- package/internal/headers.d.mts +0 -20
- package/internal/headers.d.mts.map +0 -1
- package/internal/headers.d.ts +0 -20
- package/internal/headers.d.ts.map +0 -1
- package/internal/headers.js +0 -79
- package/internal/headers.js.map +0 -1
- package/internal/headers.mjs +0 -74
- package/internal/headers.mjs.map +0 -1
- package/internal/parse.d.mts +0 -12
- package/internal/parse.d.mts.map +0 -1
- package/internal/parse.d.ts +0 -12
- package/internal/parse.d.ts.map +0 -1
- package/internal/parse.js +0 -40
- package/internal/parse.js.map +0 -1
- package/internal/parse.mjs +0 -37
- package/internal/parse.mjs.map +0 -1
- package/internal/qs/formats.d.mts +0 -7
- package/internal/qs/formats.d.mts.map +0 -1
- package/internal/qs/index.d.mts +0 -10
- package/internal/qs/index.d.mts.map +0 -1
- package/internal/qs/stringify.d.mts +0 -3
- package/internal/qs/stringify.d.mts.map +0 -1
- package/internal/qs/types.d.mts +0 -57
- package/internal/qs/types.d.mts.map +0 -1
- package/internal/qs/utils.d.mts +0 -15
- package/internal/qs/utils.d.mts.map +0 -1
- package/internal/request-options.d.mts +0 -75
- package/internal/request-options.d.mts.map +0 -1
- package/internal/request-options.d.ts +0 -75
- package/internal/request-options.d.ts.map +0 -1
- package/internal/request-options.js +0 -14
- package/internal/request-options.js.map +0 -1
- package/internal/request-options.mjs +0 -10
- package/internal/request-options.mjs.map +0 -1
- package/internal/shim-types.d.mts +0 -17
- package/internal/shim-types.d.mts.map +0 -1
- package/internal/shim-types.d.ts +0 -17
- package/internal/shim-types.d.ts.map +0 -1
- package/internal/shim-types.js +0 -4
- package/internal/shim-types.js.map +0 -1
- package/internal/shim-types.mjs +0 -3
- package/internal/shim-types.mjs.map +0 -1
- package/internal/shims.d.mts +0 -20
- package/internal/shims.d.mts.map +0 -1
- package/internal/shims.d.ts +0 -20
- package/internal/shims.d.ts.map +0 -1
- package/internal/shims.js +0 -92
- package/internal/shims.js.map +0 -1
- package/internal/shims.mjs +0 -85
- package/internal/shims.mjs.map +0 -1
- package/internal/to-file.d.mts +0 -45
- package/internal/to-file.d.mts.map +0 -1
- package/internal/to-file.d.ts +0 -45
- package/internal/to-file.d.ts.map +0 -1
- package/internal/to-file.js +0 -91
- package/internal/to-file.js.map +0 -1
- package/internal/to-file.mjs +0 -88
- package/internal/to-file.mjs.map +0 -1
- package/internal/tslib.js +0 -81
- package/internal/tslib.mjs +0 -17
- package/internal/types.d.mts +0 -69
- package/internal/types.d.mts.map +0 -1
- package/internal/types.d.ts +0 -69
- package/internal/types.d.ts.map +0 -1
- package/internal/types.js +0 -4
- package/internal/types.js.map +0 -1
- package/internal/types.mjs +0 -3
- package/internal/types.mjs.map +0 -1
- package/internal/uploads.d.mts +0 -42
- package/internal/uploads.d.mts.map +0 -1
- package/internal/uploads.d.ts +0 -42
- package/internal/uploads.d.ts.map +0 -1
- package/internal/uploads.js +0 -141
- package/internal/uploads.js.map +0 -1
- package/internal/uploads.mjs +0 -131
- package/internal/uploads.mjs.map +0 -1
- package/internal/utils/base64.d.mts +0 -3
- package/internal/utils/base64.d.mts.map +0 -1
- package/internal/utils/base64.d.ts +0 -3
- package/internal/utils/base64.d.ts.map +0 -1
- package/internal/utils/base64.js +0 -38
- package/internal/utils/base64.js.map +0 -1
- package/internal/utils/base64.mjs +0 -33
- package/internal/utils/base64.mjs.map +0 -1
- package/internal/utils/bytes.d.mts +0 -4
- package/internal/utils/bytes.d.mts.map +0 -1
- package/internal/utils/bytes.d.ts +0 -4
- package/internal/utils/bytes.d.ts.map +0 -1
- package/internal/utils/bytes.js +0 -31
- package/internal/utils/bytes.js.map +0 -1
- package/internal/utils/bytes.mjs +0 -26
- package/internal/utils/bytes.mjs.map +0 -1
- package/internal/utils/env.d.mts +0 -9
- package/internal/utils/env.d.mts.map +0 -1
- package/internal/utils/env.d.ts +0 -9
- package/internal/utils/env.d.ts.map +0 -1
- package/internal/utils/env.js +0 -22
- package/internal/utils/env.js.map +0 -1
- package/internal/utils/env.mjs +0 -18
- package/internal/utils/env.mjs.map +0 -1
- package/internal/utils/log.d.mts +0 -37
- package/internal/utils/log.d.mts.map +0 -1
- package/internal/utils/log.d.ts +0 -37
- package/internal/utils/log.d.ts.map +0 -1
- package/internal/utils/log.js +0 -86
- package/internal/utils/log.js.map +0 -1
- package/internal/utils/log.mjs +0 -80
- package/internal/utils/log.mjs.map +0 -1
- package/internal/utils/path.d.mts +0 -15
- package/internal/utils/path.d.mts.map +0 -1
- package/internal/utils/path.d.ts +0 -15
- package/internal/utils/path.d.ts.map +0 -1
- package/internal/utils/path.js +0 -79
- package/internal/utils/path.js.map +0 -1
- package/internal/utils/path.mjs +0 -74
- package/internal/utils/path.mjs.map +0 -1
- package/internal/utils/sleep.d.mts +0 -2
- package/internal/utils/sleep.d.mts.map +0 -1
- package/internal/utils/sleep.d.ts +0 -2
- package/internal/utils/sleep.d.ts.map +0 -1
- package/internal/utils/sleep.js +0 -7
- package/internal/utils/sleep.js.map +0 -1
- package/internal/utils/sleep.mjs +0 -3
- package/internal/utils/sleep.mjs.map +0 -1
- package/internal/utils/uuid.d.mts +0 -5
- package/internal/utils/uuid.d.mts.map +0 -1
- package/internal/utils/uuid.d.ts +0 -5
- package/internal/utils/uuid.d.ts.map +0 -1
- package/internal/utils/uuid.js +0 -19
- package/internal/utils/uuid.js.map +0 -1
- package/internal/utils/uuid.mjs +0 -15
- package/internal/utils/uuid.mjs.map +0 -1
- package/internal/utils/values.d.mts +0 -18
- package/internal/utils/values.d.mts.map +0 -1
- package/internal/utils/values.d.ts +0 -18
- package/internal/utils/values.d.ts.map +0 -1
- package/internal/utils/values.js +0 -112
- package/internal/utils/values.js.map +0 -1
- package/internal/utils/values.mjs +0 -94
- package/internal/utils/values.mjs.map +0 -1
- package/internal/utils.d.mts +0 -7
- package/internal/utils.d.mts.map +0 -1
- package/internal/utils.d.ts +0 -7
- package/internal/utils.d.ts.map +0 -1
- package/internal/utils.js +0 -11
- package/internal/utils.js.map +0 -1
- package/internal/utils.mjs +0 -8
- package/internal/utils.mjs.map +0 -1
- package/resource.d.mts +0 -2
- package/resource.d.mts.map +0 -1
- package/resources/assets.d.mts +0 -65
- package/resources/assets.d.mts.map +0 -1
- package/resources/auctions/auctions.d.mts +0 -368
- package/resources/auctions/auctions.d.mts.map +0 -1
- package/resources/auctions/index.d.mts +0 -3
- package/resources/auctions/index.d.mts.map +0 -1
- package/resources/auctions/website-user-attributes/index.d.mts +0 -3
- package/resources/auctions/website-user-attributes/index.d.mts.map +0 -1
- package/resources/auctions/website-user-attributes/values.d.mts +0 -127
- package/resources/auctions/website-user-attributes/values.d.mts.map +0 -1
- package/resources/auctions/website-user-attributes/website-user-attributes.d.mts +0 -136
- package/resources/auctions/website-user-attributes/website-user-attributes.d.mts.map +0 -1
- package/resources/auctions/website-user-attributes.d.mts +0 -2
- package/resources/auctions/website-user-attributes.d.mts.map +0 -1
- package/resources/auctions.d.mts +0 -2
- package/resources/auctions.d.mts.map +0 -1
- package/resources/auth.d.mts +0 -53
- package/resources/auth.d.mts.map +0 -1
- package/resources/index.d.mts +0 -10
- package/resources/index.d.mts.map +0 -1
- package/resources/loyalty/account-streaks.d.mts +0 -97
- package/resources/loyalty/account-streaks.d.mts.map +0 -1
- package/resources/loyalty/accounts.d.mts +0 -238
- package/resources/loyalty/accounts.d.mts.map +0 -1
- package/resources/loyalty/badges.d.mts +0 -1398
- package/resources/loyalty/badges.d.mts.map +0 -1
- package/resources/loyalty/currencies.d.mts +0 -272
- package/resources/loyalty/currencies.d.mts.map +0 -1
- package/resources/loyalty/index.d.mts +0 -13
- package/resources/loyalty/index.d.mts.map +0 -1
- package/resources/loyalty/loyalty.d.mts +0 -50
- package/resources/loyalty/loyalty.d.mts.map +0 -1
- package/resources/loyalty/multipliers.d.mts +0 -221
- package/resources/loyalty/multipliers.d.mts.map +0 -1
- package/resources/loyalty/questions-responses.d.mts +0 -148
- package/resources/loyalty/questions-responses.d.mts.map +0 -1
- package/resources/loyalty/questions.d.mts +0 -205
- package/resources/loyalty/questions.d.mts.map +0 -1
- package/resources/loyalty/rule-edits.d.mts +0 -3165
- package/resources/loyalty/rule-edits.d.mts.map +0 -1
- package/resources/loyalty/rule-groups.d.mts +0 -826
- package/resources/loyalty/rule-groups.d.mts.map +0 -1
- package/resources/loyalty/rules.d.mts +0 -4543
- package/resources/loyalty/rules.d.mts.map +0 -1
- package/resources/loyalty/transactions/index.d.mts +0 -4
- package/resources/loyalty/transactions/index.d.mts.map +0 -1
- package/resources/loyalty/transactions/posts.d.mts +0 -145
- package/resources/loyalty/transactions/posts.d.mts.map +0 -1
- package/resources/loyalty/transactions/rule-statuses.d.mts +0 -121
- package/resources/loyalty/transactions/rule-statuses.d.mts.map +0 -1
- package/resources/loyalty/transactions/transactions.d.mts +0 -564
- package/resources/loyalty/transactions/transactions.d.mts.map +0 -1
- package/resources/loyalty/transactions.d.mts +0 -2
- package/resources/loyalty/transactions.d.mts.map +0 -1
- package/resources/loyalty.d.mts +0 -2
- package/resources/loyalty.d.mts.map +0 -1
- package/resources/minting/allowlist.d.mts +0 -85
- package/resources/minting/allowlist.d.mts.map +0 -1
- package/resources/minting/contracts.d.mts +0 -165
- package/resources/minting/contracts.d.mts.map +0 -1
- package/resources/minting/index.d.mts +0 -5
- package/resources/minting/index.d.mts.map +0 -1
- package/resources/minting/minting.d.mts +0 -143
- package/resources/minting/minting.d.mts.map +0 -1
- package/resources/minting/status.d.mts +0 -45
- package/resources/minting/status.d.mts.map +0 -1
- package/resources/minting.d.mts +0 -2
- package/resources/minting.d.mts.map +0 -1
- package/resources/referral/index.d.mts +0 -3
- package/resources/referral/index.d.mts.map +0 -1
- package/resources/referral/referral.d.mts +0 -41
- package/resources/referral/referral.d.mts.map +0 -1
- package/resources/referral/users.d.mts +0 -84
- package/resources/referral/users.d.mts.map +0 -1
- package/resources/referral.d.mts +0 -2
- package/resources/referral.d.mts.map +0 -1
- package/resources/token-claims.d.mts +0 -159
- package/resources/token-claims.d.mts.map +0 -1
- package/resources/users/index.d.mts +0 -3
- package/resources/users/index.d.mts.map +0 -1
- package/resources/users/metadatas.d.mts +0 -174
- package/resources/users/metadatas.d.mts.map +0 -1
- package/resources/users/users.d.mts +0 -465
- package/resources/users/users.d.mts.map +0 -1
- package/resources/users.d.mts +0 -2
- package/resources/users.d.mts.map +0 -1
- package/resources/websites/index.d.mts +0 -4
- package/resources/websites/index.d.mts.map +0 -1
- package/resources/websites/website-collections.d.mts +0 -95
- package/resources/websites/website-collections.d.mts.map +0 -1
- package/resources/websites/website-user-roles.d.mts +0 -97
- package/resources/websites/website-user-roles.d.mts.map +0 -1
- package/resources/websites/websites.d.mts +0 -329
- package/resources/websites/websites.d.mts.map +0 -1
- package/resources/websites.d.mts +0 -2
- package/resources/websites.d.mts.map +0 -1
- package/resources.d.mts +0 -2
- package/resources.d.mts.map +0 -1
- package/src/api-promise.ts +0 -2
- package/src/client.ts +0 -868
- package/src/core/README.md +0 -3
- package/src/core/api-promise.ts +0 -92
- package/src/core/error.ts +0 -130
- package/src/core/resource.ts +0 -11
- package/src/core/uploads.ts +0 -2
- package/src/internal/README.md +0 -3
- package/src/internal/builtin-types.ts +0 -93
- package/src/internal/detect-platform.ts +0 -196
- package/src/internal/errors.ts +0 -33
- package/src/internal/headers.ts +0 -97
- package/src/internal/parse.ts +0 -56
- package/src/internal/request-options.ts +0 -91
- package/src/internal/shim-types.ts +0 -26
- package/src/internal/shims.ts +0 -107
- package/src/internal/to-file.ts +0 -154
- package/src/internal/types.ts +0 -95
- package/src/internal/uploads.ts +0 -187
- package/src/internal/utils/base64.ts +0 -40
- package/src/internal/utils/bytes.ts +0 -32
- package/src/internal/utils/env.ts +0 -18
- package/src/internal/utils/log.ts +0 -127
- package/src/internal/utils/path.ts +0 -88
- package/src/internal/utils/sleep.ts +0 -3
- package/src/internal/utils/uuid.ts +0 -17
- package/src/internal/utils/values.ts +0 -105
- package/src/internal/utils.ts +0 -8
- package/uploads.d.mts +0 -2
- package/uploads.d.mts.map +0 -1
- package/version.d.mts +0 -2
- package/version.d.mts.map +0 -1
package/src/error.ts
CHANGED
|
@@ -1,2 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { castToError, Headers } from './core';
|
|
4
|
+
|
|
5
|
+
export class SnagSolutionsError extends Error {}
|
|
6
|
+
|
|
7
|
+
export class APIError<
|
|
8
|
+
TStatus extends number | undefined = number | undefined,
|
|
9
|
+
THeaders extends Headers | undefined = Headers | undefined,
|
|
10
|
+
TError extends Object | undefined = Object | undefined,
|
|
11
|
+
> extends SnagSolutionsError {
|
|
12
|
+
/** HTTP status for the response that caused the error */
|
|
13
|
+
readonly status: TStatus;
|
|
14
|
+
/** HTTP headers for the response that caused the error */
|
|
15
|
+
readonly headers: THeaders;
|
|
16
|
+
/** JSON body of the response that caused the error */
|
|
17
|
+
readonly error: TError;
|
|
18
|
+
|
|
19
|
+
constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
|
|
20
|
+
super(`${APIError.makeMessage(status, error, message)}`);
|
|
21
|
+
this.status = status;
|
|
22
|
+
this.headers = headers;
|
|
23
|
+
this.error = error;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
27
|
+
const msg =
|
|
28
|
+
error?.message ?
|
|
29
|
+
typeof error.message === 'string' ?
|
|
30
|
+
error.message
|
|
31
|
+
: JSON.stringify(error.message)
|
|
32
|
+
: error ? JSON.stringify(error)
|
|
33
|
+
: message;
|
|
34
|
+
|
|
35
|
+
if (status && msg) {
|
|
36
|
+
return `${status} ${msg}`;
|
|
37
|
+
}
|
|
38
|
+
if (status) {
|
|
39
|
+
return `${status} status code (no body)`;
|
|
40
|
+
}
|
|
41
|
+
if (msg) {
|
|
42
|
+
return msg;
|
|
43
|
+
}
|
|
44
|
+
return '(no status code or body)';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static generate(
|
|
48
|
+
status: number | undefined,
|
|
49
|
+
errorResponse: Object | undefined,
|
|
50
|
+
message: string | undefined,
|
|
51
|
+
headers: Headers | undefined,
|
|
52
|
+
): APIError {
|
|
53
|
+
if (!status || !headers) {
|
|
54
|
+
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const error = errorResponse as Record<string, any>;
|
|
58
|
+
|
|
59
|
+
if (status === 400) {
|
|
60
|
+
return new BadRequestError(status, error, message, headers);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (status === 401) {
|
|
64
|
+
return new AuthenticationError(status, error, message, headers);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (status === 403) {
|
|
68
|
+
return new PermissionDeniedError(status, error, message, headers);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (status === 404) {
|
|
72
|
+
return new NotFoundError(status, error, message, headers);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (status === 409) {
|
|
76
|
+
return new ConflictError(status, error, message, headers);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (status === 422) {
|
|
80
|
+
return new UnprocessableEntityError(status, error, message, headers);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (status === 429) {
|
|
84
|
+
return new RateLimitError(status, error, message, headers);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (status >= 500) {
|
|
88
|
+
return new InternalServerError(status, error, message, headers);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return new APIError(status, error, message, headers);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export class APIUserAbortError extends APIError<undefined, undefined, undefined> {
|
|
96
|
+
constructor({ message }: { message?: string } = {}) {
|
|
97
|
+
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class APIConnectionError extends APIError<undefined, undefined, undefined> {
|
|
102
|
+
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
103
|
+
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
104
|
+
// in some environments the 'cause' property is already declared
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
if (cause) this.cause = cause;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
111
|
+
constructor({ message }: { message?: string } = {}) {
|
|
112
|
+
super({ message: message ?? 'Request timed out.' });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export class BadRequestError extends APIError<400, Headers> {}
|
|
117
|
+
|
|
118
|
+
export class AuthenticationError extends APIError<401, Headers> {}
|
|
119
|
+
|
|
120
|
+
export class PermissionDeniedError extends APIError<403, Headers> {}
|
|
121
|
+
|
|
122
|
+
export class NotFoundError extends APIError<404, Headers> {}
|
|
123
|
+
|
|
124
|
+
export class ConflictError extends APIError<409, Headers> {}
|
|
125
|
+
|
|
126
|
+
export class UnprocessableEntityError extends APIError<422, Headers> {}
|
|
127
|
+
|
|
128
|
+
export class RateLimitError extends APIError<429, Headers> {}
|
|
129
|
+
|
|
130
|
+
export class InternalServerError extends APIError<number, Headers> {}
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,345 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { type Agent } from './_shims/index';
|
|
4
|
+
import * as qs from './internal/qs';
|
|
5
|
+
import * as Core from './core';
|
|
6
|
+
import * as Errors from './error';
|
|
7
|
+
import * as Uploads from './uploads';
|
|
8
|
+
import * as API from './resources/index';
|
|
9
|
+
import { AssetCreateAssetParams, AssetCreateAssetResponse, Assets } from './resources/assets';
|
|
10
|
+
import {
|
|
11
|
+
Auth,
|
|
12
|
+
AuthConnectAuthParams,
|
|
13
|
+
AuthConnectAuthResponse,
|
|
14
|
+
AuthConnectAuthVerifyParams,
|
|
15
|
+
AuthConnectAuthVerifyResponse,
|
|
16
|
+
} from './resources/auth';
|
|
17
|
+
import {
|
|
18
|
+
TokenClaimCheckEligibilityParams,
|
|
19
|
+
TokenClaimCheckEligibilityResponse,
|
|
20
|
+
TokenClaimGetProofParams,
|
|
21
|
+
TokenClaimGetProofResponse,
|
|
22
|
+
TokenClaimListParams,
|
|
23
|
+
TokenClaimListResponse,
|
|
24
|
+
TokenClaimListUsersParams,
|
|
25
|
+
TokenClaimListUsersResponse,
|
|
26
|
+
TokenClaimRetrieveParams,
|
|
27
|
+
TokenClaimRetrieveResponse,
|
|
28
|
+
TokenClaimUpdateClaimParams,
|
|
29
|
+
TokenClaimUpdateClaimResponse,
|
|
30
|
+
TokenClaims,
|
|
31
|
+
} from './resources/token-claims';
|
|
32
|
+
import {
|
|
33
|
+
AuctionGetPageSectionsParams,
|
|
34
|
+
AuctionGetPageSectionsResponse,
|
|
35
|
+
AuctionListAuctionBidsParams,
|
|
36
|
+
AuctionListAuctionBidsResponse,
|
|
37
|
+
AuctionListAuctionsResponse,
|
|
38
|
+
Auctions,
|
|
39
|
+
} from './resources/auctions/auctions';
|
|
40
|
+
import { Loyalty } from './resources/loyalty/loyalty';
|
|
41
|
+
import {
|
|
42
|
+
Minting,
|
|
43
|
+
MintingGetAssetsParams,
|
|
44
|
+
MintingGetAssetsResponse,
|
|
45
|
+
MintingGetTokenGateStatusParams,
|
|
46
|
+
MintingGetTokenGateStatusResponse,
|
|
47
|
+
} from './resources/minting/minting';
|
|
48
|
+
import {
|
|
49
|
+
Referral,
|
|
50
|
+
ReferralCreateCodeParams,
|
|
51
|
+
ReferralCreateCodeResponse,
|
|
52
|
+
} from './resources/referral/referral';
|
|
53
|
+
import {
|
|
54
|
+
UserConnectParams,
|
|
55
|
+
UserConnectResponse,
|
|
56
|
+
UserCountParams,
|
|
57
|
+
UserCountResponse,
|
|
58
|
+
UserCreateDeviceParams,
|
|
59
|
+
UserCreateDeviceResponse,
|
|
60
|
+
UserDisconnectParams,
|
|
61
|
+
UserDisconnectResponse,
|
|
62
|
+
UserListParams,
|
|
63
|
+
UserListResponse,
|
|
64
|
+
UserVerifyParams,
|
|
65
|
+
UserVerifyResponse,
|
|
66
|
+
Users,
|
|
67
|
+
} from './resources/users/users';
|
|
68
|
+
import {
|
|
69
|
+
WebsiteCreateParams,
|
|
70
|
+
WebsiteCreateResponse,
|
|
71
|
+
WebsiteListParams,
|
|
72
|
+
WebsiteListResponse,
|
|
73
|
+
Websites,
|
|
74
|
+
} from './resources/websites/websites';
|
|
4
75
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
76
|
+
export interface ClientOptions {
|
|
77
|
+
/**
|
|
78
|
+
* API key required to authenticate with the Snag Solutions API.
|
|
79
|
+
*/
|
|
80
|
+
apiKey?: string | undefined;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
84
|
+
*
|
|
85
|
+
* Defaults to process.env['SNAG_SOLUTIONS_BASE_URL'].
|
|
86
|
+
*/
|
|
87
|
+
baseURL?: string | null | undefined;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
91
|
+
* from the server before timing out a single request.
|
|
92
|
+
*
|
|
93
|
+
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
94
|
+
* much longer than this timeout before the promise succeeds or fails.
|
|
95
|
+
*
|
|
96
|
+
* @unit milliseconds
|
|
97
|
+
*/
|
|
98
|
+
timeout?: number | undefined;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* An HTTP agent used to manage HTTP(S) connections.
|
|
102
|
+
*
|
|
103
|
+
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
104
|
+
* otherwise no agent is used.
|
|
105
|
+
*/
|
|
106
|
+
httpAgent?: Agent | undefined;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Specify a custom `fetch` function implementation.
|
|
110
|
+
*
|
|
111
|
+
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
112
|
+
* defined globally.
|
|
113
|
+
*/
|
|
114
|
+
fetch?: Core.Fetch | undefined;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
118
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
119
|
+
*
|
|
120
|
+
* @default 2
|
|
121
|
+
*/
|
|
122
|
+
maxRetries?: number | undefined;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Default headers to include with every request to the API.
|
|
126
|
+
*
|
|
127
|
+
* These can be removed in individual requests by explicitly setting the
|
|
128
|
+
* header to `undefined` or `null` in request options.
|
|
129
|
+
*/
|
|
130
|
+
defaultHeaders?: Core.Headers | undefined;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Default query parameters to include with every request to the API.
|
|
134
|
+
*
|
|
135
|
+
* These can be removed in individual requests by explicitly setting the
|
|
136
|
+
* param to `undefined` in request options.
|
|
137
|
+
*/
|
|
138
|
+
defaultQuery?: Core.DefaultQuery | undefined;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* API Client for interfacing with the Snag Solutions API.
|
|
143
|
+
*/
|
|
144
|
+
export class SnagSolutions extends Core.APIClient {
|
|
145
|
+
apiKey: string;
|
|
146
|
+
|
|
147
|
+
private _options: ClientOptions;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* API Client for interfacing with the Snag Solutions API.
|
|
151
|
+
*
|
|
152
|
+
* @param {string | undefined} [opts.apiKey=process.env['X_API_KEY'] ?? undefined]
|
|
153
|
+
* @param {string} [opts.baseURL=process.env['SNAG_SOLUTIONS_BASE_URL'] ?? https://admin.snagsolutions.io/] - Override the default base URL for the API.
|
|
154
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
155
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
156
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
157
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
158
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
159
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
160
|
+
*/
|
|
161
|
+
constructor({
|
|
162
|
+
baseURL = Core.readEnv('SNAG_SOLUTIONS_BASE_URL'),
|
|
163
|
+
apiKey = Core.readEnv('X_API_KEY'),
|
|
164
|
+
...opts
|
|
165
|
+
}: ClientOptions = {}) {
|
|
166
|
+
if (apiKey === undefined) {
|
|
167
|
+
throw new Errors.SnagSolutionsError(
|
|
168
|
+
"The X_API_KEY environment variable is missing or empty; either provide it, or instantiate the SnagSolutions client with an apiKey option, like new SnagSolutions({ apiKey: 'My API Key' }).",
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const options: ClientOptions = {
|
|
173
|
+
apiKey,
|
|
174
|
+
...opts,
|
|
175
|
+
baseURL: baseURL || `https://admin.snagsolutions.io/`,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
super({
|
|
179
|
+
baseURL: options.baseURL!,
|
|
180
|
+
baseURLOverridden: baseURL ? baseURL !== 'https://admin.snagsolutions.io/' : false,
|
|
181
|
+
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
182
|
+
httpAgent: options.httpAgent,
|
|
183
|
+
maxRetries: options.maxRetries,
|
|
184
|
+
fetch: options.fetch,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
this._options = options;
|
|
188
|
+
|
|
189
|
+
this.apiKey = apiKey;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
assets: API.Assets = new API.Assets(this);
|
|
193
|
+
auth: API.Auth = new API.Auth(this);
|
|
194
|
+
auctions: API.Auctions = new API.Auctions(this);
|
|
195
|
+
users: API.Users = new API.Users(this);
|
|
196
|
+
loyalty: API.Loyalty = new API.Loyalty(this);
|
|
197
|
+
minting: API.Minting = new API.Minting(this);
|
|
198
|
+
referral: API.Referral = new API.Referral(this);
|
|
199
|
+
websites: API.Websites = new API.Websites(this);
|
|
200
|
+
tokenClaims: API.TokenClaims = new API.TokenClaims(this);
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Check whether the base URL is set to its default.
|
|
204
|
+
*/
|
|
205
|
+
#baseURLOverridden(): boolean {
|
|
206
|
+
return this.baseURL !== 'https://admin.snagsolutions.io/';
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
210
|
+
return this._options.defaultQuery;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
214
|
+
return {
|
|
215
|
+
...super.defaultHeaders(opts),
|
|
216
|
+
...this._options.defaultHeaders,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
221
|
+
return { 'X-API-KEY': this.apiKey };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
protected override stringifyQuery(query: Record<string, unknown>): string {
|
|
225
|
+
return qs.stringify(query, { arrayFormat: 'repeat' });
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
static SnagSolutions = this;
|
|
229
|
+
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
230
|
+
|
|
231
|
+
static SnagSolutionsError = Errors.SnagSolutionsError;
|
|
232
|
+
static APIError = Errors.APIError;
|
|
233
|
+
static APIConnectionError = Errors.APIConnectionError;
|
|
234
|
+
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
235
|
+
static APIUserAbortError = Errors.APIUserAbortError;
|
|
236
|
+
static NotFoundError = Errors.NotFoundError;
|
|
237
|
+
static ConflictError = Errors.ConflictError;
|
|
238
|
+
static RateLimitError = Errors.RateLimitError;
|
|
239
|
+
static BadRequestError = Errors.BadRequestError;
|
|
240
|
+
static AuthenticationError = Errors.AuthenticationError;
|
|
241
|
+
static InternalServerError = Errors.InternalServerError;
|
|
242
|
+
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
243
|
+
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
244
|
+
|
|
245
|
+
static toFile = Uploads.toFile;
|
|
246
|
+
static fileFromPath = Uploads.fileFromPath;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
SnagSolutions.Assets = Assets;
|
|
250
|
+
SnagSolutions.Auth = Auth;
|
|
251
|
+
SnagSolutions.Auctions = Auctions;
|
|
252
|
+
SnagSolutions.Users = Users;
|
|
253
|
+
SnagSolutions.Loyalty = Loyalty;
|
|
254
|
+
SnagSolutions.Minting = Minting;
|
|
255
|
+
SnagSolutions.Referral = Referral;
|
|
256
|
+
SnagSolutions.Websites = Websites;
|
|
257
|
+
SnagSolutions.TokenClaims = TokenClaims;
|
|
258
|
+
|
|
259
|
+
export declare namespace SnagSolutions {
|
|
260
|
+
export type RequestOptions = Core.RequestOptions;
|
|
261
|
+
|
|
262
|
+
export {
|
|
263
|
+
Assets as Assets,
|
|
264
|
+
type AssetCreateAssetResponse as AssetCreateAssetResponse,
|
|
265
|
+
type AssetCreateAssetParams as AssetCreateAssetParams,
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export {
|
|
269
|
+
Auth as Auth,
|
|
270
|
+
type AuthConnectAuthResponse as AuthConnectAuthResponse,
|
|
271
|
+
type AuthConnectAuthVerifyResponse as AuthConnectAuthVerifyResponse,
|
|
272
|
+
type AuthConnectAuthParams as AuthConnectAuthParams,
|
|
273
|
+
type AuthConnectAuthVerifyParams as AuthConnectAuthVerifyParams,
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export {
|
|
277
|
+
Auctions as Auctions,
|
|
278
|
+
type AuctionGetPageSectionsResponse as AuctionGetPageSectionsResponse,
|
|
279
|
+
type AuctionListAuctionBidsResponse as AuctionListAuctionBidsResponse,
|
|
280
|
+
type AuctionListAuctionsResponse as AuctionListAuctionsResponse,
|
|
281
|
+
type AuctionGetPageSectionsParams as AuctionGetPageSectionsParams,
|
|
282
|
+
type AuctionListAuctionBidsParams as AuctionListAuctionBidsParams,
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export {
|
|
286
|
+
Users as Users,
|
|
287
|
+
type UserListResponse as UserListResponse,
|
|
288
|
+
type UserConnectResponse as UserConnectResponse,
|
|
289
|
+
type UserCountResponse as UserCountResponse,
|
|
290
|
+
type UserCreateDeviceResponse as UserCreateDeviceResponse,
|
|
291
|
+
type UserDisconnectResponse as UserDisconnectResponse,
|
|
292
|
+
type UserVerifyResponse as UserVerifyResponse,
|
|
293
|
+
type UserListParams as UserListParams,
|
|
294
|
+
type UserConnectParams as UserConnectParams,
|
|
295
|
+
type UserCountParams as UserCountParams,
|
|
296
|
+
type UserCreateDeviceParams as UserCreateDeviceParams,
|
|
297
|
+
type UserDisconnectParams as UserDisconnectParams,
|
|
298
|
+
type UserVerifyParams as UserVerifyParams,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export { Loyalty as Loyalty };
|
|
302
|
+
|
|
303
|
+
export {
|
|
304
|
+
Minting as Minting,
|
|
305
|
+
type MintingGetAssetsResponse as MintingGetAssetsResponse,
|
|
306
|
+
type MintingGetTokenGateStatusResponse as MintingGetTokenGateStatusResponse,
|
|
307
|
+
type MintingGetAssetsParams as MintingGetAssetsParams,
|
|
308
|
+
type MintingGetTokenGateStatusParams as MintingGetTokenGateStatusParams,
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
export {
|
|
312
|
+
Referral as Referral,
|
|
313
|
+
type ReferralCreateCodeResponse as ReferralCreateCodeResponse,
|
|
314
|
+
type ReferralCreateCodeParams as ReferralCreateCodeParams,
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
export {
|
|
318
|
+
Websites as Websites,
|
|
319
|
+
type WebsiteCreateResponse as WebsiteCreateResponse,
|
|
320
|
+
type WebsiteListResponse as WebsiteListResponse,
|
|
321
|
+
type WebsiteCreateParams as WebsiteCreateParams,
|
|
322
|
+
type WebsiteListParams as WebsiteListParams,
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
export {
|
|
326
|
+
TokenClaims as TokenClaims,
|
|
327
|
+
type TokenClaimRetrieveResponse as TokenClaimRetrieveResponse,
|
|
328
|
+
type TokenClaimListResponse as TokenClaimListResponse,
|
|
329
|
+
type TokenClaimCheckEligibilityResponse as TokenClaimCheckEligibilityResponse,
|
|
330
|
+
type TokenClaimGetProofResponse as TokenClaimGetProofResponse,
|
|
331
|
+
type TokenClaimListUsersResponse as TokenClaimListUsersResponse,
|
|
332
|
+
type TokenClaimUpdateClaimResponse as TokenClaimUpdateClaimResponse,
|
|
333
|
+
type TokenClaimRetrieveParams as TokenClaimRetrieveParams,
|
|
334
|
+
type TokenClaimListParams as TokenClaimListParams,
|
|
335
|
+
type TokenClaimCheckEligibilityParams as TokenClaimCheckEligibilityParams,
|
|
336
|
+
type TokenClaimGetProofParams as TokenClaimGetProofParams,
|
|
337
|
+
type TokenClaimListUsersParams as TokenClaimListUsersParams,
|
|
338
|
+
type TokenClaimUpdateClaimParams as TokenClaimUpdateClaimParams,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export { toFile, fileFromPath } from './uploads';
|
|
8
343
|
export {
|
|
9
344
|
SnagSolutionsError,
|
|
10
345
|
APIError,
|
|
@@ -19,4 +354,6 @@ export {
|
|
|
19
354
|
InternalServerError,
|
|
20
355
|
PermissionDeniedError,
|
|
21
356
|
UnprocessableEntityError,
|
|
22
|
-
} from './
|
|
357
|
+
} from './error';
|
|
358
|
+
|
|
359
|
+
export default SnagSolutions;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { Format } from './types';
|
|
2
2
|
|
|
3
3
|
export const default_format: Format = 'RFC3986';
|
|
4
|
-
export const default_formatter = (v: PropertyKey) => String(v);
|
|
5
4
|
export const formatters: Record<Format, (str: PropertyKey) => string> = {
|
|
6
5
|
RFC1738: (v: PropertyKey) => String(v).replace(/%20/g, '+'),
|
|
7
|
-
RFC3986:
|
|
6
|
+
RFC3986: (v: PropertyKey) => String(v),
|
|
8
7
|
};
|
|
9
8
|
export const RFC1738 = 'RFC1738';
|
|
10
9
|
export const RFC3986 = 'RFC3986';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { encode, is_buffer, maybe_map
|
|
2
|
-
import { default_format,
|
|
1
|
+
import { encode, is_buffer, maybe_map } from './utils';
|
|
2
|
+
import { default_format, formatters } from './formats';
|
|
3
3
|
import type { NonNullableProperties, StringifyOptions } from './types';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const has = Object.prototype.hasOwnProperty;
|
|
5
6
|
|
|
6
7
|
const array_prefix_generators = {
|
|
7
8
|
brackets(prefix: PropertyKey) {
|
|
@@ -16,11 +17,13 @@ const array_prefix_generators = {
|
|
|
16
17
|
},
|
|
17
18
|
};
|
|
18
19
|
|
|
20
|
+
const is_array = Array.isArray;
|
|
21
|
+
const push = Array.prototype.push;
|
|
19
22
|
const push_to_array = function (arr: any[], value_or_array: any) {
|
|
20
|
-
|
|
23
|
+
push.apply(arr, is_array(value_or_array) ? value_or_array : [value_or_array]);
|
|
21
24
|
};
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
const to_ISO = Date.prototype.toISOString;
|
|
24
27
|
|
|
25
28
|
const defaults = {
|
|
26
29
|
addQueryPrefix: false,
|
|
@@ -35,11 +38,11 @@ const defaults = {
|
|
|
35
38
|
encoder: encode,
|
|
36
39
|
encodeValuesOnly: false,
|
|
37
40
|
format: default_format,
|
|
38
|
-
formatter:
|
|
41
|
+
formatter: formatters[default_format],
|
|
39
42
|
/** @deprecated */
|
|
40
43
|
indices: false,
|
|
41
44
|
serializeDate(date) {
|
|
42
|
-
return
|
|
45
|
+
return to_ISO.call(date);
|
|
43
46
|
},
|
|
44
47
|
skipNulls: false,
|
|
45
48
|
strictNullHandling: false,
|
|
@@ -102,7 +105,7 @@ function inner_stringify(
|
|
|
102
105
|
obj = filter(prefix, obj);
|
|
103
106
|
} else if (obj instanceof Date) {
|
|
104
107
|
obj = serializeDate?.(obj);
|
|
105
|
-
} else if (generateArrayPrefix === 'comma' &&
|
|
108
|
+
} else if (generateArrayPrefix === 'comma' && is_array(obj)) {
|
|
106
109
|
obj = maybe_map(obj, function (value) {
|
|
107
110
|
if (value instanceof Date) {
|
|
108
111
|
return serializeDate?.(value);
|
|
@@ -145,14 +148,14 @@ function inner_stringify(
|
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
let obj_keys;
|
|
148
|
-
if (generateArrayPrefix === 'comma' &&
|
|
151
|
+
if (generateArrayPrefix === 'comma' && is_array(obj)) {
|
|
149
152
|
// we need to join elements in
|
|
150
153
|
if (encodeValuesOnly && encoder) {
|
|
151
154
|
// @ts-expect-error values only
|
|
152
155
|
obj = maybe_map(obj, encoder);
|
|
153
156
|
}
|
|
154
157
|
obj_keys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
|
|
155
|
-
} else if (
|
|
158
|
+
} else if (is_array(filter)) {
|
|
156
159
|
obj_keys = filter;
|
|
157
160
|
} else {
|
|
158
161
|
const keys = Object.keys(obj);
|
|
@@ -162,9 +165,9 @@ function inner_stringify(
|
|
|
162
165
|
const encoded_prefix = encodeDotInKeys ? String(prefix).replace(/\./g, '%2E') : String(prefix);
|
|
163
166
|
|
|
164
167
|
const adjusted_prefix =
|
|
165
|
-
commaRoundTrip &&
|
|
168
|
+
commaRoundTrip && is_array(obj) && obj.length === 1 ? encoded_prefix + '[]' : encoded_prefix;
|
|
166
169
|
|
|
167
|
-
if (allowEmptyArrays &&
|
|
170
|
+
if (allowEmptyArrays && is_array(obj) && obj.length === 0) {
|
|
168
171
|
return adjusted_prefix + '[]';
|
|
169
172
|
}
|
|
170
173
|
|
|
@@ -181,7 +184,7 @@ function inner_stringify(
|
|
|
181
184
|
// @ts-ignore
|
|
182
185
|
const encoded_key = allowDots && encodeDotInKeys ? (key as any).replace(/\./g, '%2E') : key;
|
|
183
186
|
const key_prefix =
|
|
184
|
-
|
|
187
|
+
is_array(obj) ?
|
|
185
188
|
typeof generateArrayPrefix === 'function' ?
|
|
186
189
|
generateArrayPrefix(adjusted_prefix, encoded_key)
|
|
187
190
|
: adjusted_prefix
|
|
@@ -202,7 +205,7 @@ function inner_stringify(
|
|
|
202
205
|
skipNulls,
|
|
203
206
|
encodeDotInKeys,
|
|
204
207
|
// @ts-ignore
|
|
205
|
-
generateArrayPrefix === 'comma' && encodeValuesOnly &&
|
|
208
|
+
generateArrayPrefix === 'comma' && encodeValuesOnly && is_array(obj) ? null : encoder,
|
|
206
209
|
filter,
|
|
207
210
|
sort,
|
|
208
211
|
allowDots,
|
|
@@ -241,7 +244,7 @@ function normalize_stringify_options(
|
|
|
241
244
|
|
|
242
245
|
let format = default_format;
|
|
243
246
|
if (typeof opts.format !== 'undefined') {
|
|
244
|
-
if (!has(formatters, opts.format)) {
|
|
247
|
+
if (!has.call(formatters, opts.format)) {
|
|
245
248
|
throw new TypeError('Unknown format option provided.');
|
|
246
249
|
}
|
|
247
250
|
format = opts.format;
|
|
@@ -249,7 +252,7 @@ function normalize_stringify_options(
|
|
|
249
252
|
const formatter = formatters[format];
|
|
250
253
|
|
|
251
254
|
let filter = defaults.filter;
|
|
252
|
-
if (typeof opts.filter === 'function' ||
|
|
255
|
+
if (typeof opts.filter === 'function' || is_array(opts.filter)) {
|
|
253
256
|
filter = opts.filter;
|
|
254
257
|
}
|
|
255
258
|
|
|
@@ -313,7 +316,7 @@ export function stringify(object: any, opts: StringifyOptions = {}) {
|
|
|
313
316
|
if (typeof options.filter === 'function') {
|
|
314
317
|
filter = options.filter;
|
|
315
318
|
obj = filter('', obj);
|
|
316
|
-
} else if (
|
|
319
|
+
} else if (is_array(options.filter)) {
|
|
317
320
|
filter = options.filter;
|
|
318
321
|
obj_keys = filter;
|
|
319
322
|
}
|
package/src/internal/qs/utils.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { RFC1738 } from './formats';
|
|
2
2
|
import type { DefaultEncoder, Format } from './types';
|
|
3
|
-
import { isArray } from '../utils/values';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
has(obj, key)
|
|
8
|
-
);
|
|
4
|
+
const has = Object.prototype.hasOwnProperty;
|
|
5
|
+
const is_array = Array.isArray;
|
|
9
6
|
|
|
10
|
-
const hex_table =
|
|
7
|
+
const hex_table = (() => {
|
|
11
8
|
const array = [];
|
|
12
9
|
for (let i = 0; i < 256; ++i) {
|
|
13
10
|
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
@@ -23,7 +20,7 @@ function compact_queue<T extends Record<string, any>>(queue: Array<{ obj: T; pro
|
|
|
23
20
|
|
|
24
21
|
const obj = item.obj[item.prop];
|
|
25
22
|
|
|
26
|
-
if (
|
|
23
|
+
if (is_array(obj)) {
|
|
27
24
|
const compacted: unknown[] = [];
|
|
28
25
|
|
|
29
26
|
for (let j = 0; j < obj.length; ++j) {
|
|
@@ -59,10 +56,13 @@ export function merge(
|
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
if (typeof source !== 'object') {
|
|
62
|
-
if (
|
|
59
|
+
if (is_array(target)) {
|
|
63
60
|
target.push(source);
|
|
64
61
|
} else if (target && typeof target === 'object') {
|
|
65
|
-
if (
|
|
62
|
+
if (
|
|
63
|
+
(options && (options.plainObjects || options.allowPrototypes)) ||
|
|
64
|
+
!has.call(Object.prototype, source)
|
|
65
|
+
) {
|
|
66
66
|
target[source] = true;
|
|
67
67
|
}
|
|
68
68
|
} else {
|
|
@@ -77,14 +77,14 @@ export function merge(
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
let mergeTarget = target;
|
|
80
|
-
if (
|
|
80
|
+
if (is_array(target) && !is_array(source)) {
|
|
81
81
|
// @ts-ignore
|
|
82
82
|
mergeTarget = array_to_object(target, options);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
if (
|
|
85
|
+
if (is_array(target) && is_array(source)) {
|
|
86
86
|
source.forEach(function (item, i) {
|
|
87
|
-
if (has(target, i)) {
|
|
87
|
+
if (has.call(target, i)) {
|
|
88
88
|
const targetItem = target[i];
|
|
89
89
|
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
90
90
|
target[i] = merge(targetItem, item, options);
|
|
@@ -101,7 +101,7 @@ export function merge(
|
|
|
101
101
|
return Object.keys(source).reduce(function (acc, key) {
|
|
102
102
|
const value = source[key];
|
|
103
103
|
|
|
104
|
-
if (has(acc, key)) {
|
|
104
|
+
if (has.call(acc, key)) {
|
|
105
105
|
acc[key] = merge(acc[key], value, options);
|
|
106
106
|
} else {
|
|
107
107
|
acc[key] = value;
|
|
@@ -254,7 +254,7 @@ export function combine(a: any, b: any) {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
export function maybe_map<T>(val: T[], fn: (v: T) => T) {
|
|
257
|
-
if (
|
|
257
|
+
if (is_array(val)) {
|
|
258
258
|
const mapped = [];
|
|
259
259
|
for (let i = 0; i < val.length; i += 1) {
|
|
260
260
|
mapped.push(fn(val[i]!));
|