conductor-node 8.6.5 → 9.0.0

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 CHANGED
@@ -167,23 +167,21 @@ Any and every error thrown by the Conductor API will be an instance of `Conducto
167
167
  | `type` | `string` | The error type, which categorizes the error. See [Error Types](#error-types) below.<br><br>This value is the same as the subclass name. E.g., `"ConductorIntegrationError"` or `"ConductorInvalidRequestError"`. |
168
168
  | `code` | `string` | The unique error code from Conductor, which is useful for adding special handling for specific errors. E.g., `"INTEGRATION_CONNECTION_MISSING"`, `"API_KEY_INVALID"`, or `"QBD_REQUEST_ERROR"`.<br><br>By comparison, `type` is more general and categorizes the error. |
169
169
  | `message` | `string` | The developer-friendly error message for your logs. |
170
- | `endUserMessage` | `string` | The end-user-friendly error message to display in your app's UI for your end-user to see.<br><br>This value exists for _every_ error. E.g., if it's a QBD connection error, it might recommend the end-user to check that their QuickBooks Desktop is open and that they're logged in. But if a Conductor API key is expired, this message will just say "An internal server error occurred. Please try again later.". |
171
- | `integrationCode` | `string` or `undefined` | The unique error code supplied by the third-party integration for errors that come from the integration (i.e., instances of `ConductorIntegrationError`). This is useful for adding special handling for specific errors from the third-party integration.<br><br>E.g., QuickBooks Desktop might return an error with `integrationCode` for something specific to its accounting logic. The integration's corresponding message for this code would be in `error.message`.<br><br>The third-party integration's error codes are not standardized, so you should not rely on this code to be the same across integrations. |
170
+ | `endUserMessage` | `string` | The end-user-friendly error message to display in your app's UI for your end-user to see.<br><br>This value exists for _every_ error. E.g., if it's a QBD connection error, it might recommend the end-user to check that their QuickBooks Desktop is open and that they're logged in. But if a Conductor API key is expired, e.g., this message will just say "An internal server error occurred. Please try again later.". |
171
+ | `integrationCode` | `string` or `undefined` | The unique error code supplied by the third-party integration for errors that come from the integration (i.e., instances of `ConductorIntegrationError`). This is useful for adding special handling for specific errors from the third-party integration.<br><br>E.g., QuickBooks Desktop might return an error with `integrationCode` for something specific to its accounting logic. The integration's corresponding error message for this code is in `error.message`.<br><br>The third-party integration's error codes are not standardized, so you should not rely on this code to be the same across integrations. |
172
172
  | `httpStatusCode` | `number` or `undefined` | The HTTP status code of the response that included the error. You probably won't need this. |
173
173
 
174
- _Would any additional error properties be helpful?_ Let me know. Some potential additions: `request` for the original API request, `integrationKey` (e.g., `"quickbooks-desktop"`), or `integrationConnectionId`.
175
-
176
174
  ### Error Types
177
175
 
178
176
  The error object you receive will have one of the following error types:
179
177
 
180
- | Type | Description |
181
- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
182
- | `ConductorIntegrationError` | An error occurred on the third-party integration's end while processing your end-user's request. E.g., cannot connect to QuickBooks Desktop on your end-user's computer. |
183
- | `ConductorInvalidRequestError` | You made an API call with the wrong parameters, in the wrong state, or in an invalid way. |
184
- | `ConductorAuthenticationError` | Conductor cannot authenticate you with the credentials you provided. E.g., an incorrect API key. |
185
- | `ConductorConnectionError` | There was a network problem between the client (on your server) and Conductor's servers. |
186
- | `ConductorInternalError` | Something went wrong on Conductor's end. (These are rare.) |
178
+ | Type | Description |
179
+ | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
180
+ | `ConductorIntegrationError` | The third-party integration's return an error while processing your end-user's request. E.g., cannot connect to QuickBooks Desktop on your end-user's computer.<br><br>See `error.integrationCode` for the error code that the third-party integration returned. |
181
+ | `ConductorInvalidRequestError` | You made an API call with the wrong parameters, in the wrong state, or in an invalid way. |
182
+ | `ConductorAuthenticationError` | Conductor cannot authenticate you with the credentials you provided. E.g., an incorrect API key. |
183
+ | `ConductorConnectionError` | There was a network problem between the client (on your server) and Conductor's servers. |
184
+ | `ConductorInternalError` | Something went wrong on Conductor's end. (These are rare.) |
187
185
 
188
186
  ### Specific Error Handling
189
187
 
@@ -232,7 +230,7 @@ try {
232
230
 
233
231
  We do _not_ expect you to individually wrap every API call like the examples above. Instead, we recommend your server use a single global error handler, such as [`app.use((error, ...) => { ... })` in Express](https://expressjs.com/en/guide/error-handling.html#writing-error-handlers) or [`formatError` in Apollo Server](https://apollographql.com/docs/apollo-server/data/errors/#for-client-responses), where you do the following:
234
232
 
235
- 1. Ensure your app's UI shows your end-user the property `error.endUserMessage` for any `ConductorError` instance for any Conductor request while you log the rest of the error object.
233
+ 1. Ensure your app's UI shows your end-user the property `error.endUserMessage` for any `ConductorError` instance while you log the rest of the error object.
236
234
  2. Send the entire error object to your error-tracking service (e.g., Sentry) for all `ConductorError` instances:
237
235
  - Send a **warning** for instances of `ConductorIntegrationError`, which are your end-user's fault; e.g., cannot connect to QBD on your end-user's computer.
238
236
  - Send an **error** for all other `ConductorError` instances; e.g., invalid API key.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "8.6.5",
3
+ "version": "9.0.0",
4
4
  "description": "Easily integrate with the entire QuickBooks Desktop API with fully-typed async TypeScript",
5
5
  "author": "Danny Nemer <hi@DannyNemer.com>",
6
6
  "license": "MIT",
@@ -16,8 +16,11 @@
16
16
  "delete-compiled-tests": "rm -rf `find ./dist -type d -name __tests__` ./dist/src/utils/testing.*",
17
17
  "postpack": "rm -rf dist",
18
18
  "clean": "rm -rf dist package conductor-node-*.tgz tsconfig.tsbuildinfo",
19
- "gen:graphql": "yarn graphql-codegen --config ./src/graphql/codegenConfig.ts",
20
- "diff": "yarn pack && npm diff --diff=conductor-node@latest --diff=conductor-node-v$(node -p \"require('./package.json').version\").tgz && yarn clean"
19
+ "gen:graphql": "yarn graphql-codegen --config=./src/graphql/codegenConfig.ts",
20
+ "diff": "yarn pack && npm diff --diff=conductor-node@latest --diff=conductor-node-v$(node -p \"require('./package.json').version\").tgz && yarn clean",
21
+ "prepublishOnly": "yarn test",
22
+ "test": "yarn --cwd=../.. test ./packages/client",
23
+ "jest": "yarn --cwd=../../ jest"
21
24
  },
22
25
  "engines": {
23
26
  "node": ">=16"
@@ -1,4 +1,4 @@
1
- import type { GraphqlCreateIntegrationConnectionInput, GraphqlCreateIntegrationConnectionMutation, GraphqlGetConnectionStatusQuery, GraphqlGetConnectionStatusQueryVariables, GraphqlGetIntegrationConnectionQuery, GraphqlGetIntegrationConnectionQueryVariables, GraphqlGetIntegrationConnectionsQuery, GraphqlPingIntegrationConnectionMutation, GraphqlPingIntegrationConnectionMutationVariables } from "./graphql/__generated__/operationTypes";
1
+ import type { GraphqlCreateIntegrationConnectionInput, GraphqlCreateIntegrationConnectionMutation, GraphqlGetIntegrationConnectionQuery, GraphqlGetIntegrationConnectionQueryVariables, GraphqlGetIntegrationConnectionsQuery, GraphqlPingIntegrationConnectionMutation, GraphqlPingIntegrationConnectionMutationVariables } from "./graphql/__generated__/operationTypes";
2
2
  import QbdIntegration from "./integrations/qbd/QbdIntegration";
3
3
  import { getServerUrlForEnvironment } from "./utils";
4
4
  export interface ClientOptions {
@@ -25,25 +25,6 @@ export default class Client {
25
25
  * @returns The integration-connections.
26
26
  */
27
27
  getIntegrationConnections(): Promise<GraphqlGetIntegrationConnectionsQuery["integrationConnections"]>;
28
- /**
29
- * Checks whether we can successfully connect to the end-user's QBD instance.
30
- *
31
- * Unlike `lastHeartbeatAt`, which only checks if QBWC is running (i.e., is
32
- * the user's computer on), this check fails if the user's computer is on but
33
- * QBD is not running, the wrong company file is open, or there is a modal
34
- * dialog open in QBD.
35
- *
36
- * @param integrationConnectionId The ID of the integration-connection.
37
- * @returns The result object with the following properties:
38
- * - isConnected: Whether we can connect to the end-user's QBD.
39
- * - error: If `isConnected=false`, this will be an object with the following
40
- * properties:
41
- * - error.code - The unique error code.
42
- * - error.developerMessage - The technical error message for the developer.
43
- * - error.endUserMessage - The user-friendly error message to display to
44
- * the the end-user.
45
- */
46
- getConnectionStatus(integrationConnectionId: GraphqlGetConnectionStatusQueryVariables["integrationConnectionId"]): Promise<GraphqlGetConnectionStatusQuery["integrationConnection"]["connectionStatus"]>;
47
28
  /**
48
29
  * Creates a new integration-connection.
49
30
  *
@@ -41,29 +41,6 @@ class Client {
41
41
  .getIntegrationConnections()
42
42
  .then((result) => result.integrationConnections);
43
43
  }
44
- /**
45
- * Checks whether we can successfully connect to the end-user's QBD instance.
46
- *
47
- * Unlike `lastHeartbeatAt`, which only checks if QBWC is running (i.e., is
48
- * the user's computer on), this check fails if the user's computer is on but
49
- * QBD is not running, the wrong company file is open, or there is a modal
50
- * dialog open in QBD.
51
- *
52
- * @param integrationConnectionId The ID of the integration-connection.
53
- * @returns The result object with the following properties:
54
- * - isConnected: Whether we can connect to the end-user's QBD.
55
- * - error: If `isConnected=false`, this will be an object with the following
56
- * properties:
57
- * - error.code - The unique error code.
58
- * - error.developerMessage - The technical error message for the developer.
59
- * - error.endUserMessage - The user-friendly error message to display to
60
- * the the end-user.
61
- */
62
- async getConnectionStatus(integrationConnectionId) {
63
- return this.graphqlOperations
64
- .getConnectionStatus({ integrationConnectionId })
65
- .then((result) => result.integrationConnection.connectionStatus);
66
- }
67
44
  /**
68
45
  * Creates a new integration-connection.
69
46
  *
@@ -45,8 +45,8 @@ export declare class ConductorError extends Error {
45
45
  * This value exists for *every* error. E.g., if it's a QBD connection error,
46
46
  * it might recommend the end-user to check that their QuickBooks Desktop is
47
47
  * open and that they're logged in. But if a Conductor API key is expired,
48
- * this message will just say "An internal server error occurred. Please try
49
- * again later.".
48
+ * e.g., this message will just say "An internal server error occurred. Please
49
+ * try again later.".
50
50
  */
51
51
  readonly endUserMessage: string;
52
52
  /**
@@ -57,7 +57,7 @@ export declare class ConductorError extends Error {
57
57
  *
58
58
  * E.g., QuickBooks Desktop might return an error with `integrationCode` for
59
59
  * something specific to its accounting logic. The integration's corresponding
60
- * message for this code would be in `error.message`.
60
+ * error message for this code is in `error.message`.
61
61
  *
62
62
  * The third-party integration's error codes are not standardized, so you
63
63
  * should not rely on this code to be the same across integrations.
@@ -76,9 +76,12 @@ export declare class ConductorError extends Error {
76
76
  }
77
77
  type ConductorErrorOptionsWithoutType = Omit<ConductorErrorOptions, "type">;
78
78
  /**
79
- * Raised when an error occurs on the third-party integration's end while
80
- * processing your end-user's request. E.g., cannot connect to QuickBooks
81
- * Desktop on the end-user's computer.
79
+ * Raised when the third-party integration returned an error while processing
80
+ * your end-user's request. E.g., cannot connect to QuickBooks Desktop on the
81
+ * end-user's computer.
82
+ *
83
+ * See `error.integrationCode` for the error code that the third-party
84
+ * integration returned.
82
85
  */
83
86
  export declare class ConductorIntegrationError extends ConductorError {
84
87
  static readonly rawType: string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateConductorErrorFromType = exports.ConductorUnknownError = exports.ConductorInternalError = exports.ConductorConnectionError = exports.ConductorAuthenticationError = exports.ConductorInvalidRequestError = exports.ConductorIntegrationError = exports.ConductorError = exports.DEFAULT_END_USER_MESSAGE = void 0;
4
4
  /* eslint-disable max-classes-per-file -- Use one module for all error classes. */
5
+ // Matches server-side default value.
5
6
  exports.DEFAULT_END_USER_MESSAGE = "An internal server error occurred. Please try again later.";
6
7
  /**
7
8
  * The base error from which all other more specific Conductor errors derive.
@@ -34,8 +35,8 @@ class ConductorError extends Error {
34
35
  * This value exists for *every* error. E.g., if it's a QBD connection error,
35
36
  * it might recommend the end-user to check that their QuickBooks Desktop is
36
37
  * open and that they're logged in. But if a Conductor API key is expired,
37
- * this message will just say "An internal server error occurred. Please try
38
- * again later.".
38
+ * e.g., this message will just say "An internal server error occurred. Please
39
+ * try again later.".
39
40
  */
40
41
  endUserMessage;
41
42
  /**
@@ -46,7 +47,7 @@ class ConductorError extends Error {
46
47
  *
47
48
  * E.g., QuickBooks Desktop might return an error with `integrationCode` for
48
49
  * something specific to its accounting logic. The integration's corresponding
49
- * message for this code would be in `error.message`.
50
+ * error message for this code is in `error.message`.
50
51
  *
51
52
  * The third-party integration's error codes are not standardized, so you
52
53
  * should not rely on this code to be the same across integrations.
@@ -83,9 +84,12 @@ class ConductorError extends Error {
83
84
  }
84
85
  exports.ConductorError = ConductorError;
85
86
  /**
86
- * Raised when an error occurs on the third-party integration's end while
87
- * processing your end-user's request. E.g., cannot connect to QuickBooks
88
- * Desktop on the end-user's computer.
87
+ * Raised when the third-party integration returned an error while processing
88
+ * your end-user's request. E.g., cannot connect to QuickBooks Desktop on the
89
+ * end-user's computer.
90
+ *
91
+ * See `error.integrationCode` for the error code that the third-party
92
+ * integration returned.
89
93
  */
90
94
  class ConductorIntegrationError extends ConductorError {
91
95
  static rawType = "INTEGRATION_ERROR";
@@ -47,11 +47,6 @@ export type GraphqlIntegrationConnectionFragment = {
47
47
  endUserCompanyName: string;
48
48
  lastHeartbeatAt: Date | null;
49
49
  };
50
- export type GraphqlUserErrorFragment = {
51
- code: string;
52
- developerMessage: string;
53
- endUserMessage: string;
54
- };
55
50
  export type GraphqlGetIntegrationConnectionQueryVariables = Exact<{
56
51
  integrationConnectionId: Scalars["ID"];
57
52
  }>;
@@ -78,21 +73,6 @@ export type GraphqlGetIntegrationConnectionsQuery = {
78
73
  lastHeartbeatAt: Date | null;
79
74
  }>;
80
75
  };
81
- export type GraphqlGetConnectionStatusQueryVariables = Exact<{
82
- integrationConnectionId: Scalars["ID"];
83
- }>;
84
- export type GraphqlGetConnectionStatusQuery = {
85
- integrationConnection: {
86
- connectionStatus: {
87
- isConnected: boolean;
88
- error: {
89
- code: string;
90
- developerMessage: string;
91
- endUserMessage: string;
92
- } | null;
93
- };
94
- };
95
- };
96
76
  export type GraphqlCreateIntegrationConnectionMutationVariables = Exact<{
97
77
  input: GraphqlCreateIntegrationConnectionInput;
98
78
  }>;
@@ -125,10 +105,8 @@ export type GraphqlSendIntegrationRequestMutation = {
125
105
  };
126
106
  };
127
107
  export declare const IntegrationConnectionFragmentDoc = "\n fragment IntegrationConnection on IntegrationConnection {\n id\n integrationKey\n endUserSourceId\n endUserEmail\n endUserCompanyName\n lastHeartbeatAt\n}\n ";
128
- export declare const UserErrorFragmentDoc = "\n fragment UserError on UserError {\n code\n developerMessage\n endUserMessage\n}\n ";
129
108
  export declare const GetIntegrationConnectionDocument: string;
130
109
  export declare const GetIntegrationConnectionsDocument: string;
131
- export declare const GetConnectionStatusDocument: string;
132
110
  export declare const CreateIntegrationConnectionDocument: string;
133
111
  export declare const PingIntegrationConnectionDocument = "\n mutation pingIntegrationConnection($input: PingIntegrationConnectionInput!) {\n pingIntegrationConnection(input: $input) {\n duration\n }\n}\n ";
134
112
  export declare const SendIntegrationRequestDocument = "\n mutation sendIntegrationRequest($input: SendIntegrationRequestInput!) {\n sendIntegrationRequest(input: $input) {\n response\n }\n}\n ";
@@ -136,7 +114,6 @@ export type SdkFunctionWrapper = <T>(action: (requestHeaders?: Record<string, st
136
114
  export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper): {
137
115
  getIntegrationConnection(variables: GraphqlGetIntegrationConnectionQueryVariables, requestHeaders?: (Record<string, string> | Dom.Headers | string[][]) | undefined): Promise<GraphqlGetIntegrationConnectionQuery>;
138
116
  getIntegrationConnections(variables?: GraphqlGetIntegrationConnectionsQueryVariables, requestHeaders?: (Record<string, string> | Dom.Headers | string[][]) | undefined): Promise<GraphqlGetIntegrationConnectionsQuery>;
139
- getConnectionStatus(variables: GraphqlGetConnectionStatusQueryVariables, requestHeaders?: (Record<string, string> | Dom.Headers | string[][]) | undefined): Promise<GraphqlGetConnectionStatusQuery>;
140
117
  createIntegrationConnection(variables: GraphqlCreateIntegrationConnectionMutationVariables, requestHeaders?: (Record<string, string> | Dom.Headers | string[][]) | undefined): Promise<GraphqlCreateIntegrationConnectionMutation>;
141
118
  pingIntegrationConnection(variables: GraphqlPingIntegrationConnectionMutationVariables, requestHeaders?: (Record<string, string> | Dom.Headers | string[][]) | undefined): Promise<GraphqlPingIntegrationConnectionMutation>;
142
119
  sendIntegrationRequest(variables: GraphqlSendIntegrationRequestMutationVariables, requestHeaders?: (Record<string, string> | Dom.Headers | string[][]) | undefined): Promise<GraphqlSendIntegrationRequestMutation>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSdk = exports.SendIntegrationRequestDocument = exports.PingIntegrationConnectionDocument = exports.CreateIntegrationConnectionDocument = exports.GetConnectionStatusDocument = exports.GetIntegrationConnectionsDocument = exports.GetIntegrationConnectionDocument = exports.UserErrorFragmentDoc = exports.IntegrationConnectionFragmentDoc = void 0;
3
+ exports.getSdk = exports.SendIntegrationRequestDocument = exports.PingIntegrationConnectionDocument = exports.CreateIntegrationConnectionDocument = exports.GetIntegrationConnectionsDocument = exports.GetIntegrationConnectionDocument = exports.IntegrationConnectionFragmentDoc = void 0;
4
4
  exports.IntegrationConnectionFragmentDoc = `
5
5
  fragment IntegrationConnection on IntegrationConnection {
6
6
  id
@@ -11,13 +11,6 @@ exports.IntegrationConnectionFragmentDoc = `
11
11
  lastHeartbeatAt
12
12
  }
13
13
  `;
14
- exports.UserErrorFragmentDoc = `
15
- fragment UserError on UserError {
16
- code
17
- developerMessage
18
- endUserMessage
19
- }
20
- `;
21
14
  exports.GetIntegrationConnectionDocument = `
22
15
  query getIntegrationConnection($integrationConnectionId: ID!) {
23
16
  integrationConnection(id: $integrationConnectionId) {
@@ -32,18 +25,6 @@ exports.GetIntegrationConnectionsDocument = `
32
25
  }
33
26
  }
34
27
  ${exports.IntegrationConnectionFragmentDoc}`;
35
- exports.GetConnectionStatusDocument = `
36
- query getConnectionStatus($integrationConnectionId: ID!) {
37
- integrationConnection(id: $integrationConnectionId) {
38
- connectionStatus {
39
- isConnected
40
- error {
41
- ...UserError
42
- }
43
- }
44
- }
45
- }
46
- ${exports.UserErrorFragmentDoc}`;
47
28
  exports.CreateIntegrationConnectionDocument = `
48
29
  mutation createIntegrationConnection($input: CreateIntegrationConnectionInput!) {
49
30
  createIntegrationConnection(input: $input) {
@@ -76,9 +57,6 @@ function getSdk(client, withWrapper = defaultWrapper) {
76
57
  getIntegrationConnections(variables, requestHeaders) {
77
58
  return withWrapper((wrappedRequestHeaders) => client.request(exports.GetIntegrationConnectionsDocument, variables, { ...requestHeaders, ...wrappedRequestHeaders }), "getIntegrationConnections", "query");
78
59
  },
79
- getConnectionStatus(variables, requestHeaders) {
80
- return withWrapper((wrappedRequestHeaders) => client.request(exports.GetConnectionStatusDocument, variables, { ...requestHeaders, ...wrappedRequestHeaders }), "getConnectionStatus", "query");
81
- },
82
60
  createIntegrationConnection(variables, requestHeaders) {
83
61
  return withWrapper((wrappedRequestHeaders) => client.request(exports.CreateIntegrationConnectionDocument, variables, { ...requestHeaders, ...wrappedRequestHeaders }), "createIntegrationConnection", "mutation");
84
62
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conductor-node",
3
- "version": "8.6.5",
3
+ "version": "9.0.0",
4
4
  "description": "Easily integrate with the entire QuickBooks Desktop API with fully-typed async TypeScript",
5
5
  "author": "Danny Nemer <hi@DannyNemer.com>",
6
6
  "license": "MIT",
@@ -16,8 +16,11 @@
16
16
  "delete-compiled-tests": "rm -rf `find ./dist -type d -name __tests__` ./dist/src/utils/testing.*",
17
17
  "postpack": "rm -rf dist",
18
18
  "clean": "rm -rf dist package conductor-node-*.tgz tsconfig.tsbuildinfo",
19
- "gen:graphql": "yarn graphql-codegen --config ./src/graphql/codegenConfig.ts",
20
- "diff": "yarn pack && npm diff --diff=conductor-node@latest --diff=conductor-node-v$(node -p \"require('./package.json').version\").tgz && yarn clean"
19
+ "gen:graphql": "yarn graphql-codegen --config=./src/graphql/codegenConfig.ts",
20
+ "diff": "yarn pack && npm diff --diff=conductor-node@latest --diff=conductor-node-v$(node -p \"require('./package.json').version\").tgz && yarn clean",
21
+ "prepublishOnly": "yarn test",
22
+ "test": "yarn --cwd=../.. test ./packages/client",
23
+ "jest": "yarn --cwd=../../ jest"
21
24
  },
22
25
  "engines": {
23
26
  "node": ">=16"