@nhost/stripe-graphql-js 0.0.3 → 0.0.5

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 (84) hide show
  1. package/README.md +22 -4
  2. package/dist/schema/address.js +24 -6
  3. package/dist/schema/address.js.map +1 -1
  4. package/dist/schema/billing-portal-session.js +17 -5
  5. package/dist/schema/billing-portal-session.js.map +1 -1
  6. package/dist/schema/customer-shipping.js +4 -0
  7. package/dist/schema/customer-shipping.js.map +1 -1
  8. package/dist/schema/customer-tax-location.js +4 -1
  9. package/dist/schema/customer-tax-location.js.map +1 -1
  10. package/dist/schema/customer-tax.js +2 -0
  11. package/dist/schema/customer-tax.js.map +1 -1
  12. package/dist/schema/customer.js +28 -5
  13. package/dist/schema/customer.js.map +1 -1
  14. package/dist/schema/customers.js +6 -2
  15. package/dist/schema/customers.js.map +1 -1
  16. package/dist/schema/invoice-automatic-tax.js +4 -1
  17. package/dist/schema/invoice-automatic-tax.js.map +1 -1
  18. package/dist/schema/invoice-custom-field.js +6 -2
  19. package/dist/schema/invoice-custom-field.js.map +1 -1
  20. package/dist/schema/invoice-customer-shipping.js +4 -0
  21. package/dist/schema/invoice-customer-shipping.js.map +1 -1
  22. package/dist/schema/invoice-customer-tax-id.js +4 -1
  23. package/dist/schema/invoice-customer-tax-id.js.map +1 -1
  24. package/dist/schema/invoice-line-item-period.js +6 -2
  25. package/dist/schema/invoice-line-item-period.js.map +1 -1
  26. package/dist/schema/invoice-line-item-tax-amount.js +6 -2
  27. package/dist/schema/invoice-line-item-tax-amount.js.map +1 -1
  28. package/dist/schema/invoice-line-item.js +33 -8
  29. package/dist/schema/invoice-line-item.js.map +1 -1
  30. package/dist/schema/invoice-line-items.js +6 -2
  31. package/dist/schema/invoice-line-items.js.map +1 -1
  32. package/dist/schema/invoice.js +92 -20
  33. package/dist/schema/invoice.js.map +1 -1
  34. package/dist/schema/invoices.js +6 -2
  35. package/dist/schema/invoices.js.map +1 -1
  36. package/dist/schema/payment-method-billing-details.js +4 -0
  37. package/dist/schema/payment-method-billing-details.js.map +1 -1
  38. package/dist/schema/payment-method-card-checks.js +3 -0
  39. package/dist/schema/payment-method-card-checks.js.map +1 -1
  40. package/dist/schema/payment-method-card-networks.js +4 -1
  41. package/dist/schema/payment-method-card-networks.js.map +1 -1
  42. package/dist/schema/payment-method-card-three-d-secure-usage.js +3 -1
  43. package/dist/schema/payment-method-card-three-d-secure-usage.js.map +1 -1
  44. package/dist/schema/payment-method-card-wallet-masterpass.js +4 -0
  45. package/dist/schema/payment-method-card-wallet-masterpass.js.map +1 -1
  46. package/dist/schema/payment-method-card-wallet-visa-checkout.js +4 -0
  47. package/dist/schema/payment-method-card-wallet-visa-checkout.js.map +1 -1
  48. package/dist/schema/payment-method-card-wallet.d.ts.map +1 -1
  49. package/dist/schema/payment-method-card-wallet.js +5 -1
  50. package/dist/schema/payment-method-card-wallet.js.map +1 -1
  51. package/dist/schema/payment-method-card.js +19 -4
  52. package/dist/schema/payment-method-card.js.map +1 -1
  53. package/dist/schema/payment-method.js +17 -5
  54. package/dist/schema/payment-method.js.map +1 -1
  55. package/dist/schema/payment-methods.d.ts.map +1 -1
  56. package/dist/schema/payment-methods.js +6 -2
  57. package/dist/schema/payment-methods.js.map +1 -1
  58. package/dist/schema/plan.js +39 -10
  59. package/dist/schema/plan.js.map +1 -1
  60. package/dist/schema/price.js +31 -8
  61. package/dist/schema/price.js.map +1 -1
  62. package/dist/schema/product.js +36 -8
  63. package/dist/schema/product.js.map +1 -1
  64. package/dist/schema/stripe.js +8 -3
  65. package/dist/schema/stripe.js.map +1 -1
  66. package/dist/schema/subscription-automatic-tax.js +3 -1
  67. package/dist/schema/subscription-automatic-tax.js.map +1 -1
  68. package/dist/schema/subscription-billing-thresholds.js +2 -0
  69. package/dist/schema/subscription-billing-thresholds.js.map +1 -1
  70. package/dist/schema/subscription-item-billing-thresholds.js +1 -0
  71. package/dist/schema/subscription-item-billing-thresholds.js.map +1 -1
  72. package/dist/schema/subscription-item.js +17 -4
  73. package/dist/schema/subscription-item.js.map +1 -1
  74. package/dist/schema/subscription-items.js +6 -2
  75. package/dist/schema/subscription-items.js.map +1 -1
  76. package/dist/schema/subscription.js +56 -13
  77. package/dist/schema/subscription.js.map +1 -1
  78. package/dist/schema/subscriptions.js +6 -2
  79. package/dist/schema/subscriptions.js.map +1 -1
  80. package/dist/schema/test-clock.js +22 -7
  81. package/dist/schema/test-clock.js.map +1 -1
  82. package/dist/types.d.ts +2 -2
  83. package/dist/types.d.ts.map +1 -1
  84. package/package.json +2 -3
@@ -14,37 +14,63 @@ const utils_1 = require("../utils");
14
14
  builder_1.builder.objectType('StripeSubscription', {
15
15
  description: '',
16
16
  fields: (t) => ({
17
- id: t.exposeString('id'),
18
- object: t.exposeString('object'),
17
+ id: t.exposeString('id', {
18
+ description: `Unique identifier for the object.`
19
+ }),
20
+ object: t.exposeString('object', {
21
+ description: `String representing the object's type. Objects of the same type share the same value.`
22
+ }),
19
23
  // todo: application
20
24
  applicationFeePercent: t.exposeFloat('application_fee_percent', {
25
+ description: `A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner's Stripe account.`,
21
26
  nullable: true
22
27
  }),
23
28
  automaticTax: t.expose('automatic_tax', {
24
29
  type: 'StripeSubscriptionAutomaticTax'
25
30
  }),
26
- billingCycleAnchor: t.exposeInt('billing_cycle_anchor'),
31
+ billingCycleAnchor: t.exposeInt('billing_cycle_anchor', {
32
+ description: `Determines the date of the first full invoice, and, for plans with \`month\` or \`year\` intervals, the day of the month for subsequent invoices. The timestamp is in UTC format.`
33
+ }),
27
34
  billingThresholds: t.expose('billing_thresholds', {
35
+ description: `Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period`,
28
36
  type: 'StripeSubscriptionBillingThresholds',
29
37
  nullable: true
30
38
  }),
31
39
  cancelAt: t.exposeInt('cancel_at', {
40
+ description: `A date in the future at which the subscription will automatically get canceled`,
32
41
  nullable: true
33
42
  }),
34
- cancelAtPeriodEnd: t.exposeBoolean('cancel_at_period_end'),
43
+ cancelAtPeriodEnd: t.exposeBoolean('cancel_at_period_end', {
44
+ description: `If the subscription has been canceled with the \`at_period_end\` flag set to \`true\`, \`cancel_at_period_end\` on the subscription will be true. You can use this attribute to determine whether a subscription that has a status of active is scheduled to be canceled at the end of the current period.`
45
+ }),
35
46
  canceledAt: t.exposeInt('canceled_at', {
47
+ description: `If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with \`cancel_at_period_end\`, \`canceled_at\` will reflect the time of the most recent update request, not the end of the subscription period when the subscription is automatically moved to a canceled state.`,
36
48
  nullable: true
37
49
  }),
38
- collectionMethods: t.exposeString('collection_method'),
39
- created: t.exposeInt('created'),
40
- currency: t.exposeString('currency'),
41
- currentPeriodEnd: t.exposeInt('current_period_end'),
42
- currentPeriodStart: t.exposeInt('current_period_start'),
43
- customer: t.exposeString('customer'),
50
+ collectionMethods: t.exposeString('collection_method', {
51
+ description: `Either \`charge_automatically\`, or \`send_invoice\`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as \`active\`.`
52
+ }),
53
+ created: t.exposeInt('created', {
54
+ description: `Time at which the object was created. Measured in seconds since the Unix epoch.`
55
+ }),
56
+ currency: t.exposeString('currency', {
57
+ description: `Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).`
58
+ }),
59
+ currentPeriodEnd: t.exposeInt('current_period_end', {
60
+ description: `End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created.`
61
+ }),
62
+ currentPeriodStart: t.exposeInt('current_period_start', {
63
+ description: `Start of the current period that the subscription has been invoiced for.`
64
+ }),
65
+ customer: t.exposeString('customer', {
66
+ description: `ID of the customer who owns the subscription.`
67
+ }),
44
68
  daysUntilDue: t.exposeInt('days_until_due', {
69
+ description: `Number of days a customer has to pay invoices generated by this subscription. This value will be \`null\` for subscriptions where \`collection_method=charge_automatically\`.`,
45
70
  nullable: true
46
71
  }),
47
72
  defaultPaymentMethod: t.field({
73
+ description: `ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over \`default_source\`. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://stripe.com/docs/api/customers/object#customer_object-default_source).`,
48
74
  type: 'StripePaymentMethod',
49
75
  nullable: true,
50
76
  resolve: (subscription) => __awaiter(void 0, void 0, void 0, function* () {
@@ -61,20 +87,25 @@ builder_1.builder.objectType('StripeSubscription', {
61
87
  }),
62
88
  // todo: default source
63
89
  defaultTaxRates: t.expose('default_tax_rates', {
90
+ description: `The tax rates that will apply to any subscription item that does not have \`tax_rates\` set. Invoices created will have their \`default_tax_rates\` populated from the subscription.`,
64
91
  type: ['StripeTaxRate'],
65
92
  nullable: true
66
93
  }),
67
94
  description: t.exposeString('description', {
95
+ description: `The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces.`,
68
96
  nullable: true
69
97
  }),
70
98
  // TODO: discount
71
99
  endedAt: t.exposeInt('ended_at', {
100
+ description: `If the subscription has ended, the date the subscription ended.`,
72
101
  nullable: true
73
102
  }),
74
103
  items: t.expose('items', {
104
+ description: `List of subscription items, each with an attached price.`,
75
105
  type: 'StripeSubscriptionItems'
76
106
  }),
77
107
  latestInvoice: t.field({
108
+ description: `The most recent invoice this subscription has generated.`,
78
109
  type: 'StripeInvoice',
79
110
  nullable: true,
80
111
  resolve: (subscription) => __awaiter(void 0, void 0, void 0, function* () {
@@ -89,14 +120,19 @@ builder_1.builder.objectType('StripeSubscription', {
89
120
  return invoice;
90
121
  })
91
122
  }),
92
- livemode: t.exposeBoolean('livemode'),
123
+ livemode: t.exposeBoolean('livemode', {
124
+ description: `Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode.`
125
+ }),
93
126
  metadata: t.expose('metadata', {
127
+ description: `Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.`,
94
128
  type: 'JSON'
95
129
  }),
96
130
  nextPendingInvoiceItemInvoice: t.exposeInt('next_pending_invoice_item_invoice', {
131
+ description: `Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at \`pending_invoice_item_interval\`.`,
97
132
  nullable: true
98
133
  }),
99
134
  pauseCollection: t.expose('pause_collection', {
135
+ description: `If specified, payment collection for this subscription will be paused.`,
100
136
  type: 'StripeSubscriptionPauseCollection',
101
137
  nullable: true
102
138
  }),
@@ -105,9 +141,14 @@ builder_1.builder.objectType('StripeSubscription', {
105
141
  // todo: pending_setup_intent
106
142
  // todo: pending_update
107
143
  // todo: schedule
108
- startDate: t.exposeInt('start_date'),
109
- status: t.exposeString('status'),
144
+ startDate: t.exposeInt('start_date', {
145
+ description: `Date when the subscription was first created. The date might differ from the \`created\` date due to backdating.`
146
+ }),
147
+ status: t.exposeString('status', {
148
+ description: `Possible values are \`incomplete\`, \`incomplete_expired\`, \`trialing\`, \`active\`, \`past_due\`, \`canceled\`, or \`unpaid\`.\n\nFor \`collection_method=charge_automatically\` a subscription moves into \`incomplete\` if the initial payment attempt fails. A subscription in this state can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an \`active\` state. If the first invoice is not paid within 23 hours, the subscription transitions to \`incomplete_expired\`. This is a terminal state, the open invoice will be voided and no further invoices will be generated.\n\nA subscription that is currently in a trial period is \`trialing\` and moves to \`active\` when the trial period is over.\n\nIf subscription \`collection_method=charge_automatically\` it becomes \`past_due\` when payment to renew it fails and \`canceled\` or \`unpaid\` (depending on your subscriptions settings) when Stripe has exhausted all payment retry attempts.\n\nIf subscription \`collection_method=send_invoice\` it becomes \`past_due\` when its invoice is not paid by the due date, and \`canceled\` or \`unpaid\` if it is still not paid by an additional deadline after that. Note that when a subscription has a status of \`unpaid\`, no subsequent invoices will be attempted (invoices will be created, but then immediately automatically closed). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices.`
149
+ }),
110
150
  testClock: t.field({
151
+ description: `ID of the test clock this subscription belongs to.`,
111
152
  type: 'StripeTestClock',
112
153
  nullable: true,
113
154
  resolve: (subscription) => __awaiter(void 0, void 0, void 0, function* () {
@@ -124,9 +165,11 @@ builder_1.builder.objectType('StripeSubscription', {
124
165
  }),
125
166
  // todo: transfer data
126
167
  trialEnd: t.exposeInt('trial_end', {
168
+ description: `If the subscription has a trial, the end of that trial.`,
127
169
  nullable: true
128
170
  }),
129
171
  trialStart: t.exposeInt('trial_start', {
172
+ description: `If the subscription has a trial, the beginning of that trial.`,
130
173
  nullable: true
131
174
  })
132
175
  })
@@ -1 +1 @@
1
- {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/schema/subscription.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,wCAAoC;AAEpC,oCAAiC;AAEjC,iBAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE;IACvC,WAAW,EAAE,EAAE;IACf,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACd,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC;QACxB,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;QAChC,oBAAoB;QACpB,qBAAqB,EAAE,CAAC,CAAC,WAAW,CAAC,yBAAyB,EAAE;YAC9D,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,eAAe,EAAE;YACtC,IAAI,EAAE,gCAAgC;SACvC,CAAC;QACF,kBAAkB,EAAE,CAAC,CAAC,SAAS,CAAC,sBAAsB,CAAC;QACvD,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,oBAAoB,EAAE;YAChD,IAAI,EAAE,qCAAqC;YAC3C,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,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,CAAC;QACF,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC;YACjB,WAAW,EAAE,oDAAoD;YACjE,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,CAAO,YAAY,EAAE,EAAE;gBAC9B,MAAM,EAAE,UAAU,EAAE,GAAG,YAAY,CAAA;gBAEnC,IAAI,CAAC,UAAU,EAAE;oBACf,OAAO,IAAI,CAAA;iBACZ;gBAED,MAAM,SAAS,GAAG,MAAM,cAAM,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAoB,CAAC,CAAA;gBAEpF,IAAI,CAAC,SAAS,EAAE;oBACd,OAAO,IAAI,CAAA;iBACZ;gBAED,OAAO,SAAS,CAAA;YAClB,CAAC,CAAA;SACF,CAAC;QACF,sBAAsB;QACtB,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE;YACjC,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE;YACrC,WAAW,EAAE,+DAA+D;YAC5E,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAC;CACH,CAAC,CAAA"}
@@ -4,8 +4,12 @@ const builder_1 = require("../builder");
4
4
  builder_1.builder.objectType('StripeSubscriptions', {
5
5
  fields: (t) => ({
6
6
  object: t.exposeString('object'),
7
- url: t.exposeString('url'),
8
- hasMore: t.exposeBoolean('has_more'),
7
+ url: t.exposeString('url', {
8
+ description: `The URL where this list can be accessed.`
9
+ }),
10
+ hasMore: t.exposeBoolean('has_more', {
11
+ description: `True if this list has another page of items after this one that can be fetched.`
12
+ }),
9
13
  data: t.expose('data', {
10
14
  type: ['StripeSubscription'],
11
15
  nullable: false
@@ -1 +1 @@
1
- {"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/schema/subscriptions.ts"],"names":[],"mappings":";;AAAA,wCAAoC;AAEpC,iBAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE;IACxC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACd,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;QAChC,GAAG,EAAE,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC;QAC1B,OAAO,EAAE,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC;QACpC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE;YACrB,IAAI,EAAE,CAAC,oBAAoB,CAAC;YAC5B,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH,CAAC;CACH,CAAC,CAAA"}
1
+ {"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/schema/subscriptions.ts"],"names":[],"mappings":";;AAAA,wCAAoC;AAEpC,iBAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE;IACxC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACd,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;QAChC,GAAG,EAAE,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE;YACzB,WAAW,EAAE,0CAA0C;SACxD,CAAC;QACF,OAAO,EAAE,CAAC,CAAC,aAAa,CAAC,UAAU,EAAE;YACnC,WAAW,EAAE,iFAAiF;SAC/F,CAAC;QACF,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE;YACrB,IAAI,EAAE,CAAC,oBAAoB,CAAC;YAC5B,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH,CAAC;CACH,CAAC,CAAA"}
@@ -4,16 +4,31 @@ const builder_1 = require("../builder");
4
4
  builder_1.builder.objectType('StripeTestClock', {
5
5
  description: '',
6
6
  fields: (t) => ({
7
- id: t.exposeString('id'),
8
- object: t.exposeString('object'),
9
- created: t.exposeInt('created'),
10
- deletesAfter: t.exposeInt('deletes_after'),
11
- frozenTime: t.exposeInt('frozen_time'),
12
- livemode: t.exposeBoolean('livemode'),
7
+ id: t.exposeString('id', {
8
+ description: `Unique identifier for the object.`
9
+ }),
10
+ object: t.exposeString('object', {
11
+ description: `String representing the object's type. Objects of the same type share the same value.`
12
+ }),
13
+ created: t.exposeInt('created', {
14
+ description: `Time at which the object was created. Measured in seconds since the Unix epoch.`
15
+ }),
16
+ deletesAfter: t.exposeInt('deletes_after', {
17
+ description: `Time at which this clock is scheduled to auto delete.`
18
+ }),
19
+ frozenTime: t.exposeInt('frozen_time', {
20
+ description: `Time at which all objects belonging to this clock are frozen.`
21
+ }),
22
+ livemode: t.exposeBoolean('livemode', {
23
+ description: `Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode.`
24
+ }),
13
25
  name: t.exposeString('name', {
26
+ description: `The custom name supplied at creation.`,
14
27
  nullable: true
15
28
  }),
16
- status: t.exposeString('status')
29
+ status: t.exposeString('status', {
30
+ description: `The status of the Test Clock.`
31
+ })
17
32
  })
18
33
  });
19
34
  //# sourceMappingURL=test-clock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-clock.js","sourceRoot":"","sources":["../../src/schema/test-clock.ts"],"names":[],"mappings":";;AAAA,wCAAoC;AAEpC,iBAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE;IACpC,WAAW,EAAE,EAAE;IACf,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACd,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC;QACxB,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;QAChC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;QAC/B,YAAY,EAAE,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC;QAC1C,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC;QACtC,QAAQ,EAAE,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC;QACrC,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE;YAC3B,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;KACjC,CAAC;CACH,CAAC,CAAA"}
1
+ {"version":3,"file":"test-clock.js","sourceRoot":"","sources":["../../src/schema/test-clock.ts"],"names":[],"mappings":";;AAAA,wCAAoC;AAEpC,iBAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE;IACpC,WAAW,EAAE,EAAE;IACf,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACd,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE;YACvB,WAAW,EAAE,mCAAmC;SACjD,CAAC;QACF,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE;YAC/B,WAAW,EAAE,uFAAuF;SACrG,CAAC;QACF,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE;YAC9B,WAAW,EAAE,iFAAiF;SAC/F,CAAC;QACF,YAAY,EAAE,CAAC,CAAC,SAAS,CAAC,eAAe,EAAE;YACzC,WAAW,EAAE,uDAAuD;SACrE,CAAC;QACF,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE;YACrC,WAAW,EAAE,+DAA+D;SAC7E,CAAC;QACF,QAAQ,EAAE,CAAC,CAAC,aAAa,CAAC,UAAU,EAAE;YACpC,WAAW,EAAE,oHAAoH;SAClI,CAAC;QACF,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE;YAC3B,WAAW,EAAE,uCAAuC;YACpD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE;YAC/B,WAAW,EAAE,+BAA+B;SAC7C,CAAC;KACH,CAAC;CACH,CAAC,CAAA"}
package/dist/types.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import type Stripe from 'stripe';
2
2
  import type { CORSOptions, YogaInitialContext } from '@graphql-yoga/node';
3
3
  export declare type StripeGraphQLContext = {
4
- isAllowed: (stripeCustomerId: string, context: Context) => boolean;
4
+ isAllowed: (stripeCustomerId: string, context: Context) => boolean | Promise<boolean>;
5
5
  userClaims?: UserHasuraClaims;
6
6
  isAdmin: boolean;
7
7
  };
8
8
  export declare type Context = YogaInitialContext & StripeGraphQLContext;
9
9
  export declare type CreateServerProps = {
10
10
  cors?: CORSOptions;
11
- isAllowed?: (stripeCustomerId: string, context: Context) => boolean;
11
+ isAllowed?: (stripeCustomerId: string, context: Context) => boolean | Promise<boolean>;
12
12
  graphiql?: boolean;
13
13
  };
14
14
  export declare type StripePaymentMethod = Stripe.PaymentMethod & {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEzE,oBAAY,oBAAoB,GAAG;IACjC,SAAS,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAA;IAClE,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,oBAAY,OAAO,GAAG,kBAAkB,GAAG,oBAAoB,CAAA;AAE/D,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,SAAS,CAAC,EAAE,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAA;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,oBAAY,mBAAmB,GAAG,MAAM,CAAC,aAAa,GAAG;IACvD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB,CAAA;AAED,oBAAY,kBAAkB,GAAG,MAAM,CAAC,YAAY,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AAE,MAAM,GAAG,IAAI,CAAA;CACxB,CAAA;AAED,oBAAY,kBAAkB,GAAG,MAAM,CAAC,YAAY,GAAG;IACrD,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B,CAAA;AAED,oBAAY,aAAa,GAAG,MAAM,CAAC,OAAO,GAAG;IAC3C,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,sBAAsB,EAAE,mBAAmB,GAAG,IAAI,CAAA;CACnD,CAAA;AAED,oBAAY,gBAAgB,GAAG;IAC7B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,uBAAuB,EAAE,MAAM,CAAA;IAC/B,wBAAwB,EAAE,MAAM,EAAE,CAAA;CACnC,GAAG;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nhost/stripe-graphql-js",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Stripe GraphQL API",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -53,6 +53,5 @@
53
53
  "lint:fix": "eslint . --ext .ts,.tsx --fix",
54
54
  "verify": "run-p prettier lint",
55
55
  "verify:fix": "run-p prettier:fix lint:fix"
56
- },
57
- "readme": "<h1 align=\"center\">@nhost/stripe-graphql-js</h1>\n<h2 align=\"center\">Stripe GraphQL API</h2>\n\n<p align=\"center\">\n <img alt=\"npm\" src=\"https://img.shields.io/npm/v/@nhost/stripe-graphql\">\n <img alt=\"npm\" src=\"https://img.shields.io/npm/dm/@nhost/stripe-graphql\">\n <a href=\"LICENSE\">\n <img src=\"https://img.shields.io/badge/license-MIT-yellow.svg\" alt=\"license: MIT\" />\n </a>\n</p>\n\nThis package creates a Stripe GraphQL API.\n\n```graphql\nquery {\n stripe {\n customer(id: \"cus_MVBRpmnBis9v5x\") {\n id\n name\n invoices {\n data {\n id\n created\n paid\n hostedInvoiceUrl\n }\n }\n }\n }\n}\n```\n\nYou can also add the Stripe GraphQL API as a Hasura Remote Schema and connect data from your database and Stripe. This allows you to request data from your database and Stripe in a single GraphQL query:\n\n```graphql\nquery {\n users {\n # User in your database\n id\n displayName\n userData {\n stripeCustomerId # Customer's Stripe Customer Id\n stripeCustomer {\n # Data from Stripe\n id\n name\n paymentMethods {\n id\n card {\n brand\n last4\n }\n }\n }\n }\n }\n}\n```\n\n## Install\n\n```bash\nnpm install @nhost/stripe-graphql-js\n```\n\n## Quick Start\n\n### Serverless Function Setup\n\nCreate a new [Serverless Function](https://docs.nhost.io/platform/serverless-functions) `functions/graphql/stripe.ts`:\n\n```js\nimport { createStripeGraphQLServer } from '@nhost/stripe-graphql-js'\n\nconst server = createStripeGraphQLServer()\n\nexport default server\n```\n\n> You can run the Stripe GraphQL API in any JS environment because it's built using [GraphQL Yoga](https://github.com/dotansimha/graphql-yoga).\n\n### Test\n\nTest the Stripe GraphQL API in the browser:\n\n[http://localhost:1337/v1/functions/graphql/stripe](http://localhost:1337/v1/functions/graphql/stripe)\n\n### Remote Schema\n\nAdd the Stripe GraphQL API as a Remote Schema in Hasura.\n\n**URL**\n\n```\n{{NHOST_BACKEND_URL}}/v1/functions/graphql/stripe`\n```\n\n**Headers**\n\n```\nx-nhost-webhook-secret: NHOST_WEBHOOK_SECRET (from env var)\n```\n\n![Hasura Remote Schema](./assets//hasura-remote-schema.png)\n\n## Permissions\n\nHere's a minimal example without any custom permissions. Only requests using the `x-hasura-admin-secret` header will work:\n\n```js\nconst server = createStripeGraphQLServer()\n```\n\nFor more granular permissions, you can pass an `isAllowed` function to the `createStripeGraphQLServer`. The `isAllowed` function takes a `stripeCustomerId` and [`context`](#context) as parameters and runs every time the GraphQL server makes a request to Stripe to get or modify data for a specific Stripe customer.\n\nHere is an example of an `isAllowed` function:\n\n```js\n\nconst isAllowed = (stripeCustomerId: string, context: Context) => {\n const { isAdmin, userClaims } = context\n\n // allow requests if it has a valid `x-hasura-admin-secret`\n if (isAdmin) {\n return true\n }\n\n // get user id\n const userId = userClaims['x-hasura-user-id']\n\n // check if user is signed in\n if (!userId) {\n return false;\n }\n\n // get more user information from the database\n const { user } = await gqlSDK.getUser({\n id: userId,\n });\n\n if (!user) {\n return false;\n }\n\n // check if the user is part of a workspace with the `stripeCustomerId`\n return user.workspaceMembers\n .some((workspaceMember) => {\n return workspaceMember.workspace.stripeCustomerId === stripeCustomerId;\n });\n}\n\n```\n\n### Context\n\nThe `context` object contains:\n\n- `userClaims` - verified JWT claims from the user's access token.\n- `isAdmin` - `true` if the request was made using a valid `x-hasura-admin-secret` header.\n- `request` - [Fetch API Request object](https://developer.mozilla.org/en-US/docs/Web/API/Request) that represents the incoming HTTP request in platform-independent way. It can be useful for accessing headers to authenticate a user\n- `query` - the DocumentNode that was parsed from the GraphQL query string\n- `operationName` - the operation name selected from the incoming query\n- `variables` - the variables that were defined in the query\n- `extensions` - the extensions that were received from the client\n\nRead more about the [default context from GraphQL Yoga](https://www.the-guild.dev/graphql/yoga-server/docs/features/context#default-context).\n\n## Development\n\nInstall dependencies:\n\n```bash\npnpm install\n```\n\nStart the development server:\n\n```bash\npnpm dev\n```\n\nThe GraphQL Server will reload every time the code changes.\n\nOpen GraphiQL:\n\n[http://0.0.0.0:4000/graphql](http://0.0.0.0:4000/graphql)\n"
56
+ }
58
57
  }