@nhost/stripe-graphql-js 0.0.1 → 0.0.3
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/README.md +39 -8
- package/dist/builder.d.ts +66 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +15 -0
- package/dist/builder.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/schema/address.d.ts +2 -0
- package/dist/schema/address.d.ts.map +1 -0
- package/dist/schema/address.js +14 -0
- package/dist/schema/address.js.map +1 -0
- package/dist/schema/billing-portal-session.d.ts +2 -0
- package/dist/schema/billing-portal-session.d.ts.map +1 -0
- package/dist/schema/billing-portal-session.js +23 -0
- package/dist/schema/billing-portal-session.js.map +1 -0
- package/dist/schema/customer-shipping.d.ts +2 -0
- package/dist/schema/customer-shipping.d.ts.map +1 -0
- package/dist/schema/customer-shipping.js +24 -0
- package/dist/schema/customer-shipping.js.map +1 -0
- package/dist/schema/customer-tax-location.d.ts +2 -0
- package/dist/schema/customer-tax-location.d.ts.map +1 -0
- package/dist/schema/customer-tax-location.js +20 -0
- package/dist/schema/customer-tax-location.js.map +1 -0
- package/dist/schema/customer-tax.d.ts +2 -0
- package/dist/schema/customer-tax.d.ts.map +1 -0
- package/dist/schema/customer-tax.js +21 -0
- package/dist/schema/customer-tax.js.map +1 -0
- package/dist/schema/customer.d.ts +2 -0
- package/dist/schema/customer.d.ts.map +1 -0
- package/dist/schema/customer.js +126 -0
- package/dist/schema/customer.js.map +1 -0
- package/dist/schema/customers.d.ts +2 -0
- package/dist/schema/customers.d.ts.map +1 -0
- package/dist/schema/customers.js +15 -0
- package/dist/schema/customers.js.map +1 -0
- package/dist/schema/index.d.ts +46 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +50 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/invoice-automatic-tax.d.ts +2 -0
- package/dist/schema/invoice-automatic-tax.d.ts.map +1 -0
- package/dist/schema/invoice-automatic-tax.js +12 -0
- package/dist/schema/invoice-automatic-tax.js.map +1 -0
- package/dist/schema/invoice-custom-field.d.ts +2 -0
- package/dist/schema/invoice-custom-field.d.ts.map +1 -0
- package/dist/schema/invoice-custom-field.js +10 -0
- package/dist/schema/invoice-custom-field.js.map +1 -0
- package/dist/schema/invoice-customer-shipping.d.ts +2 -0
- package/dist/schema/invoice-customer-shipping.d.ts.map +1 -0
- package/dist/schema/invoice-customer-shipping.js +24 -0
- package/dist/schema/invoice-customer-shipping.js.map +1 -0
- package/dist/schema/invoice-customer-tax-id.d.ts +2 -0
- package/dist/schema/invoice-customer-tax-id.d.ts.map +1 -0
- package/dist/schema/invoice-customer-tax-id.js +12 -0
- package/dist/schema/invoice-customer-tax-id.js.map +1 -0
- package/dist/schema/invoice-line-item-period.d.ts +2 -0
- package/dist/schema/invoice-line-item-period.d.ts.map +1 -0
- package/dist/schema/invoice-line-item-period.js +10 -0
- package/dist/schema/invoice-line-item-period.js.map +1 -0
- package/dist/schema/invoice-line-item-tax-amount.d.ts +2 -0
- package/dist/schema/invoice-line-item-tax-amount.d.ts.map +1 -0
- package/dist/schema/invoice-line-item-tax-amount.js +15 -0
- package/dist/schema/invoice-line-item-tax-amount.js.map +1 -0
- package/dist/schema/invoice-line-item.d.ts +2 -0
- package/dist/schema/invoice-line-item.d.ts.map +1 -0
- package/dist/schema/invoice-line-item.js +59 -0
- package/dist/schema/invoice-line-item.js.map +1 -0
- package/dist/schema/invoice-line-items.d.ts +2 -0
- package/dist/schema/invoice-line-items.d.ts.map +1 -0
- package/dist/schema/invoice-line-items.js +15 -0
- package/dist/schema/invoice-line-items.js.map +1 -0
- package/dist/schema/invoice-rendering-options.d.ts +2 -0
- package/dist/schema/invoice-rendering-options.d.ts.map +1 -0
- package/dist/schema/invoice-rendering-options.js +12 -0
- package/dist/schema/invoice-rendering-options.js.map +1 -0
- package/dist/schema/invoice-status-transitions.d.ts +2 -0
- package/dist/schema/invoice-status-transitions.d.ts.map +1 -0
- package/dist/schema/invoice-status-transitions.js +24 -0
- package/dist/schema/invoice-status-transitions.js.map +1 -0
- package/dist/schema/invoice.d.ts +2 -0
- package/dist/schema/invoice.d.ts.map +1 -0
- package/dist/schema/invoice.js +201 -0
- package/dist/schema/invoice.js.map +1 -0
- package/dist/schema/invoices.d.ts +2 -0
- package/dist/schema/invoices.d.ts.map +1 -0
- package/dist/schema/invoices.js +15 -0
- package/dist/schema/invoices.js.map +1 -0
- package/dist/schema/payment-method-billing-details.d.ts +2 -0
- package/dist/schema/payment-method-billing-details.d.ts.map +1 -0
- package/dist/schema/payment-method-billing-details.js +21 -0
- package/dist/schema/payment-method-billing-details.js.map +1 -0
- package/dist/schema/payment-method-card-checks.d.ts +2 -0
- package/dist/schema/payment-method-card-checks.d.ts.map +1 -0
- package/dist/schema/payment-method-card-checks.js +17 -0
- package/dist/schema/payment-method-card-checks.js.map +1 -0
- package/dist/schema/payment-method-card-networks.d.ts +2 -0
- package/dist/schema/payment-method-card-networks.d.ts.map +1 -0
- package/dist/schema/payment-method-card-networks.js +12 -0
- package/dist/schema/payment-method-card-networks.js.map +1 -0
- package/dist/schema/payment-method-card-three-d-secure-usage.d.ts +2 -0
- package/dist/schema/payment-method-card-three-d-secure-usage.d.ts.map +1 -0
- package/dist/schema/payment-method-card-three-d-secure-usage.js +9 -0
- package/dist/schema/payment-method-card-three-d-secure-usage.js.map +1 -0
- package/dist/schema/payment-method-card-wallet-masterpass.d.ts +2 -0
- package/dist/schema/payment-method-card-wallet-masterpass.d.ts.map +1 -0
- package/dist/schema/payment-method-card-wallet-masterpass.js +22 -0
- package/dist/schema/payment-method-card-wallet-masterpass.js.map +1 -0
- package/dist/schema/payment-method-card-wallet-visa-checkout.d.ts +2 -0
- package/dist/schema/payment-method-card-wallet-visa-checkout.d.ts.map +1 -0
- package/dist/schema/payment-method-card-wallet-visa-checkout.js +22 -0
- package/dist/schema/payment-method-card-wallet-visa-checkout.js.map +1 -0
- package/dist/schema/payment-method-card-wallet.d.ts +2 -0
- package/dist/schema/payment-method-card-wallet.d.ts.map +1 -0
- package/dist/schema/payment-method-card-wallet.js +31 -0
- package/dist/schema/payment-method-card-wallet.js.map +1 -0
- package/dist/schema/payment-method-card.d.ts +2 -0
- package/dist/schema/payment-method-card.d.ts.map +1 -0
- package/dist/schema/payment-method-card.js +48 -0
- package/dist/schema/payment-method-card.js.map +1 -0
- package/dist/schema/payment-method.d.ts +2 -0
- package/dist/schema/payment-method.d.ts.map +1 -0
- package/dist/schema/payment-method.js +27 -0
- package/dist/schema/payment-method.js.map +1 -0
- package/dist/schema/payment-methods.d.ts +2 -0
- package/dist/schema/payment-methods.d.ts.map +1 -0
- package/dist/schema/payment-methods.js +66 -0
- package/dist/schema/payment-methods.js.map +1 -0
- package/dist/schema/plan-transform-usage.d.ts +2 -0
- package/dist/schema/plan-transform-usage.d.ts.map +1 -0
- package/dist/schema/plan-transform-usage.js +15 -0
- package/dist/schema/plan-transform-usage.js.map +1 -0
- package/dist/schema/plan.d.ts +2 -0
- package/dist/schema/plan.d.ts.map +1 -0
- package/dist/schema/plan.js +69 -0
- package/dist/schema/plan.js.map +1 -0
- package/dist/schema/price.d.ts +2 -0
- package/dist/schema/price.d.ts.map +1 -0
- package/dist/schema/price.js +63 -0
- package/dist/schema/price.js.map +1 -0
- package/dist/schema/product.d.ts +2 -0
- package/dist/schema/product.d.ts.map +1 -0
- package/dist/schema/product.js +75 -0
- package/dist/schema/product.js.map +1 -0
- package/dist/schema/stripe.d.ts +2 -0
- package/dist/schema/stripe.d.ts.map +1 -0
- package/dist/schema/stripe.js +117 -0
- package/dist/schema/stripe.js.map +1 -0
- package/dist/schema/subscription-automatic-tax.d.ts +2 -0
- package/dist/schema/subscription-automatic-tax.d.ts.map +1 -0
- package/dist/schema/subscription-automatic-tax.js +10 -0
- package/dist/schema/subscription-automatic-tax.js.map +1 -0
- package/dist/schema/subscription-billing-thresholds.d.ts +2 -0
- package/dist/schema/subscription-billing-thresholds.d.ts.map +1 -0
- package/dist/schema/subscription-billing-thresholds.js +15 -0
- package/dist/schema/subscription-billing-thresholds.js.map +1 -0
- package/dist/schema/subscription-item-billing-thresholds.d.ts +2 -0
- package/dist/schema/subscription-item-billing-thresholds.d.ts.map +1 -0
- package/dist/schema/subscription-item-billing-thresholds.js +12 -0
- package/dist/schema/subscription-item-billing-thresholds.js.map +1 -0
- package/dist/schema/subscription-item.d.ts +2 -0
- package/dist/schema/subscription-item.d.ts.map +1 -0
- package/dist/schema/subscription-item.js +33 -0
- package/dist/schema/subscription-item.js.map +1 -0
- package/dist/schema/subscription-items.d.ts +2 -0
- package/dist/schema/subscription-items.d.ts.map +1 -0
- package/dist/schema/subscription-items.js +15 -0
- package/dist/schema/subscription-items.js.map +1 -0
- package/dist/schema/subscription-pause-collection.d.ts +2 -0
- package/dist/schema/subscription-pause-collection.d.ts.map +1 -0
- package/dist/schema/subscription-pause-collection.js +16 -0
- package/dist/schema/subscription-pause-collection.js.map +1 -0
- package/dist/schema/subscription.d.ts +2 -0
- package/dist/schema/subscription.d.ts.map +1 -0
- package/dist/schema/subscription.js +134 -0
- package/dist/schema/subscription.js.map +1 -0
- package/dist/schema/subscriptions.d.ts +2 -0
- package/dist/schema/subscriptions.d.ts.map +1 -0
- package/dist/schema/subscriptions.js +15 -0
- package/dist/schema/subscriptions.js.map +1 -0
- package/dist/schema/tax-rate.d.ts +2 -0
- package/dist/schema/tax-rate.d.ts.map +1 -0
- package/dist/schema/tax-rate.js +58 -0
- package/dist/schema/tax-rate.js.map +1 -0
- package/dist/schema/test-clock.d.ts +2 -0
- package/dist/schema/test-clock.d.ts.map +1 -0
- package/dist/schema/test-clock.js +19 -0
- package/dist/schema/test-clock.js.map +1 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +43 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +34 -0
- package/dist/utils.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const builder_1 = require("../builder");
|
|
4
|
+
builder_1.builder.objectType('StripeTaxRate', {
|
|
5
|
+
description: 'Tax rates can be applied to [invoices](https://stripe.com/docs/billing/invoices/tax-rates), [subscriptions](https://stripe.com/docs/billing/subscriptions/taxes) and [Checkout Sessions](https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates) to collect tax.',
|
|
6
|
+
fields: (t) => ({
|
|
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
|
+
active: t.exposeBoolean('active', {
|
|
14
|
+
description: 'Defaults to `true`. When set to `false`, this tax rate cannot be used with new applications or Checkout Sessions, but will still work for subscriptions and invoices that already have it set.'
|
|
15
|
+
}),
|
|
16
|
+
country: t.exposeString('country', {
|
|
17
|
+
description: 'Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).',
|
|
18
|
+
nullable: true
|
|
19
|
+
}),
|
|
20
|
+
created: t.exposeInt('created', {
|
|
21
|
+
description: 'Time at which the object was created. Measured in seconds since the Unix epoch.'
|
|
22
|
+
}),
|
|
23
|
+
description: t.exposeString('description', {
|
|
24
|
+
description: 'An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers.',
|
|
25
|
+
nullable: true
|
|
26
|
+
}),
|
|
27
|
+
displayName: t.exposeString('display_name', {
|
|
28
|
+
description: 'The display name of the tax rates as it will appear to your customer on their receipt email, PDF, and the hosted invoice page.'
|
|
29
|
+
}),
|
|
30
|
+
inclusive: t.exposeBoolean('inclusive', {
|
|
31
|
+
description: 'This specifies if the tax rate is inclusive or exclusive.'
|
|
32
|
+
}),
|
|
33
|
+
jurisdiction: t.exposeString('jurisdiction', {
|
|
34
|
+
description: 'The jurisdiction for the tax rate. You can use this label field for tax reporting purposes. It also appears on your customer’s invoice.',
|
|
35
|
+
nullable: true
|
|
36
|
+
}),
|
|
37
|
+
livemode: t.exposeBoolean('livemode', {
|
|
38
|
+
description: 'Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.'
|
|
39
|
+
}),
|
|
40
|
+
metadata: t.expose('metadata', {
|
|
41
|
+
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.',
|
|
42
|
+
type: 'JSON',
|
|
43
|
+
nullable: true
|
|
44
|
+
}),
|
|
45
|
+
percentage: t.exposeFloat('percentage', {
|
|
46
|
+
description: 'This represents the tax rate percent out of 100.'
|
|
47
|
+
}),
|
|
48
|
+
state: t.exposeString('state', {
|
|
49
|
+
description: '[ISO 3166-2 subdivision code](https://en.wikipedia.org/wiki/ISO_3166-2:US), without country prefix. For example, "NY" for New York, United States.',
|
|
50
|
+
nullable: true
|
|
51
|
+
}),
|
|
52
|
+
taxType: t.exposeString('tax_type', {
|
|
53
|
+
description: 'The high-level tax type, such as `vat` or `sales_tax`.',
|
|
54
|
+
nullable: true
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=tax-rate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tax-rate.js","sourceRoot":"","sources":["../../src/schema/tax-rate.ts"],"names":[],"mappings":";;AAAA,wCAAoC;AAEpC,iBAAO,CAAC,UAAU,CAAC,eAAe,EAAE;IAClC,WAAW,EACT,qRAAqR;IACvR,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,MAAM,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE;YAChC,WAAW,EACT,gMAAgM;SACnM,CAAC;QACF,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE;YACjC,WAAW,EACT,mGAAmG;YACrG,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE;YAC9B,WAAW,EAAE,iFAAiF;SAC/F,CAAC;QACF,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC,aAAa,EAAE;YACzC,WAAW,EACT,oHAAoH;YACtH,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,WAAW,EAAE,CAAC,CAAC,YAAY,CAAC,cAAc,EAAE;YAC1C,WAAW,EACT,gIAAgI;SACnI,CAAC;QACF,SAAS,EAAE,CAAC,CAAC,aAAa,CAAC,WAAW,EAAE;YACtC,WAAW,EAAE,2DAA2D;SACzE,CAAC;QACF,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC,cAAc,EAAE;YAC3C,WAAW,EACT,yIAAyI;YAC3I,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,CAAC,CAAC,aAAa,CAAC,UAAU,EAAE;YACpC,WAAW,EACT,gHAAgH;SACnH,CAAC;QACF,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE;YAC7B,WAAW,EACT,iMAAiM;YACnM,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,UAAU,EAAE,CAAC,CAAC,WAAW,CAAC,YAAY,EAAE;YACtC,WAAW,EAAE,kDAAkD;SAChE,CAAC;QACF,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE;YAC7B,WAAW,EACT,oJAAoJ;YACtJ,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,UAAU,EAAE;YAClC,WAAW,EAAE,wDAAwD;YACrE,QAAQ,EAAE,IAAI;SACf,CAAC;KACH,CAAC;CACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-clock.d.ts","sourceRoot":"","sources":["../../src/schema/test-clock.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const builder_1 = require("../builder");
|
|
4
|
+
builder_1.builder.objectType('StripeTestClock', {
|
|
5
|
+
description: '',
|
|
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'),
|
|
13
|
+
name: t.exposeString('name', {
|
|
14
|
+
nullable: true
|
|
15
|
+
}),
|
|
16
|
+
status: t.exposeString('status')
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=test-clock.js.map
|
|
@@ -0,0 +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"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { schema } from './schema';
|
|
3
|
+
import { Context, CreateServerProps } from './types';
|
|
4
|
+
declare const createStripeGraphQLServer: (params?: CreateServerProps) => import("@graphql-yoga/node").YogaNodeServerInstance<{
|
|
5
|
+
req: import("http").IncomingMessage;
|
|
6
|
+
res: import("http").ServerResponse;
|
|
7
|
+
}, Context, {}>;
|
|
8
|
+
export { createStripeGraphQLServer, schema };
|
|
9
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAGpD,QAAA,MAAM,yBAAyB,YAAa,iBAAiB;;;eA+C5D,CAAA;AAED,OAAO,EAAE,yBAAyB,EAAE,MAAM,EAAE,CAAA"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = exports.createStripeGraphQLServer = void 0;
|
|
4
|
+
const node_1 = require("@graphql-yoga/node");
|
|
5
|
+
const schema_1 = require("./schema");
|
|
6
|
+
Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return schema_1.schema; } });
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
const createStripeGraphQLServer = (params) => {
|
|
9
|
+
const cors = params === null || params === void 0 ? void 0 : params.cors;
|
|
10
|
+
const isAllowed = params === null || params === void 0 ? void 0 : params.isAllowed;
|
|
11
|
+
const graphiql = params === null || params === void 0 ? void 0 : params.graphiql;
|
|
12
|
+
const context = (context) => {
|
|
13
|
+
const { request } = context;
|
|
14
|
+
// user id
|
|
15
|
+
const userClaims = (0, utils_1.getUserClaims)(request);
|
|
16
|
+
// check if using correct `x-hasura-admin-secret` header
|
|
17
|
+
const adminSecretFromHeader = request.headers.get('x-hasura-admin-secret');
|
|
18
|
+
const adminSecret = process.env.NHOST_ADMIN_SECRET;
|
|
19
|
+
// check if the request is from Hasura
|
|
20
|
+
const nhostWebhookSecretFromHeader = request.headers.get('x-nhost-webhook-secret');
|
|
21
|
+
const nhostWebhookSecret = process.env.NHOST_WEBHOOK_SECRET;
|
|
22
|
+
const role = request.headers.get('x-hasura-role');
|
|
23
|
+
// variables
|
|
24
|
+
const isAdmin = adminSecretFromHeader === adminSecret ||
|
|
25
|
+
(role === 'admin' && nhostWebhookSecretFromHeader === nhostWebhookSecret);
|
|
26
|
+
// if no isAllowed function is provided, we will allow admin requests
|
|
27
|
+
const isAllowedFunction = isAllowed ||
|
|
28
|
+
((_stripeCustomerId, context) => {
|
|
29
|
+
return context.isAdmin;
|
|
30
|
+
});
|
|
31
|
+
// return
|
|
32
|
+
return Object.assign(Object.assign({}, context), { isAllowed: isAllowedFunction, userClaims,
|
|
33
|
+
isAdmin });
|
|
34
|
+
};
|
|
35
|
+
return (0, node_1.createServer)({
|
|
36
|
+
cors,
|
|
37
|
+
graphiql,
|
|
38
|
+
context,
|
|
39
|
+
schema: schema_1.schema
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.createStripeGraphQLServer = createStripeGraphQLServer;
|
|
43
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;AAAA,6CAAqE;AAErE,qCAAiC;AAqDG,uFArD3B,eAAM,OAqD2B;AAnD1C,mCAAuC;AAEvC,MAAM,yBAAyB,GAAG,CAAC,MAA0B,EAAE,EAAE;IAC/D,MAAM,IAAI,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAA;IACzB,MAAM,SAAS,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAA;IACnC,MAAM,QAAQ,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAA;IAEjC,MAAM,OAAO,GAAG,CAAC,OAA2B,EAAW,EAAE;QACvD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;QAE3B,UAAU;QACV,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAA;QAEzC,wDAAwD;QACxD,MAAM,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;QAC1E,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAA;QAElD,sCAAsC;QACtC,MAAM,4BAA4B,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;QAClF,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAA;QAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QAEjD,YAAY;QACZ,MAAM,OAAO,GACX,qBAAqB,KAAK,WAAW;YACrC,CAAC,IAAI,KAAK,OAAO,IAAI,4BAA4B,KAAK,kBAAkB,CAAC,CAAA;QAE3E,qEAAqE;QACrE,MAAM,iBAAiB,GACrB,SAAS;YACT,CAAC,CAAC,iBAAyB,EAAE,OAAgB,EAAE,EAAE;gBAC/C,OAAO,OAAO,CAAC,OAAO,CAAA;YACxB,CAAC,CAAC,CAAA;QAEJ,SAAS;QACT,uCACK,OAAO,KACV,SAAS,EAAE,iBAAiB,EAC5B,UAAU;YACV,OAAO,IACR;IACH,CAAC,CAAA;IAED,OAAO,IAAA,mBAAY,EAAC;QAClB,IAAI;QACJ,QAAQ;QACR,OAAO;QACP,MAAM,EAAN,eAAM;KACP,CAAC,CAAA;AACJ,CAAC,CAAA;AAEQ,8DAAyB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type Stripe from 'stripe';
|
|
2
|
+
import type { CORSOptions, YogaInitialContext } from '@graphql-yoga/node';
|
|
3
|
+
export declare type StripeGraphQLContext = {
|
|
4
|
+
isAllowed: (stripeCustomerId: string, context: Context) => boolean;
|
|
5
|
+
userClaims?: UserHasuraClaims;
|
|
6
|
+
isAdmin: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare type Context = YogaInitialContext & StripeGraphQLContext;
|
|
9
|
+
export declare type CreateServerProps = {
|
|
10
|
+
cors?: CORSOptions;
|
|
11
|
+
isAllowed?: (stripeCustomerId: string, context: Context) => boolean;
|
|
12
|
+
graphiql?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare type StripePaymentMethod = Stripe.PaymentMethod & {
|
|
15
|
+
customer: string | null;
|
|
16
|
+
};
|
|
17
|
+
export declare type StripeSubscription = Stripe.Subscription & {
|
|
18
|
+
customer: string;
|
|
19
|
+
test_clock: string | null;
|
|
20
|
+
};
|
|
21
|
+
export declare type StripeInvoice = Stripe.Invoice & {
|
|
22
|
+
id: string;
|
|
23
|
+
customer: string;
|
|
24
|
+
default_payment_method: StripePaymentMethod | null;
|
|
25
|
+
};
|
|
26
|
+
export declare type UserHasuraClaims = {
|
|
27
|
+
'x-hasura-user-id': string;
|
|
28
|
+
'x-hasura-default-role': string;
|
|
29
|
+
'x-hasura-allowed-roles': string[];
|
|
30
|
+
} & {
|
|
31
|
+
[key: string]: string;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,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/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAM1C,eAAO,MAAM,MAAM,QAEjB,CAAA;AAEF,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,gBAAgB,GAAG,SAqB/D,CAAA"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getUserClaims = exports.stripe = void 0;
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
+
const stripe_1 = __importDefault(require("stripe"));
|
|
9
|
+
if (!process.env.STRIPE_SECRET_KEY) {
|
|
10
|
+
throw new Error('STRIPE_SECRET_KEY env var is not set');
|
|
11
|
+
}
|
|
12
|
+
exports.stripe = new stripe_1.default(process.env.STRIPE_SECRET_KEY, {
|
|
13
|
+
apiVersion: '2022-08-01'
|
|
14
|
+
});
|
|
15
|
+
const getUserClaims = (req) => {
|
|
16
|
+
try {
|
|
17
|
+
const authorizationHeader = req.headers.get('authorization');
|
|
18
|
+
const accessToken = authorizationHeader === null || authorizationHeader === void 0 ? void 0 : authorizationHeader.split(' ')[1];
|
|
19
|
+
if (!accessToken) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
if (!process.env.NHOST_JWT_SECRET) {
|
|
23
|
+
throw new Error('NHOST_JWT_SECRET env var is not set');
|
|
24
|
+
}
|
|
25
|
+
const jwtSecret = JSON.parse(process.env.NHOST_JWT_SECRET);
|
|
26
|
+
const decodedToken = jsonwebtoken_1.default.verify(accessToken, jwtSecret.key);
|
|
27
|
+
return decodedToken['https://hasura.io/jwt/claims'];
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.getUserClaims = getUserClaims;
|
|
34
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,gEAA8B;AAC9B,oDAA2B;AAI3B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;IAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;CACxD;AAEY,QAAA,MAAM,GAAG,IAAI,gBAAM,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE;IAC9D,UAAU,EAAE,YAAY;CACzB,CAAC,CAAA;AAEK,MAAM,aAAa,GAAG,CAAC,GAAY,EAAgC,EAAE;IAC1E,IAAI;QACF,MAAM,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QAE5D,MAAM,WAAW,GAAG,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QAEtD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,SAAS,CAAA;SACjB;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;SACvD;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;QAE1D,MAAM,YAAY,GAAG,sBAAG,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,CAAQ,CAAA;QAClE,OAAO,YAAY,CAAC,8BAA8B,CAAqB,CAAA;KACxE;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,SAAS,CAAA;KACjB;AACH,CAAC,CAAA;AArBY,QAAA,aAAa,iBAqBzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nhost/stripe-graphql-js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Stripe GraphQL API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -53,5 +53,6 @@
|
|
|
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
|
-
}
|
|
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\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"
|
|
57
58
|
}
|