@segment/action-destinations 3.323.1-hadron.0 → 3.324.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/destinations/hubspot/customEvent/client.d.ts +2 -2
- package/dist/destinations/hubspot/customEvent/client.js.map +1 -1
- package/dist/destinations/hubspot/customEvent/dynamic-fields.js +2 -2
- package/dist/destinations/hubspot/customEvent/dynamic-fields.js.map +1 -1
- package/dist/destinations/hubspot/customEvent/index.js +42 -36
- package/dist/destinations/hubspot/customEvent/index.js.map +1 -1
- package/dist/destinations/hubspot/customEvent/types.d.ts +4 -11
- package/dist/destinations/hubspot/customEvent/types.js +2 -1
- package/dist/destinations/hubspot/customEvent/types.js.map +1 -1
- package/dist/destinations/hubspot/customEvent/utils.d.ts +8 -10
- package/dist/destinations/hubspot/customEvent/utils.js +189 -155
- package/dist/destinations/hubspot/customEvent/utils.js.map +1 -1
- package/package.json +4 -5
- package/dist/destinations/braze/createAliasV2.types.d.ts +0 -5
- package/dist/destinations/braze/createAliasV2.types.js +0 -3
- package/dist/destinations/braze/createAliasV2.types.js.map +0 -1
- package/dist/destinations/braze/identifyUserV2.types.d.ts +0 -8
- package/dist/destinations/braze/identifyUserV2.types.js +0 -3
- package/dist/destinations/braze/identifyUserV2.types.js.map +0 -1
- package/dist/destinations/braze/trackEvent2/generated-types.d.ts +0 -16
- package/dist/destinations/braze/trackEvent2/generated-types.js +0 -3
- package/dist/destinations/braze/trackEvent2/generated-types.js.map +0 -1
- package/dist/destinations/braze/trackEvent2/index.d.ts +0 -5
- package/dist/destinations/braze/trackEvent2/index.js +0 -117
- package/dist/destinations/braze/trackEvent2/index.js.map +0 -1
- package/dist/destinations/braze/trackPurchase2/generated-types.d.ts +0 -22
- package/dist/destinations/braze/trackPurchase2/generated-types.js +0 -3
- package/dist/destinations/braze/trackPurchase2/generated-types.js.map +0 -1
- package/dist/destinations/braze/trackPurchase2/index.d.ts +0 -5
- package/dist/destinations/braze/trackPurchase2/index.js +0 -135
- package/dist/destinations/braze/trackPurchase2/index.js.map +0 -1
- package/dist/destinations/campaign-manager-360/common-fields.d.ts +0 -3
- package/dist/destinations/campaign-manager-360/common-fields.js +0 -306
- package/dist/destinations/campaign-manager-360/common-fields.js.map +0 -1
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/generated-types.d.ts +0 -45
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/generated-types.js +0 -3
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/generated-types.js.map +0 -1
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/index.d.ts +0 -5
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/index.js +0 -86
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/index.js.map +0 -1
- package/dist/destinations/campaign-manager-360/conversionUpload/generated-types.d.ts +0 -50
- package/dist/destinations/campaign-manager-360/conversionUpload/generated-types.js +0 -3
- package/dist/destinations/campaign-manager-360/conversionUpload/generated-types.js.map +0 -1
- package/dist/destinations/campaign-manager-360/conversionUpload/index.d.ts +0 -5
- package/dist/destinations/campaign-manager-360/conversionUpload/index.js +0 -131
- package/dist/destinations/campaign-manager-360/conversionUpload/index.js.map +0 -1
- package/dist/destinations/campaign-manager-360/generated-types.d.ts +0 -5
- package/dist/destinations/campaign-manager-360/generated-types.js +0 -3
- package/dist/destinations/campaign-manager-360/generated-types.js.map +0 -1
- package/dist/destinations/campaign-manager-360/index.d.ts +0 -4
- package/dist/destinations/campaign-manager-360/index.js +0 -63
- package/dist/destinations/campaign-manager-360/index.js.map +0 -1
- package/dist/destinations/campaign-manager-360/types.d.ts +0 -116
- package/dist/destinations/campaign-manager-360/types.js +0 -23
- package/dist/destinations/campaign-manager-360/types.js.map +0 -1
- package/dist/destinations/campaign-manager-360/utils.d.ts +0 -21
- package/dist/destinations/campaign-manager-360/utils.js +0 -175
- package/dist/destinations/campaign-manager-360/utils.js.map +0 -1
- package/dist/destinations/first-party-dv360/addToAudContactInfo/generated-types.d.ts +0 -9
- package/dist/destinations/first-party-dv360/addToAudContactInfo/generated-types.js +0 -3
- package/dist/destinations/first-party-dv360/addToAudContactInfo/generated-types.js.map +0 -1
- package/dist/destinations/first-party-dv360/addToAudContactInfo/index.d.ts +0 -5
- package/dist/destinations/first-party-dv360/addToAudContactInfo/index.js +0 -32
- package/dist/destinations/first-party-dv360/addToAudContactInfo/index.js.map +0 -1
- package/dist/destinations/first-party-dv360/addToAudMobileDeviceId/generated-types.d.ts +0 -4
- package/dist/destinations/first-party-dv360/addToAudMobileDeviceId/generated-types.js +0 -3
- package/dist/destinations/first-party-dv360/addToAudMobileDeviceId/generated-types.js.map +0 -1
- package/dist/destinations/first-party-dv360/addToAudMobileDeviceId/index.d.ts +0 -5
- package/dist/destinations/first-party-dv360/addToAudMobileDeviceId/index.js +0 -27
- package/dist/destinations/first-party-dv360/addToAudMobileDeviceId/index.js.map +0 -1
- package/dist/destinations/first-party-dv360/addToList.types.d.ts +0 -9
- package/dist/destinations/first-party-dv360/addToList.types.js +0 -3
- package/dist/destinations/first-party-dv360/addToList.types.js.map +0 -1
- package/dist/destinations/first-party-dv360/properties.d.ts +0 -9
- package/dist/destinations/first-party-dv360/properties.js +0 -69
- package/dist/destinations/first-party-dv360/properties.js.map +0 -1
- package/dist/destinations/hubspot/customEvent/event-completion.d.ts +0 -3
- package/dist/destinations/hubspot/customEvent/event-completion.js +0 -17
- package/dist/destinations/hubspot/customEvent/event-completion.js.map +0 -1
- package/dist/destinations/hubspot/customEvent/validation.d.ts +0 -3
- package/dist/destinations/hubspot/customEvent/validation.js +0 -66
- package/dist/destinations/hubspot/customEvent/validation.js.map +0 -1
- package/dist/destinations/s3/syncAudienceToS3/generated-types.d.ts +0 -53
- package/dist/destinations/s3/syncAudienceToS3/generated-types.js +0 -3
- package/dist/destinations/s3/syncAudienceToS3/generated-types.js.map +0 -1
- package/dist/destinations/s3/syncAudienceToS3/index.d.ts +0 -5
- package/dist/destinations/s3/syncAudienceToS3/index.js +0 -22
- package/dist/destinations/s3/syncAudienceToS3/index.js.map +0 -1
- package/dist/destinations/s3/syncEventsToS3/generated-types.d.ts +0 -44
- package/dist/destinations/s3/syncEventsToS3/generated-types.js +0 -3
- package/dist/destinations/s3/syncEventsToS3/generated-types.js.map +0 -1
- package/dist/destinations/s3/syncEventsToS3/index.d.ts +0 -5
- package/dist/destinations/s3/syncEventsToS3/index.js +0 -19
- package/dist/destinations/s3/syncEventsToS3/index.js.map +0 -1
- package/dist/destinations/s3/syncToS3.types.d.ts +0 -44
- package/dist/destinations/s3/syncToS3.types.js +0 -3
- package/dist/destinations/s3/syncToS3.types.js.map +0 -1
- package/dist/destinations/webhook-extensible/types.d.ts +0 -6
- package/dist/destinations/webhook-extensible/types.js +0 -3
- package/dist/destinations/webhook-extensible/types.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RequestClient, ModifiedResponse } from '@segment/actions-core';
|
|
2
|
-
import { CreateEventDefinitionResp, CreateEventDefinitionReq, CreatePropDefinitionReq, GetEventDefinitionResp, EventCompletionReq
|
|
2
|
+
import { CreateEventDefinitionResp, CreateEventDefinitionReq, CreatePropDefinitionReq, GetEventDefinitionResp, EventCompletionReq } from './types';
|
|
3
3
|
export declare class Client {
|
|
4
4
|
request: RequestClient;
|
|
5
5
|
constructor(request: RequestClient);
|
|
6
6
|
getEventDefinition(eventName: string): Promise<ModifiedResponse<GetEventDefinitionResp>>;
|
|
7
7
|
send(json: EventCompletionReq): Promise<ModifiedResponse<unknown>>;
|
|
8
8
|
createEventDefinition(json: CreateEventDefinitionReq): Promise<ModifiedResponse<CreateEventDefinitionResp>>;
|
|
9
|
-
createPropertyDefinition(json: CreatePropDefinitionReq, eventName: string): Promise<ModifiedResponse<
|
|
9
|
+
createPropertyDefinition(json: CreatePropDefinitionReq, eventName: string): Promise<ModifiedResponse<unknown>>;
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/client.ts"],"names":[],"mappings":";;;AACA,8CAAgD;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/client.ts"],"names":[],"mappings":";;;AACA,8CAAgD;AAShD,MAAa,MAAM;IAGjB,YAAY,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,SAAiB;QAExC,OAAO,MAAM,IAAI,CAAC,OAAO,CACvB,GAAG,6BAAgB,gCAAgC,SAAS,0BAA0B,EACtF;YACE,MAAM,EAAE,KAAK;YACb,mBAAmB,EAAE,IAAI;YACzB,eAAe,EAAE,KAAK;SACvB,CACF,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAwB;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,6BAAgB,iBAAiB,EAAE;YACxD,MAAM,EAAE,MAAM;YACd,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,IAA8B;QACxD,OAAO,MAAM,IAAI,CAAC,OAAO,CAA4B,GAAG,6BAAgB,8BAA8B,EAAE;YACtG,MAAM,EAAE,MAAM;YACd,IAAI;YACJ,mBAAmB,EAAE,IAAI;YACzB,eAAe,EAAE,KAAK;SACvB,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,wBAAwB,CAAC,IAA6B,EAAE,SAAiB;QAC7E,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,6BAAgB,gCAAgC,SAAS,WAAW,EAAE;YAC3F,MAAM,EAAE,MAAM;YACd,IAAI;YACJ,eAAe,EAAE,KAAK;SACvB,CAAC,CAAA;IACJ,CAAC;CACF;AA1CD,wBA0CC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.dynamicReadProperties = exports.dynamicReadObjectTypes = exports.dynamicReadEventNames = void 0;
|
|
4
4
|
const properties_1 = require("../properties");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
|
-
const
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
7
|
async function dynamicReadEventNames(request) {
|
|
8
8
|
try {
|
|
9
9
|
const response = await request(`${properties_1.HUBSPOT_BASE_URL}/events/v3/event-definitions/?includeProperties=false`, {
|
|
@@ -67,7 +67,7 @@ async function dynamicReadProperties(request, eventName) {
|
|
|
67
67
|
method: 'GET',
|
|
68
68
|
skipResponseCloning: true
|
|
69
69
|
});
|
|
70
|
-
const cleanedEventName =
|
|
70
|
+
const cleanedEventName = utils_1.cleanEventName(eventName);
|
|
71
71
|
return {
|
|
72
72
|
choices: (() => {
|
|
73
73
|
const choices = response.data.results
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-fields.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/dynamic-fields.ts"],"names":[],"mappings":";;;AAEA,8CAAgD;AAChD,2CAA6F;AAC7F,
|
|
1
|
+
{"version":3,"file":"dynamic-fields.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/dynamic-fields.ts"],"names":[],"mappings":";;;AAEA,8CAAgD;AAChD,2CAA6F;AAC7F,mCAAwC;AAGjC,KAAK,UAAU,qBAAqB,CAAC,OAAsB;IAgBhE,IAAI;QACF,MAAM,QAAQ,GAAiB,MAAM,OAAO,CAC1C,GAAG,6BAAgB,uDAAuD,EAC1E;YACE,MAAM,EAAE,KAAK;YACb,mBAAmB,EAAE,IAAI;SAC1B,CACF,CAAA;QAED,OAAO;YACL,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO;iBAC3B,MAAM,CAAC,CAAC,KAAiB,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAA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FD,sDAgFC"}
|
|
@@ -6,8 +6,6 @@ const actions_core_1 = require("@segment/actions-core");
|
|
|
6
6
|
const dynamic_fields_1 = require("./dynamic-fields");
|
|
7
7
|
const types_1 = require("./types");
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
|
-
const event_completion_1 = require("./event-completion");
|
|
10
|
-
const validation_1 = require("./validation");
|
|
11
9
|
const action = {
|
|
12
10
|
title: 'Custom Event V2',
|
|
13
11
|
description: 'Send Custom Events to HubSpot',
|
|
@@ -43,48 +41,56 @@ const action = {
|
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
},
|
|
46
|
-
perform: async (request, { payload, syncMode
|
|
47
|
-
return await send(request, payload, syncMode
|
|
44
|
+
perform: async (request, { payload, syncMode }) => {
|
|
45
|
+
return await send(request, payload, syncMode);
|
|
48
46
|
}
|
|
49
47
|
};
|
|
50
|
-
const send = async (request, payload, syncMode
|
|
51
|
-
statsContext?.tags?.push('action:custom_event');
|
|
48
|
+
const send = async (request, payload, syncMode) => {
|
|
52
49
|
const client = new client_1.Client(request);
|
|
53
|
-
const validPayload =
|
|
50
|
+
const validPayload = utils_1.validate(payload);
|
|
54
51
|
const schema = utils_1.eventSchema(validPayload);
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
const cacheSchemaDiff = utils_1.compareSchemas(schema, cachedSchema);
|
|
58
|
-
statsContext?.statsClient?.incr(`cache.diff.${cacheSchemaDiff.match}`, 1, statsContext?.tags);
|
|
59
|
-
if (cacheSchemaDiff.match === types_1.SchemaMatch.FullMatch) {
|
|
60
|
-
return await event_completion_1.sendEvent(client, cachedSchema.fullyQualifiedName, validPayload);
|
|
61
|
-
}
|
|
62
|
-
const hubspotSchema = await utils_1.getSchemaFromHubspot(client, schema);
|
|
63
|
-
statsContext?.statsClient?.incr(`hubspotSchema.get.${hubspotSchema === undefined ? 'miss' : 'hit'}`, 1, statsContext?.tags);
|
|
64
|
-
const hubspotSchemaDiff = utils_1.compareSchemas(schema, hubspotSchema);
|
|
65
|
-
statsContext?.statsClient?.incr(`hubspotSchemaDiff.diff.${hubspotSchemaDiff.match}`, 1, statsContext?.tags);
|
|
66
|
-
switch (hubspotSchemaDiff.match) {
|
|
52
|
+
const cacheSchemaDiff = await utils_1.compareToCache(schema);
|
|
53
|
+
switch (cacheSchemaDiff.match) {
|
|
67
54
|
case types_1.SchemaMatch.FullMatch: {
|
|
68
|
-
await utils_1.
|
|
69
|
-
return await event_completion_1.sendEvent(client, hubspotSchema.fullyQualifiedName, validPayload);
|
|
55
|
+
return await utils_1.sendEvent(client, cacheSchemaDiff?.fullyQualifiedName, validPayload);
|
|
70
56
|
}
|
|
71
|
-
case types_1.SchemaMatch.
|
|
72
|
-
|
|
73
|
-
throw new actions_core_1.IntegrationError(`The 'Sync Mode' setting is set to 'add' which is stopping Segment from creating a new properties on the Event Schema in the HubSpot`, 'HUBSPOT_SCHEMA_PROPERTIES_MISSING', 400);
|
|
74
|
-
}
|
|
75
|
-
const cacheableSchema = { ...schema, fullyQualifiedName: hubspotSchema.fullyQualifiedName };
|
|
76
|
-
await utils_1.updateHubspotSchema(client, cacheableSchema.fullyQualifiedName, hubspotSchemaDiff);
|
|
77
|
-
await utils_1.saveSchemaToCache(cacheableSchema, subscriptionMetadata, statsContext);
|
|
78
|
-
return await event_completion_1.sendEvent(client, cacheableSchema.fullyQualifiedName, validPayload);
|
|
57
|
+
case types_1.SchemaMatch.Mismatch: {
|
|
58
|
+
throw new actions_core_1.IntegrationError('Cache schema mismatch.', 'CACHE_SCHEMA_MISMATCH', 400);
|
|
79
59
|
}
|
|
80
|
-
case types_1.SchemaMatch.NoMatch:
|
|
81
|
-
|
|
82
|
-
|
|
60
|
+
case types_1.SchemaMatch.NoMatch:
|
|
61
|
+
case types_1.SchemaMatch.PropertiesMissing: {
|
|
62
|
+
const hubspotSchemaDiff = await utils_1.compareToHubspot(client, schema);
|
|
63
|
+
switch (hubspotSchemaDiff.match) {
|
|
64
|
+
case types_1.SchemaMatch.FullMatch: {
|
|
65
|
+
const fullyQualifiedName = hubspotSchemaDiff?.fullyQualifiedName;
|
|
66
|
+
const name = hubspotSchemaDiff?.name;
|
|
67
|
+
await utils_1.saveSchemaToCache(fullyQualifiedName, name, schema);
|
|
68
|
+
return await utils_1.sendEvent(client, fullyQualifiedName, validPayload);
|
|
69
|
+
}
|
|
70
|
+
case types_1.SchemaMatch.Mismatch: {
|
|
71
|
+
throw new actions_core_1.IntegrationError('Hubspot schema mismatch.', 'HUBSPOT_SCHEMA_MISMATCH', 400);
|
|
72
|
+
}
|
|
73
|
+
case types_1.SchemaMatch.NoMatch: {
|
|
74
|
+
if (syncMode === 'update') {
|
|
75
|
+
throw new actions_core_1.IntegrationError(`The 'Sync Mode' setting is set to 'update' which is stopping Segment from creating a new Custom Event Schema in the HubSpot`, 'HUBSPOT_SCHEMA_MISSING', 400);
|
|
76
|
+
}
|
|
77
|
+
const schemaDiff = await utils_1.createHubspotEventSchema(client, schema);
|
|
78
|
+
const fullyQualifiedName = schemaDiff?.fullyQualifiedName;
|
|
79
|
+
const name = schemaDiff?.name;
|
|
80
|
+
await utils_1.saveSchemaToCache(fullyQualifiedName, name, schema);
|
|
81
|
+
return await utils_1.sendEvent(client, fullyQualifiedName, validPayload);
|
|
82
|
+
}
|
|
83
|
+
case types_1.SchemaMatch.PropertiesMissing: {
|
|
84
|
+
if (syncMode === 'add') {
|
|
85
|
+
throw new actions_core_1.IntegrationError(`The 'Sync Mode' setting is set to 'add' which is stopping Segment from creating a new properties on the Event Schema in the HubSpot`, 'HUBSPOT_SCHEMA_PROPERTIES_MISSING', 400);
|
|
86
|
+
}
|
|
87
|
+
const fullyQualifiedName = hubspotSchemaDiff?.fullyQualifiedName;
|
|
88
|
+
const name = hubspotSchemaDiff?.name;
|
|
89
|
+
await utils_1.updateHubspotSchema(client, fullyQualifiedName, hubspotSchemaDiff);
|
|
90
|
+
await utils_1.saveSchemaToCache(fullyQualifiedName, name, schema);
|
|
91
|
+
return await utils_1.sendEvent(client, fullyQualifiedName, validPayload);
|
|
92
|
+
}
|
|
83
93
|
}
|
|
84
|
-
const fullyQualifiedName = await utils_1.createHubspotEventSchema(client, schema);
|
|
85
|
-
const cacheableSchema = { ...schema, fullyQualifiedName };
|
|
86
|
-
await utils_1.saveSchemaToCache(cacheableSchema, subscriptionMetadata, statsContext);
|
|
87
|
-
return await event_completion_1.sendEvent(client, cacheableSchema.fullyQualifiedName, validPayload);
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/index.ts"],"names":[],"mappings":";;AAEA,mDAA8C;AAC9C,qCAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/index.ts"],"names":[],"mappings":";;AAEA,mDAA8C;AAC9C,qCAAiC;AACjC,wDAAyF;AACzF,qDAAuG;AACvG,mCAA+C;AAC/C,mCASgB;AAEhB,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,iBAAiB;IACxB,WAAW,EAAE,+BAA+B;IAC5C,QAAQ,EAAE;QACR,WAAW,EAAE,4DAA4D;QACzE,KAAK,EAAE,WAAW;QAClB,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,yDAAyD,EAAE,KAAK,EAAE,QAAQ,EAAE;YACrF,EAAE,KAAK,EAAE,iEAAiE,EAAE,KAAK,EAAE,KAAK,EAAE;YAC1F,EAAE,KAAK,EAAE,iEAAiE,EAAE,KAAK,EAAE,QAAQ,EAAE;SAC9F;KACF;IACD,MAAM,EAAE;QACN,GAAG,4BAAY;KAChB;IACD,aAAa,EAAE;QACb,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC5B,OAAO,MAAM,sCAAqB,CAAC,OAAO,CAAC,CAAA;QAC7C,CAAC;QACD,cAAc,EAAE;YACd,WA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BACtB,MAAM,IAAI,+BAAgB,CACxB,qIAAqI,EACrI,mCAAmC,EACnC,GAAG,CACJ,CAAA;qBACF;oBAED,MAAM,kBAAkB,GAAG,iBAAiB,EAAE,kBAA4B,CAAA;oBAC1E,MAAM,IAAI,GAAG,iBAAiB,EAAE,IAAc,CAAA;oBAC9C,MAAM,2BAAmB,CAAC,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,CAAC,CAAA;oBACxE,MAAM,yBAAiB,CAAC,kBAAkB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;oBACzD,OAAO,MAAM,iBAAS,CAAC,MAAM,EAAE,kBAAkB,EAAE,YAAY,CAAC,CAAA;iBACjE;aACF;SACF;KACF;AACH,CAAC,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -9,24 +9,24 @@ export declare const SchemaMatch: {
|
|
|
9
9
|
readonly FullMatch: "full_match";
|
|
10
10
|
readonly PropertiesMissing: "properties_missing";
|
|
11
11
|
readonly NoMatch: "no_match";
|
|
12
|
+
readonly Mismatch: "mismatch";
|
|
12
13
|
};
|
|
13
14
|
export declare type SchemaMatch = typeof SchemaMatch[keyof typeof SchemaMatch];
|
|
14
15
|
export interface SchemaDiff {
|
|
15
16
|
match: SchemaMatch;
|
|
17
|
+
fullyQualifiedName?: string;
|
|
18
|
+
name?: string;
|
|
16
19
|
missingProperties: {
|
|
17
20
|
[key: string]: SegmentProperty;
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
export interface Schema {
|
|
21
|
-
|
|
24
|
+
eventName: string;
|
|
22
25
|
properties: {
|
|
23
26
|
[key: string]: SegmentProperty;
|
|
24
27
|
};
|
|
25
28
|
primaryObject: string;
|
|
26
29
|
}
|
|
27
|
-
export interface CachableSchema extends Schema {
|
|
28
|
-
fullyQualifiedName: string;
|
|
29
|
-
}
|
|
30
30
|
export declare type HubspotPropertyType = 'string' | 'number' | 'enumeration' | 'datetime';
|
|
31
31
|
export interface GetEventDefinitionResp {
|
|
32
32
|
archived: boolean;
|
|
@@ -73,10 +73,3 @@ export interface EventCompletionReq {
|
|
|
73
73
|
[k: string]: unknown;
|
|
74
74
|
} | undefined;
|
|
75
75
|
}
|
|
76
|
-
export interface PropertyCreateResp {
|
|
77
|
-
status: number;
|
|
78
|
-
statusText: string;
|
|
79
|
-
data: {
|
|
80
|
-
message: string;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/types.ts"],"names":[],"mappings":";;;AAUa,QAAA,WAAW,GAAG;IACzB,SAAS,EAAE,YAAY;IACvB,iBAAiB,EAAE,oBAAoB;IACvC,OAAO,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/types.ts"],"names":[],"mappings":";;;AAUa,QAAA,WAAW,GAAG;IACzB,SAAS,EAAE,YAAY;IACvB,iBAAiB,EAAE,oBAAoB;IACvC,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;CACZ,CAAA"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { StatsContext } from '@segment/actions-core';
|
|
2
|
-
import { SubscriptionMetadata } from '@segment/actions-core/destination-kit';
|
|
3
1
|
import type { Payload } from './generated-types';
|
|
4
|
-
import { Schema,
|
|
2
|
+
import { Schema, SchemaDiff } from './types';
|
|
5
3
|
import { Client } from './client';
|
|
6
|
-
|
|
7
|
-
export declare
|
|
4
|
+
export declare function validate(payload: Payload): Payload;
|
|
5
|
+
export declare function cleanEventName(str: string): string;
|
|
8
6
|
export declare function eventSchema(payload: Payload): Schema;
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function createHubspotEventSchema(client: Client, schema: Schema): Promise<
|
|
7
|
+
export declare function compareToCache(_schema: Schema): Promise<SchemaDiff>;
|
|
8
|
+
export declare function compareToHubspot(client: Client, schema: Schema): Promise<SchemaDiff>;
|
|
9
|
+
export declare function saveSchemaToCache(_fullyQualifiedName: string, _name: string, _schema: Schema): Promise<void>;
|
|
10
|
+
export declare function sendEvent(client: Client, fullyQualifiedName: string, payload: Payload): Promise<import("@segment/actions-core/src").ModifiedResponse<unknown>>;
|
|
11
|
+
export declare function createHubspotEventSchema(client: Client, schema: Schema): Promise<SchemaDiff>;
|
|
14
12
|
export declare function updateHubspotSchema(client: Client, fullyQualifiedName: string, schemaDiff: SchemaDiff): Promise<void>;
|