@manifoldco/manifold-subscription
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -8,5 +8,5 @@ 'use strict'; | ||
const defineCustomElements = (win, options) => index.patchEsm().then(() => { | ||
return index.bootstrapLazy([["manifold-configured-feature_4.cjs",[[0,"manifold-configured-feature",{"label":[1],"value":[8]}],[0,"manifold-subscription-create",{"loading":[1028],"isLoadingPlanSelector":[1028,"is-loading-plan-selector"],"errors":[1040],"data":[1040],"planListData":[1040],"setupIntentStatus":[1025,"setup-intent-status"],"setupIntentError":[1025,"setup-intent-error"],"subscribing":[1028],"configuredFeatures":[1040],"calculatedCost":[1026,"calculated-cost"],"isEditing":[1028,"is-editing"],"preview":[4],"heading":[1],"planId":[1025,"plan-id"],"ownerId":[1,"owner-id"],"stripePublishableKey":[1,"stripe-publishable-key"],"displayName":[1,"display-name"],"label":[1],"card":[32],"cardStatus":[32],"profile":[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{"subscriptionId":[1,"subscription-id"],"planId":[1,"plan-id"],"heading":[1],"isEditing":[4,"is-editing"],"preview":[4]}],[0,"manifold-subscription-list",{"connection":[1040],"loading":[1028],"errors":[1040],"data":[1040],"subLinkFormat":[1025,"sub-link-format"],"heading":[1],"owner":[1]}]]]], options); | ||
return index.bootstrapLazy([["manifold-configured-feature_4.cjs",[[0,"manifold-configured-feature",{"label":[1],"value":[8]}],[0,"manifold-subscription-create",{"loading":[1028],"isLoadingPlanSelector":[1028,"is-loading-plan-selector"],"errors":[1040],"data":[1040],"planListData":[1040],"setupIntentStatus":[1025,"setup-intent-status"],"setupIntentError":[1025,"setup-intent-error"],"subscribing":[1028],"configuredFeatures":[1040],"calculatedCost":[1026,"calculated-cost"],"isEditing":[1028,"is-editing"],"preview":[4],"heading":[1],"planId":[1025,"plan-id"],"ownerId":[1,"owner-id"],"stripePublishableKey":[1,"stripe-publishable-key"],"displayName":[1,"display-name"],"label":[1],"card":[32],"cardStatus":[32],"profile":[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{"subscriptionId":[1,"subscription-id"],"planId":[1,"plan-id"],"heading":[1],"isEditing":[4,"is-editing"],"preview":[4]}],[0,"manifold-subscription-list",{"connection":[1040],"loading":[1028],"errors":[1040],"data":[1040],"productId":[1,"product-id"],"preview":[4],"subLinkFormat":[1025,"sub-link-format"],"heading":[1],"owner":[1]}]]]], options); | ||
}); | ||
exports.defineCustomElements = defineCustomElements; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
index.patchBrowser().then(options => { | ||
return index.bootstrapLazy([["manifold-configured-feature_4.cjs",[[0,"manifold-configured-feature",{"label":[1],"value":[8]}],[0,"manifold-subscription-create",{"loading":[1028],"isLoadingPlanSelector":[1028,"is-loading-plan-selector"],"errors":[1040],"data":[1040],"planListData":[1040],"setupIntentStatus":[1025,"setup-intent-status"],"setupIntentError":[1025,"setup-intent-error"],"subscribing":[1028],"configuredFeatures":[1040],"calculatedCost":[1026,"calculated-cost"],"isEditing":[1028,"is-editing"],"preview":[4],"heading":[1],"planId":[1025,"plan-id"],"ownerId":[1,"owner-id"],"stripePublishableKey":[1,"stripe-publishable-key"],"displayName":[1,"display-name"],"label":[1],"card":[32],"cardStatus":[32],"profile":[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{"subscriptionId":[1,"subscription-id"],"planId":[1,"plan-id"],"heading":[1],"isEditing":[4,"is-editing"],"preview":[4]}],[0,"manifold-subscription-list",{"connection":[1040],"loading":[1028],"errors":[1040],"data":[1040],"subLinkFormat":[1025,"sub-link-format"],"heading":[1],"owner":[1]}]]]], options); | ||
return index.bootstrapLazy([["manifold-configured-feature_4.cjs",[[0,"manifold-configured-feature",{"label":[1],"value":[8]}],[0,"manifold-subscription-create",{"loading":[1028],"isLoadingPlanSelector":[1028,"is-loading-plan-selector"],"errors":[1040],"data":[1040],"planListData":[1040],"setupIntentStatus":[1025,"setup-intent-status"],"setupIntentError":[1025,"setup-intent-error"],"subscribing":[1028],"configuredFeatures":[1040],"calculatedCost":[1026,"calculated-cost"],"isEditing":[1028,"is-editing"],"preview":[4],"heading":[1],"planId":[1025,"plan-id"],"ownerId":[1,"owner-id"],"stripePublishableKey":[1,"stripe-publishable-key"],"displayName":[1,"display-name"],"label":[1],"card":[32],"cardStatus":[32],"profile":[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{"subscriptionId":[1,"subscription-id"],"planId":[1,"plan-id"],"heading":[1],"isEditing":[4,"is-editing"],"preview":[4]}],[0,"manifold-subscription-list",{"connection":[1040],"loading":[1028],"errors":[1040],"data":[1040],"productId":[1,"product-id"],"preview":[4],"subLinkFormat":[1025,"sub-link-format"],"heading":[1],"owner":[1]}]]]], options); | ||
}); |
import { Component, Event, Element, Prop, h, Watch } from '@stencil/core'; | ||
import ListCard from './components/ListCard'; | ||
import query from './subscriptions.graphql'; | ||
import fragment from './list-plan-fragment.graphql'; | ||
import query from './subscription-list.graphql'; | ||
import previewQuery from './subscription-list-preview.graphql'; | ||
const fetchSubscriptionList = async (args) => { | ||
const { owner, connection, preview, productId } = args; | ||
if (preview && productId) { | ||
const variables = { productId }; | ||
const res = await connection.graphqlFetch({ | ||
query: fragment + previewQuery, | ||
variables, | ||
}); | ||
if (res.data) { | ||
const edges = res.data.product.plans.edges.map(({ node }) => ({ | ||
node: { | ||
id: node.id, | ||
plan: node, | ||
}, | ||
})); | ||
return { | ||
data: { | ||
subscriptions: { | ||
edges, | ||
}, | ||
}, | ||
errors: null, | ||
}; | ||
} | ||
return { errors: res.errors }; | ||
} | ||
const variables = { owner }; | ||
const res = await connection.graphqlFetch({ | ||
query: fragment + query, | ||
variables, | ||
}); | ||
return res; | ||
}; | ||
export class ManifoldSubscriptionList { | ||
constructor() { | ||
this.loading = false; | ||
/** | ||
* Puts the component in preview mode | ||
*/ | ||
this.preview = false; | ||
this.handleCtaClick = (subId, href) => (e) => { | ||
@@ -30,3 +69,3 @@ e.preventDefault(); | ||
async getSubscriptions(owner) { | ||
if (!owner) { | ||
if (!owner && !this.preview) { | ||
throw new Error('Missing property `owner` on `manifold-subscription-list`'); | ||
@@ -38,6 +77,7 @@ } | ||
this.loading = true; | ||
const variables = { owner }; | ||
const { data, errors } = await this.connection.graphqlFetch({ | ||
query, | ||
variables, | ||
const { data, errors } = await fetchSubscriptionList({ | ||
owner, | ||
connection: this.connection, | ||
preview: this.preview, | ||
productId: this.productId, | ||
}); | ||
@@ -138,6 +178,6 @@ if (errors) { | ||
"complexType": { | ||
"original": "SubscriptionsQuery", | ||
"resolved": "undefined | { __typename?: \"Query\" | undefined; } & { subscriptions: { __typename?: \"SubscriptionAgreementConnection\" | undefined; } & { edges: ({ __typename?: \"SubscriptionAgreementEdge\" | undefined; } & { node: { __typename?: \"SubscriptionAgreement\" | undefined; } & Pick<SubscriptionAgreement, \"id\"> & { plan: { __typename?: \"Plan\" | undefined; } & Pick<Plan, \"displayName\" | \"cost\"> & { configurableFeatures: { __typename?: \"PlanConfigurableFeatureConnection\" | undefined; } & { edges: ({ __typename?: \"PlanConfigurableFeatureEdge\" | undefined; } & { node: { __typename?: \"PlanConfigurableFeature\" | undefined; } & Pick<PlanConfigurableFeature, \"displayName\">; })[]; }; }; }; })[]; }; }", | ||
"original": "SubscriptionListQuery", | ||
"resolved": "undefined | { __typename?: \"Query\" | undefined; } & { subscriptions: { __typename?: \"SubscriptionAgreementConnection\" | undefined; } & { edges: ({ __typename?: \"SubscriptionAgreementEdge\" | undefined; } & { node: { __typename?: \"SubscriptionAgreement\" | undefined; } & Pick<SubscriptionAgreement, \"id\"> & { plan: { __typename?: \"Plan\" | undefined; } & { __typename?: \"Plan\" | undefined; } & Pick<Plan, \"displayName\" | \"cost\" | \"id\"> & { configurableFeatures: { __typename?: \"PlanConfigurableFeatureConnection\" | undefined; } & { edges: ({ __typename?: \"PlanConfigurableFeatureEdge\" | undefined; } & { node: { __typename?: \"PlanConfigurableFeature\" | undefined; } & Pick<PlanConfigurableFeature, \"displayName\">; })[]; }; }; }; })[]; }; }", | ||
"references": { | ||
"SubscriptionsQuery": { | ||
"SubscriptionListQuery": { | ||
"location": "import", | ||
@@ -155,2 +195,37 @@ "path": "../../types/graphql" | ||
}, | ||
"productId": { | ||
"type": "string", | ||
"mutable": false, | ||
"complexType": { | ||
"original": "string", | ||
"resolved": "string | undefined", | ||
"references": {} | ||
}, | ||
"required": false, | ||
"optional": true, | ||
"docs": { | ||
"tags": [], | ||
"text": "" | ||
}, | ||
"attribute": "product-id", | ||
"reflect": false | ||
}, | ||
"preview": { | ||
"type": "boolean", | ||
"mutable": false, | ||
"complexType": { | ||
"original": "boolean", | ||
"resolved": "boolean | undefined", | ||
"references": {} | ||
}, | ||
"required": false, | ||
"optional": true, | ||
"docs": { | ||
"tags": [], | ||
"text": "Puts the component in preview mode" | ||
}, | ||
"attribute": "preview", | ||
"reflect": false, | ||
"defaultValue": "false" | ||
}, | ||
"subLinkFormat": { | ||
@@ -157,0 +232,0 @@ "type": "string", |
@@ -1,1 +0,1 @@ | ||
import{p as i,b as e}from"./p-a98c757b.js";i().then(i=>e([["p-4339398f",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],preview:[4],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32],profile:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],planId:[1,"plan-id"],heading:[1],isEditing:[4,"is-editing"],preview:[4]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],i)); | ||
import{p as i,b as e}from"./p-a98c757b.js";i().then(i=>e([["p-120e8468",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],preview:[4],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32],profile:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],planId:[1,"plan-id"],heading:[1],isEditing:[4,"is-editing"],preview:[4]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],productId:[1,"product-id"],preview:[4],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],i)); |
@@ -1,1 +0,1 @@ | ||
System.register(["./p-a956fdd1.system.js"],(function(){"use strict";var e,i;return{setters:[function(t){e=t.p;i=t.b}],execute:function(){e().then((function(e){return i([["p-3eb0e4f3.system",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],preview:[4],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32],profile:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],planId:[1,"plan-id"],heading:[1],isEditing:[4,"is-editing"],preview:[4]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],e)}))}}})); | ||
System.register(["./p-a956fdd1.system.js"],(function(){"use strict";var e,i;return{setters:[function(t){e=t.p;i=t.b}],execute:function(){e().then((function(e){return i([["p-5481db90.system",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],preview:[4],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32],profile:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],planId:[1,"plan-id"],heading:[1],isEditing:[4,"is-editing"],preview:[4]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],productId:[1,"product-id"],preview:[4],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],e)}))}}})); |
@@ -9,3 +9,3 @@ /* eslint-disable */ | ||
import { UIError, } from "./utils/error"; | ||
import { PlanListQuery, PlanQuery, SubscriptionsQuery, } from "./types/graphql"; | ||
import { PlanListQuery, PlanQuery, SubscriptionListQuery, } from "./types/graphql"; | ||
import { SetupIntent, } from "@stripe/stripe-js"; | ||
@@ -70,3 +70,3 @@ import { FeatureMap, } from "./utils/plan"; | ||
"connection"?: Connection; | ||
"data"?: SubscriptionsQuery; | ||
"data"?: SubscriptionListQuery; | ||
"errors"?: GraphqlError[]; | ||
@@ -83,2 +83,7 @@ /** | ||
/** | ||
* Puts the component in preview mode | ||
*/ | ||
"preview"?: boolean; | ||
"productId"?: string; | ||
/** | ||
* Component subscription link format | ||
@@ -180,3 +185,3 @@ */ | ||
"connection"?: Connection; | ||
"data"?: SubscriptionsQuery; | ||
"data"?: SubscriptionListQuery; | ||
"errors"?: GraphqlError[]; | ||
@@ -194,2 +199,7 @@ /** | ||
/** | ||
* Puts the component in preview mode | ||
*/ | ||
"preview"?: boolean; | ||
"productId"?: string; | ||
/** | ||
* Component subscription link format | ||
@@ -196,0 +206,0 @@ */ |
import { EventEmitter } from '@stencil/core'; | ||
import { Connection } from '@manifoldco/manifold-init-types/types/v0'; | ||
import { GraphqlError } from '@manifoldco/manifold-init-types/types/v0/graphqlFetch'; | ||
import { SubscriptionsQuery } from '../../types/graphql'; | ||
import { SubscriptionListQuery } from '../../types/graphql'; | ||
export declare class ManifoldSubscriptionList { | ||
@@ -11,4 +11,9 @@ el: HTMLElement; | ||
errors?: GraphqlError[]; | ||
data?: SubscriptionsQuery; | ||
data?: SubscriptionListQuery; | ||
productId?: string; | ||
/** | ||
* Puts the component in preview mode | ||
*/ | ||
preview?: boolean; | ||
/** | ||
* Component subscription link format | ||
@@ -15,0 +20,0 @@ */ |
@@ -1435,6 +1435,43 @@ export declare type Maybe<T> = T; | ||
}); | ||
export declare type SubscriptionsQueryVariables = { | ||
export declare type ListPlanFragment = ({ | ||
__typename?: 'Plan'; | ||
} & Pick<Plan, 'id' | 'displayName' | 'cost'> & { | ||
configurableFeatures: Maybe<({ | ||
__typename?: 'PlanConfigurableFeatureConnection'; | ||
} & { | ||
edges: Array<({ | ||
__typename?: 'PlanConfigurableFeatureEdge'; | ||
} & { | ||
node: ({ | ||
__typename?: 'PlanConfigurableFeature'; | ||
} & Pick<PlanConfigurableFeature, 'displayName'>); | ||
})>; | ||
})>; | ||
}); | ||
export declare type SubscriptionListPreviewQueryVariables = { | ||
productId: Scalars['ID']; | ||
}; | ||
export declare type SubscriptionListPreviewQuery = ({ | ||
__typename?: 'Query'; | ||
} & { | ||
product: Maybe<({ | ||
__typename?: 'Product'; | ||
} & { | ||
plans: Maybe<({ | ||
__typename?: 'PlanConnection'; | ||
} & { | ||
edges: Array<({ | ||
__typename?: 'PlanEdge'; | ||
} & { | ||
node: ({ | ||
__typename?: 'Plan'; | ||
} & ListPlanFragment); | ||
})>; | ||
})>; | ||
})>; | ||
}); | ||
export declare type SubscriptionListQueryVariables = { | ||
owner: Scalars['ProfileIdentity']; | ||
}; | ||
export declare type SubscriptionsQuery = ({ | ||
export declare type SubscriptionListQuery = ({ | ||
__typename?: 'Query'; | ||
@@ -1453,15 +1490,3 @@ } & { | ||
__typename?: 'Plan'; | ||
} & Pick<Plan, 'displayName' | 'cost'> & { | ||
configurableFeatures: Maybe<({ | ||
__typename?: 'PlanConfigurableFeatureConnection'; | ||
} & { | ||
edges: Array<({ | ||
__typename?: 'PlanConfigurableFeatureEdge'; | ||
} & { | ||
node: ({ | ||
__typename?: 'PlanConfigurableFeature'; | ||
} & Pick<PlanConfigurableFeature, 'displayName'>); | ||
})>; | ||
})>; | ||
})>; | ||
} & ListPlanFragment)>; | ||
})>; | ||
@@ -1468,0 +1493,0 @@ })>; |
{ | ||
"name": "@manifoldco/manifold-subscription", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Manifold Subscription Web Components", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1407999
21956