@nhost/stripe-graphql-js 1.3.0-beta.5 → 1.3.0-beta7

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.
Files changed (127) hide show
  1. package/README.md +37 -10
  2. package/dist/src/builder.d.ts +2 -2
  3. package/dist/src/builder.d.ts.map +1 -1
  4. package/dist/src/builder.js +1 -1
  5. package/dist/src/builder.js.map +1 -1
  6. package/dist/src/index.d.ts.map +1 -1
  7. package/dist/src/index.js.map +1 -1
  8. package/dist/src/schema/address.js +8 -8
  9. package/dist/src/schema/address.js.map +1 -1
  10. package/dist/src/schema/billing-portal-session.js +9 -9
  11. package/dist/src/schema/billing-portal-session.js.map +1 -1
  12. package/dist/src/schema/charge.js +23 -11
  13. package/dist/src/schema/charge.js.map +1 -1
  14. package/dist/src/schema/charges.js +3 -3
  15. package/dist/src/schema/charges.js.map +1 -1
  16. package/dist/src/schema/connectedAccount.js +2 -2
  17. package/dist/src/schema/connectedAccount.js.map +1 -1
  18. package/dist/src/schema/connectedAccounts.js +3 -3
  19. package/dist/src/schema/connectedAccounts.js.map +1 -1
  20. package/dist/src/schema/customer-shipping.js +7 -7
  21. package/dist/src/schema/customer-shipping.js.map +1 -1
  22. package/dist/src/schema/customer-tax-location.js +4 -4
  23. package/dist/src/schema/customer-tax-location.js.map +1 -1
  24. package/dist/src/schema/customer-tax.js +4 -4
  25. package/dist/src/schema/customer-tax.js.map +1 -1
  26. package/dist/src/schema/customer.js +35 -35
  27. package/dist/src/schema/customer.js.map +1 -1
  28. package/dist/src/schema/customers.js +5 -5
  29. package/dist/src/schema/customers.js.map +1 -1
  30. package/dist/src/schema/index.d.ts.map +1 -1
  31. package/dist/src/schema/index.js.map +1 -1
  32. package/dist/src/schema/invoice-automatic-tax.js +4 -4
  33. package/dist/src/schema/invoice-automatic-tax.js.map +1 -1
  34. package/dist/src/schema/invoice-custom-field.js +4 -4
  35. package/dist/src/schema/invoice-custom-field.js.map +1 -1
  36. package/dist/src/schema/invoice-customer-shipping.js +7 -7
  37. package/dist/src/schema/invoice-customer-shipping.js.map +1 -1
  38. package/dist/src/schema/invoice-customer-tax-id.js +4 -4
  39. package/dist/src/schema/invoice-customer-tax-id.js.map +1 -1
  40. package/dist/src/schema/invoice-line-item-period.js +4 -4
  41. package/dist/src/schema/invoice-line-item-period.js.map +1 -1
  42. package/dist/src/schema/invoice-line-item-tax-amount.js +4 -4
  43. package/dist/src/schema/invoice-line-item-tax-amount.js.map +1 -1
  44. package/dist/src/schema/invoice-line-item.js +21 -21
  45. package/dist/src/schema/invoice-line-item.js.map +1 -1
  46. package/dist/src/schema/invoice-line-items.js +5 -5
  47. package/dist/src/schema/invoice-line-items.js.map +1 -1
  48. package/dist/src/schema/invoice-rendering-options.js +3 -3
  49. package/dist/src/schema/invoice-rendering-options.js.map +1 -1
  50. package/dist/src/schema/invoice-status-transitions.js +6 -6
  51. package/dist/src/schema/invoice-status-transitions.js.map +1 -1
  52. package/dist/src/schema/invoice.js +59 -59
  53. package/dist/src/schema/invoice.js.map +1 -1
  54. package/dist/src/schema/invoices.js +5 -5
  55. package/dist/src/schema/invoices.js.map +1 -1
  56. package/dist/src/schema/payment-intent.js +14 -14
  57. package/dist/src/schema/payment-intent.js.map +1 -1
  58. package/dist/src/schema/payment-intents.js +3 -3
  59. package/dist/src/schema/payment-intents.js.map +1 -1
  60. package/dist/src/schema/payment-method-billing-details.js +6 -6
  61. package/dist/src/schema/payment-method-billing-details.js.map +1 -1
  62. package/dist/src/schema/payment-method-card-checks.js +5 -5
  63. package/dist/src/schema/payment-method-card-checks.js.map +1 -1
  64. package/dist/src/schema/payment-method-card-networks.js +4 -4
  65. package/dist/src/schema/payment-method-card-networks.js.map +1 -1
  66. package/dist/src/schema/payment-method-card-three-d-secure-usage.js +3 -3
  67. package/dist/src/schema/payment-method-card-three-d-secure-usage.js.map +1 -1
  68. package/dist/src/schema/payment-method-card-wallet-masterpass.js +6 -6
  69. package/dist/src/schema/payment-method-card-wallet-masterpass.js.map +1 -1
  70. package/dist/src/schema/payment-method-card-wallet-visa-checkout.js +6 -6
  71. package/dist/src/schema/payment-method-card-wallet-visa-checkout.js.map +1 -1
  72. package/dist/src/schema/payment-method-card-wallet.d.ts.map +1 -1
  73. package/dist/src/schema/payment-method-card-wallet.js +8 -8
  74. package/dist/src/schema/payment-method-card-wallet.js.map +1 -1
  75. package/dist/src/schema/payment-method-card.js +16 -16
  76. package/dist/src/schema/payment-method-card.js.map +1 -1
  77. package/dist/src/schema/payment-method.js +10 -10
  78. package/dist/src/schema/payment-method.js.map +1 -1
  79. package/dist/src/schema/payment-methods.d.ts.map +1 -1
  80. package/dist/src/schema/payment-methods.js +7 -7
  81. package/dist/src/schema/payment-methods.js.map +1 -1
  82. package/dist/src/schema/plan-transform-usage.js +4 -4
  83. package/dist/src/schema/plan-transform-usage.js.map +1 -1
  84. package/dist/src/schema/plan.js +21 -21
  85. package/dist/src/schema/plan.js.map +1 -1
  86. package/dist/src/schema/price.js +17 -17
  87. package/dist/src/schema/price.js.map +1 -1
  88. package/dist/src/schema/product.js +21 -21
  89. package/dist/src/schema/product.js.map +1 -1
  90. package/dist/src/schema/stripe.js +31 -30
  91. package/dist/src/schema/stripe.js.map +1 -1
  92. package/dist/src/schema/subscription-automatic-tax.js +3 -3
  93. package/dist/src/schema/subscription-automatic-tax.js.map +1 -1
  94. package/dist/src/schema/subscription-billing-thresholds.js +4 -4
  95. package/dist/src/schema/subscription-billing-thresholds.js.map +1 -1
  96. package/dist/src/schema/subscription-item-billing-thresholds.js +3 -3
  97. package/dist/src/schema/subscription-item-billing-thresholds.js.map +1 -1
  98. package/dist/src/schema/subscription-item.js +11 -11
  99. package/dist/src/schema/subscription-item.js.map +1 -1
  100. package/dist/src/schema/subscription-items.js +5 -5
  101. package/dist/src/schema/subscription-items.js.map +1 -1
  102. package/dist/src/schema/subscription-pause-collection.js +4 -4
  103. package/dist/src/schema/subscription-pause-collection.js.map +1 -1
  104. package/dist/src/schema/subscription.js +33 -33
  105. package/dist/src/schema/subscription.js.map +1 -1
  106. package/dist/src/schema/subscriptions.js +5 -5
  107. package/dist/src/schema/subscriptions.js.map +1 -1
  108. package/dist/src/schema/tax-rate.js +16 -16
  109. package/dist/src/schema/tax-rate.js.map +1 -1
  110. package/dist/src/schema/test-clock.js +10 -10
  111. package/dist/src/schema/test-clock.js.map +1 -1
  112. package/dist/src/server.d.ts +2 -2
  113. package/dist/src/server.d.ts.map +1 -1
  114. package/dist/src/server.js +3 -3
  115. package/dist/src/server.js.map +1 -1
  116. package/dist/src/types.d.ts +1 -1
  117. package/dist/src/types.d.ts.map +1 -1
  118. package/dist/src/utils.d.ts +1 -1
  119. package/dist/src/utils.d.ts.map +1 -1
  120. package/dist/src/utils.js +3 -2
  121. package/dist/src/utils.js.map +1 -1
  122. package/dist/stripe-graphql-js.cjs +2 -0
  123. package/dist/stripe-graphql-js.cjs.map +1 -0
  124. package/dist/stripe-graphql-js.js +76 -0
  125. package/dist/stripe-graphql-js.js.map +1 -0
  126. package/dist/tsconfig.tsbuildinfo +1 -1
  127. package/package.json +32 -23
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripe-graphql-js.js","sources":["../src/builder.ts","../src/utils.ts","../src/schema/index.ts","../src/server.ts"],"sourcesContent":["import SchemaBuilder from '@pothos/core';\nimport { GraphQLJSONObject } from 'graphql-scalars';\nimport type Stripe from 'stripe';\n\nimport type {\n Context,\n StripeCharge,\n StripeInvoice,\n StripePaymentIntent,\n StripePaymentMethod,\n StripeSubscription,\n} from './types';\n\n// TODO: Make sure we either use Type or Types (e.g. StripePaymentMethodTypes or StripePaymentMethodType ) everywhere\n\nconst builder = new SchemaBuilder<{\n Scalars: {\n JSON: {\n Output: unknown;\n Input: JSON;\n };\n };\n Objects: {\n // biome-ignore lint/complexity/noBannedTypes: Pothos requires {} for empty object types in schema builder\n Stripe: {};\n // biome-ignore lint/complexity/noBannedTypes: Pothos requires {} for empty object types in schema builder\n StripeMutations: {};\n\n // CUSTOMER\n StripeCustomers: Stripe.ApiList<Stripe.Customer>;\n StripeCustomer: Stripe.Customer;\n StripeCustomerShipping: Stripe.Customer.Shipping;\n StripeCustomerTax: Stripe.Customer.Tax;\n StripeCustomerTaxAutomaticTax: Stripe.Customer.Tax.AutomaticTax;\n StripeCustomerTaxLocation: Stripe.Customer.Tax.Location;\n\n // ADDRESS\n StripeAddress: Stripe.Address;\n\n // PAYMENT METHOD\n StripePaymentMethods: Stripe.ApiList<StripePaymentMethod>;\n StripePaymentMethod: StripePaymentMethod;\n StripeCustomerListPaymentMethodsParamsType: Stripe.CustomerListPaymentMethodsParams.Type;\n StripePaymentMethodBillingDetails: Stripe.PaymentMethod.BillingDetails;\n StripePaymentMethodTypes: Stripe.PaymentMethod.Type;\n\n // PAYMENT METHOD CARD\n StripePaymentMethodCard: Stripe.PaymentMethod.Card;\n StripePaymentMethodCardChecks: Stripe.PaymentMethod.Card.Checks;\n StripePaymentMethodCardNetworks: Stripe.PaymentMethod.Card.Networks;\n StripePaymentMethodCardThreeDSecureUsage: Stripe.PaymentMethod.Card.ThreeDSecureUsage;\n StripePaymentMethodCardWallet: Stripe.PaymentMethod.Card.Wallet;\n StripePaymentMethodCardWalletMasterpass: Stripe.PaymentMethod.Card.Wallet.Masterpass;\n StripePaymentMethodCardWalletType: Stripe.PaymentMethod.Card.Wallet.Type;\n StripePaymentMethodCardWalletVisaMasterpass: Stripe.PaymentMethod.Card.Wallet.Masterpass;\n StripePaymentMethodCardWalletVisaCheckout: Stripe.PaymentMethod.Card.Wallet.VisaCheckout;\n\n // SUBSCRIPTION\n StripeSubscriptions: Stripe.ApiList<StripeSubscription>;\n StripeSubscription: StripeSubscription;\n StripeSubscriptionStatus: Stripe.Subscription.Status;\n StripeSubscriptionItems: Stripe.ApiList<Stripe.SubscriptionItem>;\n StripeSubscriptionItem: Stripe.SubscriptionItem;\n StripeSubscriptionItemBillingThresholds: Stripe.SubscriptionItem.BillingThresholds;\n StripeSubscriptionAutomaticTax: Stripe.Subscription.AutomaticTax;\n StripeSubscriptionBillingThresholds: Stripe.Subscription.BillingThresholds;\n StripeSubscriptionPauseCollection: Stripe.Subscription.PauseCollection;\n\n // INVOICE\n StripeInvoice: StripeInvoice;\n StripeInvoices: Stripe.ApiList<StripeInvoice>;\n // StripeInvoceAccountTaxIds: Array<string | Stripe.TaxId | Stripe.DeletedTaxId> | null\n StripeInvoiceAutomaticTax: Stripe.Invoice.AutomaticTax;\n StripeInvoiceCustomField: Stripe.Invoice.CustomField;\n StripeInvoiceCustomerShipping: Stripe.Invoice.CustomerShipping;\n StripeInvoiceCustomerTaxId: Stripe.Invoice.CustomerTaxId;\n StripeInvoiceRenderingOptions: Stripe.Invoice.RenderingOptions;\n StripeInvoiceStatusTransitions: Stripe.Invoice.StatusTransitions;\n\n // INVOICE LINE ITEM\n StripeInvoiceLineItems: Stripe.ApiList<Stripe.InvoiceLineItem>;\n StripeInvoiceLineItem: Stripe.InvoiceLineItem;\n StripeInvoiceLineItemPeriod: Stripe.InvoiceLineItem.Period;\n StripeInvoiceLineItemTaxAmount: Stripe.InvoiceLineItem.TaxAmount;\n\n // PRICE\n StripePrice: Stripe.Price;\n\n // PLAN\n StripePlan: Stripe.Plan;\n StripePlanTransformUsage: Stripe.Plan.TransformUsage;\n\n // PRODUCT\n StripeProduct: Stripe.Product;\n\n // TAX RATES\n StripeTaxRate: Stripe.TaxRate;\n\n // TEST CLOCK\n StripeTestClock: Stripe.TestHelpers.TestClock;\n\n // BILLING PORTAL\n StripeBillingPortalSession: Stripe.BillingPortal.Session;\n\n // PAYMENT INTENT\n StripePaymentIntent: StripePaymentIntent;\n StripePaymentIntents: Stripe.ApiList<StripePaymentIntent>;\n\n // CHARGES\n StripeCharge: StripeCharge;\n StripeCharges: Stripe.ApiList<StripeCharge>;\n\n // CONNECTED ACCOUNTS\n StripeConnectedAccount: Stripe.Account;\n StripeConnectedAccounts: Stripe.ApiList<Stripe.Account>;\n };\n Context: Context;\n}>({});\n\nbuilder.queryType();\nbuilder.mutationType();\n\nbuilder.addScalarType('JSON', GraphQLJSONObject, {});\n\nexport { builder };\n","import jwt from 'jsonwebtoken';\nimport Stripe from 'stripe';\n\nimport type { UserHasuraClaims } from './types';\n\nif (!process.env['STRIPE_SECRET_KEY']) {\n throw new Error('STRIPE_SECRET_KEY env var is not set');\n}\n\nexport const stripe = new Stripe(process.env['STRIPE_SECRET_KEY'], {\n apiVersion: '2022-11-15',\n});\n\nexport const getUserClaims = (req: Request): UserHasuraClaims | undefined => {\n try {\n const authorizationHeader = req.headers.get('authorization');\n\n const accessToken = authorizationHeader?.split(' ')[1];\n\n if (!accessToken) {\n return undefined;\n }\n\n if (!process.env['NHOST_JWT_SECRET']) {\n throw new Error('NHOST_JWT_SECRET env var is not set');\n }\n\n const jwtSecret = JSON.parse(process.env['NHOST_JWT_SECRET']);\n\n // biome-ignore lint/suspicious/noExplicitAny: JWT decode returns unknown structure\n const decodedToken = jwt.verify(accessToken, jwtSecret.key) as any;\n return decodedToken['https://hasura.io/jwt/claims'] as UserHasuraClaims;\n } catch (_error) {\n return undefined;\n }\n};\n","import './address';\nimport './customer';\nimport './customers';\nimport './customer-shipping';\nimport './customer-tax';\nimport './customer-tax-location';\nimport './payment-methods';\nimport './payment-method';\nimport './payment-method-billing-details';\nimport './payment-method-card';\nimport './payment-method-card-checks';\nimport './payment-method-card-networks';\nimport './payment-method-card-three-d-secure-usage';\nimport './payment-method-card-wallet-masterpass';\nimport './payment-method-card-wallet-visa-checkout';\nimport './payment-method-card-wallet';\nimport './stripe';\nimport './subscriptions';\nimport './subscription';\nimport './subscription-items';\nimport './subscription-item';\nimport './subscription-item-billing-thresholds';\nimport './subscription-automatic-tax';\nimport './subscription-billing-thresholds';\nimport './subscription-pause-collection';\nimport './invoices';\nimport './invoice';\nimport './invoice-automatic-tax';\nimport './invoice-custom-field';\nimport './invoice-customer-shipping';\nimport './invoice-customer-tax-id';\nimport './invoice-line-items';\nimport './invoice-line-item';\nimport './invoice-line-item-period';\nimport './invoice-line-item-tax-amount';\nimport './invoice-rendering-options';\nimport './invoice-status-transitions';\nimport './plan';\nimport './plan-transform-usage';\nimport './price';\nimport './product';\nimport './tax-rate';\nimport './test-clock';\nimport './billing-portal-session';\nimport './payment-intent';\nimport './payment-intents';\nimport './charges';\nimport './charge';\nimport './connectedAccount';\nimport './connectedAccounts';\n\nimport { builder } from '../builder';\n\nexport const schema = builder.toSchema();\n","import { createYoga, type YogaInitialContext } from 'graphql-yoga';\n\nimport { schema } from './schema';\nimport type { Context, CreateServerProps } from './types';\nimport { getUserClaims } from './utils';\n\nconst createStripeGraphQLServer = ({\n cors,\n isAllowed,\n graphiql,\n maskedErrors = true,\n}: CreateServerProps = {}) => {\n const context = (context: YogaInitialContext): Context => {\n const { request } = context;\n\n // user id\n const userClaims = getUserClaims(request);\n\n // check if using correct `x-hasura-admin-secret` header\n const adminSecretFromHeader = request.headers.get('x-hasura-admin-secret');\n const adminSecret = process.env['NHOST_ADMIN_SECRET'];\n\n // check if the request is from Hasura\n const nhostWebhookSecretFromHeader = request.headers.get(\n 'x-nhost-webhook-secret',\n );\n const nhostWebhookSecret = process.env['NHOST_WEBHOOK_SECRET'];\n const role = request.headers.get('x-hasura-role');\n\n // variables\n const isAdmin =\n adminSecretFromHeader === adminSecret ||\n (role === 'admin' && nhostWebhookSecretFromHeader === nhostWebhookSecret);\n\n // if no isAllowed function is provided, we will allow admin requests\n const isAllowedFunction =\n isAllowed ||\n ((_stripeCustomerId: string, context: Context) => {\n return context.isAdmin;\n });\n\n // return\n return {\n ...context,\n isAllowed: isAllowedFunction,\n userClaims,\n isAdmin,\n };\n };\n\n const yoga = createYoga({\n cors,\n graphiql,\n context,\n schema,\n graphqlEndpoint: '*',\n maskedErrors,\n });\n\n return yoga;\n};\n\nexport { createStripeGraphQLServer, schema };\n"],"names":["context"],"mappings":";;;;;AAeA,MAAM,UAAU,IAAI,cAsGjB,CAAA,CAAE;AAEL,QAAQ,UAAA;AACR,QAAQ,aAAA;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