@dma-sdk/hubspot 1.0.16 → 1.0.18

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.
@@ -1,3 +1,4 @@
1
1
  export declare const HsSubscriptionTypes: {
2
2
  ticketPropChange: string;
3
+ dealCreation: string;
3
4
  };
@@ -5,4 +5,5 @@ const events_1 = require("./events");
5
5
  const objects_1 = require("./objects");
6
6
  exports.HsSubscriptionTypes = {
7
7
  ticketPropChange: `${objects_1.HsObjectTypes.ticket}.${events_1.HsEventTypes.propertyChange}`,
8
+ dealCreation: `${objects_1.HsObjectTypes.deal}.${events_1.HsEventTypes.creation}`,
8
9
  };
package/dist/index.d.ts CHANGED
@@ -6,5 +6,6 @@ export * from './constants/subscriptions';
6
6
  export * from './interfaces/input/subscriptions';
7
7
  export * from './interfaces/output/subscriptions';
8
8
  export * from './types/auth/hs-signature-data';
9
+ export * from './types/subscription/event';
9
10
  export * from './exceptions/conversion-error';
10
11
  export * from './utils/auth';
package/dist/index.js CHANGED
@@ -22,5 +22,6 @@ __exportStar(require("./constants/subscriptions"), exports);
22
22
  __exportStar(require("./interfaces/input/subscriptions"), exports);
23
23
  __exportStar(require("./interfaces/output/subscriptions"), exports);
24
24
  __exportStar(require("./types/auth/hs-signature-data"), exports);
25
+ __exportStar(require("./types/subscription/event"), exports);
25
26
  __exportStar(require("./exceptions/conversion-error"), exports);
26
27
  __exportStar(require("./utils/auth"), exports);
@@ -68,9 +68,19 @@ export declare class HubspotService {
68
68
  createObject(objectType: string, properties: SimplePublicObjectInputForCreate, accessToken: string): Promise<SimplePublicObject | {
69
69
  id: string;
70
70
  }>;
71
- getObject(objectType: string, objectId: string, accessToken: string): Promise<SimplePublicObject>;
72
- getObjectProps(objectType: string, objectId: string, props: string[], // nome delle props da restituire
73
- accessToken: string): Promise<SimplePublicObject>;
71
+ getObjectById(params: {
72
+ objectType: string;
73
+ objectId: string;
74
+ accessToken: string;
75
+ }): Promise<SimplePublicObject>;
76
+ getObject(params: {
77
+ objectType: string;
78
+ objectId: string;
79
+ associations?: string[];
80
+ props?: string[];
81
+ propsWithHistory?: string[];
82
+ accessToken: string;
83
+ }): Promise<SimplePublicObject>;
74
84
  getObjectWithPropsType(objectType: string, objectId: string, accessToken: string, types?: string[]): Promise<SimplePublicObject & {
75
85
  propertiesWithTypes: {
76
86
  [key: string]: {
@@ -82,19 +82,25 @@ class HubspotService {
82
82
  const response = await this.client.crm.objects.basicApi.create(objectType, properties);
83
83
  return response;
84
84
  }
85
- async getObject(objectType, objectId, accessToken) {
85
+ async getObjectById(params) {
86
+ const { objectType, objectId, accessToken } = params;
86
87
  this.client.setAccessToken(accessToken);
87
88
  return await this.client.crm.objects.basicApi.getById(objectType, objectId);
88
89
  }
89
- async getObjectProps(objectType, objectId, props, // nome delle props da restituire
90
- accessToken) {
90
+ async getObject(params) {
91
+ const { objectType, objectId, associations, props, propsWithHistory, accessToken } = params;
91
92
  this.client.setAccessToken(accessToken);
92
- return await this.client.crm.objects.basicApi.getById(objectType, objectId, props);
93
+ return await this.client.crm.objects.basicApi.getById(objectType, objectId, props, propsWithHistory, associations);
93
94
  }
94
95
  async getObjectWithPropsType(objectType, objectId, accessToken, types) {
95
96
  this.client.setAccessToken(accessToken);
96
97
  const props = await this.listObjectProperties({ objectType, types });
97
- const data = await this.getObjectProps(objectType, objectId, props.results.map((prop) => prop.name), accessToken);
98
+ const data = await this.getObject({
99
+ objectType,
100
+ objectId,
101
+ props: props.results.map((prop) => prop.name),
102
+ accessToken
103
+ });
98
104
  let formattedProp = {};
99
105
  props.results.forEach((property) => {
100
106
  if (!data.properties[property.name]) {
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ export declare const subscriptionEventSchema: z.ZodObject<{
3
+ eventId: z.ZodNumber;
4
+ subscriptionId: z.ZodOptional<z.ZodNumber>;
5
+ portalId: z.ZodOptional<z.ZodNumber>;
6
+ appId: z.ZodNumber;
7
+ occurredAt: z.ZodOptional<z.ZodNumber>;
8
+ subscriptionType: z.ZodString;
9
+ attemptNumber: z.ZodOptional<z.ZodNumber>;
10
+ objectId: z.ZodNumber;
11
+ propertyName: z.ZodOptional<z.ZodString>;
12
+ propertyValue: z.ZodOptional<z.ZodString>;
13
+ changeSource: z.ZodOptional<z.ZodString>;
14
+ changeFlag: z.ZodOptional<z.ZodString>;
15
+ sourceId: z.ZodOptional<z.ZodString>;
16
+ }, z.core.$strip>;
17
+ export declare const subscriptionEventListSchema: z.ZodArray<z.ZodObject<{
18
+ eventId: z.ZodNumber;
19
+ subscriptionId: z.ZodOptional<z.ZodNumber>;
20
+ portalId: z.ZodOptional<z.ZodNumber>;
21
+ appId: z.ZodNumber;
22
+ occurredAt: z.ZodOptional<z.ZodNumber>;
23
+ subscriptionType: z.ZodString;
24
+ attemptNumber: z.ZodOptional<z.ZodNumber>;
25
+ objectId: z.ZodNumber;
26
+ propertyName: z.ZodOptional<z.ZodString>;
27
+ propertyValue: z.ZodOptional<z.ZodString>;
28
+ changeSource: z.ZodOptional<z.ZodString>;
29
+ changeFlag: z.ZodOptional<z.ZodString>;
30
+ sourceId: z.ZodOptional<z.ZodString>;
31
+ }, z.core.$strip>>;
32
+ export type SubscriptionEvent = z.infer<typeof subscriptionEventSchema>;
33
+ export type SubscriptionEventList = z.infer<typeof subscriptionEventListSchema>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.subscriptionEventListSchema = exports.subscriptionEventSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.subscriptionEventSchema = zod_1.z.object({
6
+ eventId: zod_1.z.number(),
7
+ subscriptionId: zod_1.z.number().optional(),
8
+ portalId: zod_1.z.number().optional(),
9
+ appId: zod_1.z.number(),
10
+ occurredAt: zod_1.z.number().optional(),
11
+ subscriptionType: zod_1.z.string(),
12
+ attemptNumber: zod_1.z.number().optional(),
13
+ objectId: zod_1.z.number(),
14
+ propertyName: zod_1.z.string().optional(),
15
+ propertyValue: zod_1.z.string().optional(),
16
+ changeSource: zod_1.z.string().optional(),
17
+ changeFlag: zod_1.z.string().optional(),
18
+ sourceId: zod_1.z.string().optional(),
19
+ });
20
+ exports.subscriptionEventListSchema = zod_1.z.array(exports.subscriptionEventSchema);
@@ -3,4 +3,5 @@ import { HsObjectTypes } from "./objects";
3
3
 
4
4
  export const HsSubscriptionTypes = {
5
5
  ticketPropChange: `${HsObjectTypes.ticket}.${HsEventTypes.propertyChange}`,
6
+ dealCreation: `${HsObjectTypes.deal}.${HsEventTypes.creation}`,
6
7
  };
package/lib/index.ts CHANGED
@@ -6,5 +6,6 @@ export * from './constants/subscriptions';
6
6
  export * from './interfaces/input/subscriptions';
7
7
  export * from './interfaces/output/subscriptions';
8
8
  export * from './types/auth/hs-signature-data';
9
+ export * from './types/subscription/event';
9
10
  export * from './exceptions/conversion-error';
10
11
  export * from './utils/auth';
@@ -147,11 +147,12 @@ export class HubspotService {
147
147
  return response
148
148
  }
149
149
 
150
- async getObject(
150
+ async getObjectById(params: {
151
151
  objectType: string,
152
- objectId: string,
152
+ objectId: string,
153
153
  accessToken: string
154
- ): Promise<SimplePublicObject> {
154
+ }): Promise<SimplePublicObject> {
155
+ const { objectType, objectId, accessToken } = params
155
156
  this.client.setAccessToken(accessToken)
156
157
  return await this.client.crm.objects.basicApi.getById(
157
158
  objectType,
@@ -159,17 +160,22 @@ export class HubspotService {
159
160
  );
160
161
  }
161
162
 
162
- async getObjectProps(
163
+ async getObject(params: {
163
164
  objectType: string,
164
165
  objectId: string,
165
- props: string[], // nome delle props da restituire
166
+ associations?: string[],
167
+ props?: string[], // nome delle props da restituire
168
+ propsWithHistory?: string[], // nome delle props da restituire
166
169
  accessToken: string
167
- ): Promise<SimplePublicObject> {
170
+ }): Promise<SimplePublicObject> {
171
+ const { objectType, objectId, associations, props, propsWithHistory, accessToken } = params
168
172
  this.client.setAccessToken(accessToken)
169
173
  return await this.client.crm.objects.basicApi.getById(
170
174
  objectType,
171
175
  objectId,
172
- props
176
+ props,
177
+ propsWithHistory,
178
+ associations
173
179
  );
174
180
  }
175
181
 
@@ -181,12 +187,12 @@ export class HubspotService {
181
187
  ): Promise<SimplePublicObject & { propertiesWithTypes: { [key: string]: { type: string, label: string, value: string | null } }}> {
182
188
  this.client.setAccessToken(accessToken)
183
189
  const props = await this.listObjectProperties({ objectType, types })
184
- const data = await this.getObjectProps(
190
+ const data = await this.getObject({
185
191
  objectType,
186
192
  objectId,
187
- props.results.map((prop) => prop.name),
193
+ props: props.results.map((prop) => prop.name),
188
194
  accessToken
189
- );
195
+ });
190
196
 
191
197
 
192
198
  let formattedProp: { [key: string]: { type: string, label: string, value: string | null } } = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dma-sdk/hubspot",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "DMA SDK – Hubspot service",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",