@memberjunction/integration-connectors 5.8.0 → 5.10.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/dist/HubSpotConnector.d.ts +84 -29
- package/dist/HubSpotConnector.d.ts.map +1 -1
- package/dist/HubSpotConnector.js +413 -71
- package/dist/HubSpotConnector.js.map +1 -1
- package/dist/YourMembershipConnector.d.ts +106 -39
- package/dist/YourMembershipConnector.d.ts.map +1 -1
- package/dist/YourMembershipConnector.js +568 -362
- package/dist/YourMembershipConnector.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,41 +1,96 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
1
|
+
import { type UserInfo } from '@memberjunction/core';
|
|
2
|
+
import type { MJCompanyIntegrationEntity, MJIntegrationObjectEntity } from '@memberjunction/core-entities';
|
|
3
|
+
import { BaseRESTIntegrationConnector, type RESTAuthContext, type RESTResponse, type PaginationState, type PaginationType, type ConnectionTestResult, type DefaultFieldMapping, type DefaultIntegrationConfig } from '@memberjunction/integration-engine';
|
|
4
|
+
/** HubSpot property definition (from /crm/v3/properties/{objectType}) */
|
|
5
|
+
interface HubSpotPropertyDef {
|
|
6
|
+
name: string;
|
|
7
|
+
label: string;
|
|
8
|
+
type: string;
|
|
9
|
+
fieldType: string;
|
|
10
|
+
groupName: string;
|
|
11
|
+
description: string;
|
|
12
|
+
hasUniqueValue: boolean;
|
|
13
|
+
calculated: boolean;
|
|
14
|
+
externalOptions: boolean;
|
|
15
|
+
modificationMetadata?: {
|
|
16
|
+
readOnlyValue: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
3
19
|
/**
|
|
4
|
-
* Connector for HubSpot CRM
|
|
5
|
-
*
|
|
6
|
-
*
|
|
20
|
+
* Connector for HubSpot CRM via the HubSpot REST API v3.
|
|
21
|
+
*
|
|
22
|
+
* Extends BaseRESTIntegrationConnector to leverage metadata-driven object/field
|
|
23
|
+
* discovery from IntegrationEngineBase cache and generic pagination handling.
|
|
24
|
+
*
|
|
25
|
+
* Uses Bearer token authentication (private app key or OAuth access token).
|
|
26
|
+
* Supports cursor-based pagination and automatic response flattening.
|
|
27
|
+
*
|
|
28
|
+
* DATA SAFETY: This connector is READ-ONLY. It never writes data back to HubSpot.
|
|
7
29
|
*/
|
|
8
|
-
export declare class HubSpotConnector extends
|
|
30
|
+
export declare class HubSpotConnector extends BaseRESTIntegrationConnector {
|
|
31
|
+
/** Timestamp of the last API request, used for throttling */
|
|
32
|
+
private lastRequestTime;
|
|
33
|
+
protected Authenticate(companyIntegration: MJCompanyIntegrationEntity): Promise<RESTAuthContext>;
|
|
34
|
+
protected BuildHeaders(auth: RESTAuthContext): Record<string, string>;
|
|
35
|
+
protected MakeHTTPRequest(_auth: RESTAuthContext, url: string, method: string, headers: Record<string, string>, _body?: unknown): Promise<RESTResponse>;
|
|
36
|
+
protected NormalizeResponse(rawBody: unknown, responseDataKey: string | null): Record<string, unknown>[];
|
|
37
|
+
protected ExtractPaginationInfo(rawBody: unknown, _paginationType: PaginationType, _currentPage: number, _currentOffset: number, _pageSize: number): PaginationState;
|
|
38
|
+
protected GetBaseURL(_companyIntegration: MJCompanyIntegrationEntity): string;
|
|
9
39
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @returns Batch of HubSpot records with pagination info
|
|
40
|
+
* Overrides base pagination URL building to use HubSpot's parameter names.
|
|
41
|
+
* HubSpot uses `after` for cursor pagination (not `cursor`), and needs
|
|
42
|
+
* `limit` instead of `pageSize`. Also appends `properties` query param.
|
|
14
43
|
*/
|
|
15
|
-
|
|
44
|
+
protected BuildPaginatedURL(basePath: string, obj: MJIntegrationObjectEntity, _page: number, _offset: number, cursor?: string): string;
|
|
45
|
+
/** Tests connectivity by authenticating and fetching 1 contact. */
|
|
46
|
+
TestConnection(companyIntegration: MJCompanyIntegrationEntity, _contextUser: UserInfo): Promise<ConnectionTestResult>;
|
|
47
|
+
GetDefaultFieldMappings(objectName: string, _entityName: string): DefaultFieldMapping[];
|
|
48
|
+
GetDefaultConfiguration(): DefaultIntegrationConfig;
|
|
49
|
+
/** Converts a HubSpot property definition to ExternalFieldSchema format */
|
|
50
|
+
MapPropertyToField(prop: HubSpotPropertyDef): {
|
|
51
|
+
Name: string;
|
|
52
|
+
Label: string;
|
|
53
|
+
DataType: string;
|
|
54
|
+
IsRequired: boolean;
|
|
55
|
+
IsUniqueKey: boolean;
|
|
56
|
+
IsReadOnly: boolean;
|
|
57
|
+
};
|
|
58
|
+
/** Maps HubSpot type + fieldType to a simplified data type string */
|
|
59
|
+
MapHubSpotType(type: string, fieldType: string): string;
|
|
16
60
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param entityName - Target MJ entity name (e.g., "Contacts")
|
|
20
|
-
* @returns Array of default field mappings
|
|
61
|
+
* Reads credentials from CompanyIntegration.CredentialID -> Credential.Values JSON,
|
|
62
|
+
* or falls back to CompanyIntegration Configuration JSON for backwards compat.
|
|
21
63
|
*/
|
|
22
|
-
|
|
64
|
+
private LoadCredentials;
|
|
65
|
+
/** Loads credentials from a Credential entity by ID. */
|
|
66
|
+
private LoadFromCredentialEntity;
|
|
67
|
+
/** Parses a JSON string to extract HubSpot credentials. Returns null if no token found. */
|
|
68
|
+
private ParseCredentialJson;
|
|
69
|
+
/**
|
|
70
|
+
* Flattens a HubSpot CRM record from the nested format:
|
|
71
|
+
* { id, properties: { field1, field2 }, createdAt, updatedAt, archived }
|
|
72
|
+
* into a flat record with all properties at the top level,
|
|
73
|
+
* plus system fields (hs_object_id, createdAt, updatedAt, archived).
|
|
74
|
+
*/
|
|
75
|
+
private FlattenHubSpotRecord;
|
|
23
76
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @returns Column name for the primary key
|
|
77
|
+
* Extracts the HubSpot object name from an API path.
|
|
78
|
+
* E.g., "/crm/v3/objects/contacts" -> "contacts"
|
|
27
79
|
*/
|
|
28
|
-
private
|
|
80
|
+
private ExtractObjectNameFromPath;
|
|
29
81
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @param objectName - Table name
|
|
33
|
-
* @returns Column name for the deleted flag, or undefined if not applicable
|
|
82
|
+
* Builds the `properties` query parameter for a HubSpot object type.
|
|
83
|
+
* Returns empty string if no properties are configured for the object.
|
|
34
84
|
*/
|
|
35
|
-
private
|
|
36
|
-
/**
|
|
37
|
-
private
|
|
38
|
-
/**
|
|
39
|
-
private
|
|
85
|
+
private BuildPropertiesParam;
|
|
86
|
+
/** Executes an HTTP request with a timeout. */
|
|
87
|
+
private FetchWithTimeout;
|
|
88
|
+
/** Calculates retry delay from Retry-After header or exponential backoff. */
|
|
89
|
+
private CalculateRetryDelay;
|
|
90
|
+
/** Converts a fetch Response + parsed body into a RESTResponse. */
|
|
91
|
+
private BuildRESTResponse;
|
|
92
|
+
/** Returns a promise that resolves after the specified number of milliseconds. */
|
|
93
|
+
private Sleep;
|
|
40
94
|
}
|
|
95
|
+
export {};
|
|
41
96
|
//# sourceMappingURL=HubSpotConnector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HubSpotConnector.d.ts","sourceRoot":"","sources":["../src/HubSpotConnector.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,YAAY,EACjB,KAAK,
|
|
1
|
+
{"version":3,"file":"HubSpotConnector.d.ts","sourceRoot":"","sources":["../src/HubSpotConnector.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,0BAA0B,EAAsB,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/H,OAAO,EAEH,4BAA4B,EAC5B,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAChC,M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