1+ import { VariablesOf } from '@graphql-typed-document-node/core' ;
12import { Context } from './context' ;
23import { PlainSDKError } from './error' ;
34import {
5+ AddCustomerToCustomerGroupsDocument ,
6+ CustomerByIdDocument ,
47 CustomerGroupMembershipPartsFragment ,
58 RemoveCustomerFromCustomerGroupsDocument ,
6- RemoveCustomerFromCustomerGroupsInput ,
79} from './graphql/types' ;
8- import { AddCustomerToCustomerGroupsDocument } from './graphql/types' ;
9- import { AddCustomerToCustomerGroupsInput } from './graphql/types' ;
1010import {
1111 CreateIssueDocument ,
12- CreateIssueInput ,
13- CustomerByIdDocument ,
14- CustomerByIdQueryVariables ,
1512 CustomerPartsFragment ,
1613 IssuePartsFragment ,
1714 TimelineEntryPartsFragment ,
1815 UpsertCustomTimelineEntryDocument ,
19- UpsertCustomTimelineEntryInput ,
2016 UpsertCustomerDocument ,
21- UpsertCustomerInput ,
2217 UpsertResult ,
2318} from './graphql/types' ;
2419import { request } from './request' ;
2520import { Result } from './result' ;
2621
2722type SDKResult < T > = Promise < Result < T , PlainSDKError > > ;
2823
29- function nonNullable < T > ( x : T | null ) : T {
30- if ( x === null ) {
24+ function nonNullable < T > ( x : T | null | undefined ) : T {
25+ if ( x === null || x === undefined ) {
3126 throw new Error ( `Expected value to be non nullable` ) ;
3227 }
3328
@@ -74,12 +69,12 @@ export class PlainSDKClient {
7469 /**
7570 * If the customer is not found this will return null.
7671 */
77- async getCustomerById ( args : CustomerByIdQueryVariables ) : SDKResult < CustomerPartsFragment | null > {
72+ async getCustomerById (
73+ variables : VariablesOf < typeof CustomerByIdDocument >
74+ ) : SDKResult < CustomerPartsFragment | null > {
7875 const res = await request ( this . #ctx, {
7976 query : CustomerByIdDocument ,
80- variables : {
81- customerId : args . customerId ,
82- } ,
77+ variables,
8378 } ) ;
8479
8580 return unwrapData ( res , ( q ) => q . customer ) ;
@@ -89,7 +84,9 @@ export class PlainSDKClient {
8984 * Allows you to create or update a customer. If you need to get the customer id
9085 * for a customer in Plain, this is typically your first step.
9186 */
92- async upsertCustomer ( input : UpsertCustomerInput ) : SDKResult < CustomerPartsFragment | null > {
87+ async upsertCustomer (
88+ input : VariablesOf < typeof UpsertCustomerDocument > [ 'input' ]
89+ ) : SDKResult < CustomerPartsFragment > {
9390 const res = await request ( this . #ctx, {
9491 query : UpsertCustomerDocument ,
9592 variables : {
@@ -104,7 +101,9 @@ export class PlainSDKClient {
104101 * Create an issue for a customer. If you want you can override the default issue priority
105102 * in your settings by specifying a priority manually here.
106103 */
107- async createIssue ( input : CreateIssueInput ) : SDKResult < IssuePartsFragment > {
104+ async createIssue (
105+ input : VariablesOf < typeof CreateIssueDocument > [ 'input' ]
106+ ) : SDKResult < IssuePartsFragment > {
108107 const res = await request ( this . #ctx, {
109108 query : CreateIssueDocument ,
110109 variables : {
@@ -119,7 +118,7 @@ export class PlainSDKClient {
119118 * Adds a customer to a customer groups.
120119 */
121120 async addCustomerToCustomerGroups (
122- input : AddCustomerToCustomerGroupsInput
121+ input : VariablesOf < typeof AddCustomerToCustomerGroupsDocument > [ 'input' ]
123122 ) : SDKResult < CustomerGroupMembershipPartsFragment [ ] > {
124123 const res = await request ( this . #ctx, {
125124 query : AddCustomerToCustomerGroupsDocument ,
@@ -137,7 +136,7 @@ export class PlainSDKClient {
137136 * Remove a customer from customer groups.
138137 */
139138 async removeCustomerFromCustomerGroups (
140- input : RemoveCustomerFromCustomerGroupsInput
139+ input : VariablesOf < typeof RemoveCustomerFromCustomerGroupsDocument > [ 'input' ]
141140 ) : SDKResult < null > {
142141 const res = await request ( this . #ctx, {
143142 query : RemoveCustomerFromCustomerGroupsDocument ,
@@ -155,7 +154,7 @@ export class PlainSDKClient {
155154 * This can be used to power custom contact forms, log events from your own systems and much more.
156155 */
157156 async upsertCustomTimelineEntry (
158- input : UpsertCustomTimelineEntryInput
157+ input : VariablesOf < typeof UpsertCustomTimelineEntryDocument > [ 'input' ]
159158 ) : SDKResult < { result : UpsertResult ; timelineEntry : TimelineEntryPartsFragment } > {
160159 const res = await request ( this . #ctx, {
161160 query : UpsertCustomTimelineEntryDocument ,
0 commit comments