@hs-x/hubspot 0.1.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/effect/cache.d.ts +4 -0
- package/dist/effect/cache.d.ts.map +1 -0
- package/dist/effect/cache.js +4 -0
- package/dist/effect/cache.js.map +1 -0
- package/dist/effect/client.d.ts +42 -0
- package/dist/effect/client.d.ts.map +1 -0
- package/dist/effect/client.js +51 -0
- package/dist/effect/client.js.map +1 -0
- package/dist/effect/index.d.ts +6 -0
- package/dist/effect/index.d.ts.map +1 -0
- package/dist/effect/index.js +6 -0
- package/dist/effect/index.js.map +1 -0
- package/dist/effect/requests.d.ts +76 -0
- package/dist/effect/requests.d.ts.map +1 -0
- package/dist/effect/requests.js +16 -0
- package/dist/effect/requests.js.map +1 -0
- package/dist/effect/resolvers.d.ts +7 -0
- package/dist/effect/resolvers.d.ts.map +1 -0
- package/dist/effect/resolvers.js +170 -0
- package/dist/effect/resolvers.js.map +1 -0
- package/dist/effect/service.d.ts +13 -0
- package/dist/effect/service.d.ts.map +1 -0
- package/dist/effect/service.js +36 -0
- package/dist/effect/service.js.map +1 -0
- package/dist/index.d.ts +135 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/project-upload.d.ts +72 -0
- package/dist/project-upload.d.ts.map +1 -0
- package/dist/project-upload.js +191 -0
- package/dist/project-upload.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/effect/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAW,MAAM,QAAQ,CAAC;AAEhD,eAAO,MAAM,wBAAwB,kCAEpC,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EACzC,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CACwD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Effect, Layer, Request } from 'effect';
|
|
2
|
+
export const HubSpotRequestCacheLayer = Layer.setRequestCache(Request.makeCache({ capacity: 2048, timeToLive: '5 minutes' }));
|
|
3
|
+
export const withHubSpotBatching = (effect) => effect.pipe(Effect.withRequestCaching(true), Effect.withRequestBatching(true));
|
|
4
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/effect/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEhD,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC,eAAe,CAC3D,OAAO,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAC/D,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,MAA8B,EACN,EAAE,CAC1B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { type AssociationTarget, type HubSpotObject } from './requests.js';
|
|
3
|
+
import { HubSpotApiService, type ManagedFetch } from './service.js';
|
|
4
|
+
import type { HubSpotPropertyDefinition } from '../index.js';
|
|
5
|
+
export interface BatchObjectReadInput {
|
|
6
|
+
readonly objectType: string;
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly idProperty?: string;
|
|
9
|
+
readonly properties?: readonly string[];
|
|
10
|
+
readonly propertiesWithHistory?: readonly string[];
|
|
11
|
+
readonly associations?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export interface BatchPropertyReadInput {
|
|
14
|
+
readonly objectType: string;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
}
|
|
17
|
+
export interface BatchAssociationsReadInput {
|
|
18
|
+
readonly fromObjectType: string;
|
|
19
|
+
readonly toObjectType: string;
|
|
20
|
+
readonly fromId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface BatchingHubSpotClient {
|
|
23
|
+
readonly objects: {
|
|
24
|
+
readonly read: (input: BatchObjectReadInput) => Promise<HubSpotObject>;
|
|
25
|
+
};
|
|
26
|
+
readonly properties: {
|
|
27
|
+
readonly read: (input: BatchPropertyReadInput) => Promise<HubSpotPropertyDefinition>;
|
|
28
|
+
};
|
|
29
|
+
readonly associations: {
|
|
30
|
+
readonly read: (input: BatchAssociationsReadInput) => Promise<readonly AssociationTarget[]>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Run a user-built Effect program under the same resolver + cache. Use this
|
|
34
|
+
* when the program issues many Requests in `Effect.forEach` — batching only
|
|
35
|
+
* fires when sibling Requests share a fiber tick.
|
|
36
|
+
*/
|
|
37
|
+
readonly run: <A, E>(effect: Effect.Effect<A, E, HubSpotApiService>) => Promise<A>;
|
|
38
|
+
}
|
|
39
|
+
export declare function createBatchingHubSpotClient(managedFetch: ManagedFetch, portalId: string, options?: {
|
|
40
|
+
readonly baseUrl?: string;
|
|
41
|
+
}): BatchingHubSpotClient;
|
|
42
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/effect/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA0B,MAAM,QAAQ,CAAC;AACxD,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAOvB,OAAO,EAAE,iBAAiB,EAAyB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,CAAC,CAAC,EAAE,CAAC,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,iBAAiB,CAAC,KAC3C,OAAO,CAAC,CAAC,CAAC,CAAC;CACjB;AAED,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1C,qBAAqB,CAiEvB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Effect, Layer, RequestResolver } from 'effect';
|
|
2
|
+
import { ReadAssociations, ReadCrmObject, ReadProperty, normalizeKeys, } from './requests.js';
|
|
3
|
+
import { ReadAssociationsResolver, ReadCrmObjectResolver, ReadPropertyResolver, } from './resolvers.js';
|
|
4
|
+
import { HubSpotRequestCacheLayer, withHubSpotBatching } from './cache.js';
|
|
5
|
+
import { HubSpotApiService, layerFromManagedFetch } from './service.js';
|
|
6
|
+
export function createBatchingHubSpotClient(managedFetch, portalId, options = {}) {
|
|
7
|
+
const apiLayer = options.baseUrl
|
|
8
|
+
? layerFromManagedFetch(managedFetch, options.baseUrl)
|
|
9
|
+
: layerFromManagedFetch(managedFetch);
|
|
10
|
+
const runtimeLayer = Layer.merge(apiLayer, HubSpotRequestCacheLayer);
|
|
11
|
+
const run = (effect) => Effect.runPromise(withHubSpotBatching(effect).pipe(Effect.provide(runtimeLayer)));
|
|
12
|
+
return {
|
|
13
|
+
objects: {
|
|
14
|
+
read: (input) => run(Effect.gen(function* () {
|
|
15
|
+
const resolver = yield* ReadCrmObjectResolver;
|
|
16
|
+
return yield* Effect.request(ReadCrmObject({
|
|
17
|
+
portalId,
|
|
18
|
+
objectType: input.objectType,
|
|
19
|
+
id: input.id,
|
|
20
|
+
...(input.idProperty ? { idProperty: input.idProperty } : {}),
|
|
21
|
+
properties: normalizeKeys(input.properties ?? []),
|
|
22
|
+
propertiesWithHistory: normalizeKeys(input.propertiesWithHistory ?? []),
|
|
23
|
+
associations: normalizeKeys(input.associations ?? []),
|
|
24
|
+
}), resolver);
|
|
25
|
+
})),
|
|
26
|
+
},
|
|
27
|
+
properties: {
|
|
28
|
+
read: (input) => run(Effect.gen(function* () {
|
|
29
|
+
const resolver = yield* ReadPropertyResolver;
|
|
30
|
+
return yield* Effect.request(ReadProperty({
|
|
31
|
+
portalId,
|
|
32
|
+
objectType: input.objectType,
|
|
33
|
+
name: input.name,
|
|
34
|
+
}), resolver);
|
|
35
|
+
})),
|
|
36
|
+
},
|
|
37
|
+
associations: {
|
|
38
|
+
read: (input) => run(Effect.gen(function* () {
|
|
39
|
+
const resolver = yield* ReadAssociationsResolver;
|
|
40
|
+
return yield* Effect.request(ReadAssociations({
|
|
41
|
+
portalId,
|
|
42
|
+
fromObjectType: input.fromObjectType,
|
|
43
|
+
toObjectType: input.toObjectType,
|
|
44
|
+
fromId: input.fromId,
|
|
45
|
+
}), resolver);
|
|
46
|
+
})),
|
|
47
|
+
},
|
|
48
|
+
run,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/effect/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,GAGd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAqB,MAAM,cAAc,CAAC;AA2C3F,MAAM,UAAU,2BAA2B,CACzC,YAA0B,EAC1B,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C,KAAK,EAAE,EAAE,CACd,GAAG,CACD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAClB,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,oBAAoB,CAAC;gBAC7C,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAC1B,YAAY,CAAC;oBACX,QAAQ;oBACR,UAAU,EAAE,KAAK,CAAC,UAAU;oBAC5B,IAAI,EAAE,KAAK,CAAC,IAAI;iBACjB,CAAC,EACF,QAAQ,CACT,CAAC;YACJ,CAAC,CAAC,CACH;SACJ;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CACd,GAAG,CACD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAClB,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,wBAAwB,CAAC;gBACjD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAC1B,gBAAgB,CAAC;oBACf,QAAQ;oBACR,cAAc,EAAE,KAAK,CAAC,cAAc;oBACpC,YAAY,EAAE,KAAK,CAAC,YAAY;oBAChC,MAAM,EAAE,KAAK,CAAC,MAAM;iBACrB,CAAC,EACF,QAAQ,CACT,CAAC;YACJ,CAAC,CAAC,CACH;SACJ;QACD,GAAG;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { HubSpotObjectNotFound, HubSpotObjectReadError, HubSpotPropertyReadError, ReadAssociations, ReadCrmObject, ReadProperty, normalizeKeys, type AssociationTarget, type HubSpotObject, } from './requests.js';
|
|
2
|
+
export { HubSpotApiService, layerFromManagedFetch, type HubSpotApiServiceShape, type ManagedFetch, } from './service.js';
|
|
3
|
+
export { ReadAssociationsResolver, ReadCrmObjectResolver, ReadPropertyResolver, } from './resolvers.js';
|
|
4
|
+
export { HubSpotRequestCacheLayer, withHubSpotBatching } from './cache.js';
|
|
5
|
+
export { createBatchingHubSpotClient, type BatchingHubSpotClient, type BatchObjectReadInput, type BatchPropertyReadInput, type BatchAssociationsReadInput, } from './client.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EACL,2BAA2B,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,GAChC,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { HubSpotObjectNotFound, HubSpotObjectReadError, HubSpotPropertyReadError, ReadAssociations, ReadCrmObject, ReadProperty, normalizeKeys, } from './requests.js';
|
|
2
|
+
export { HubSpotApiService, layerFromManagedFetch, } from './service.js';
|
|
3
|
+
export { ReadAssociationsResolver, ReadCrmObjectResolver, ReadPropertyResolver, } from './resolvers.js';
|
|
4
|
+
export { HubSpotRequestCacheLayer, withHubSpotBatching } from './cache.js';
|
|
5
|
+
export { createBatchingHubSpotClient, } from './client.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/effect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,GAGd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GAGtB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EACL,2BAA2B,GAK5B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Request } from 'effect';
|
|
2
|
+
import type { HubSpotPropertyDefinition } from '../index.js';
|
|
3
|
+
declare const HubSpotObjectReadError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
4
|
+
readonly _tag: "HubSpotObjectReadError";
|
|
5
|
+
} & Readonly<A>;
|
|
6
|
+
export declare class HubSpotObjectReadError extends HubSpotObjectReadError_base<{
|
|
7
|
+
readonly status: number;
|
|
8
|
+
readonly objectType: string;
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly category: string;
|
|
11
|
+
readonly message: string;
|
|
12
|
+
}> {
|
|
13
|
+
}
|
|
14
|
+
declare const HubSpotObjectNotFound_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
15
|
+
readonly _tag: "HubSpotObjectNotFound";
|
|
16
|
+
} & Readonly<A>;
|
|
17
|
+
export declare class HubSpotObjectNotFound extends HubSpotObjectNotFound_base<{
|
|
18
|
+
readonly objectType: string;
|
|
19
|
+
readonly id: string;
|
|
20
|
+
}> {
|
|
21
|
+
}
|
|
22
|
+
declare const HubSpotPropertyReadError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
23
|
+
readonly _tag: "HubSpotPropertyReadError";
|
|
24
|
+
} & Readonly<A>;
|
|
25
|
+
export declare class HubSpotPropertyReadError extends HubSpotPropertyReadError_base<{
|
|
26
|
+
readonly status: number;
|
|
27
|
+
readonly objectType: string;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly category: string;
|
|
30
|
+
readonly message: string;
|
|
31
|
+
}> {
|
|
32
|
+
}
|
|
33
|
+
export interface HubSpotObject {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly properties: Record<string, string | null>;
|
|
36
|
+
readonly propertiesWithHistory?: Record<string, readonly unknown[]>;
|
|
37
|
+
readonly createdAt: string;
|
|
38
|
+
readonly updatedAt: string;
|
|
39
|
+
}
|
|
40
|
+
export interface AssociationTarget {
|
|
41
|
+
readonly toObjectId: string;
|
|
42
|
+
readonly associationTypes: readonly {
|
|
43
|
+
readonly category: string;
|
|
44
|
+
readonly typeId: number;
|
|
45
|
+
readonly label?: string;
|
|
46
|
+
}[];
|
|
47
|
+
}
|
|
48
|
+
export interface ReadCrmObject extends Request.Request<HubSpotObject, HubSpotObjectReadError | HubSpotObjectNotFound> {
|
|
49
|
+
readonly _tag: 'ReadCrmObject';
|
|
50
|
+
readonly portalId: string;
|
|
51
|
+
readonly objectType: string;
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly idProperty?: string;
|
|
54
|
+
readonly properties: readonly string[];
|
|
55
|
+
readonly propertiesWithHistory: readonly string[];
|
|
56
|
+
readonly associations: readonly string[];
|
|
57
|
+
}
|
|
58
|
+
export declare const ReadCrmObject: Request.Request.Constructor<ReadCrmObject, "_tag">;
|
|
59
|
+
export interface ReadProperty extends Request.Request<HubSpotPropertyDefinition, HubSpotPropertyReadError> {
|
|
60
|
+
readonly _tag: 'ReadProperty';
|
|
61
|
+
readonly portalId: string;
|
|
62
|
+
readonly objectType: string;
|
|
63
|
+
readonly name: string;
|
|
64
|
+
}
|
|
65
|
+
export declare const ReadProperty: Request.Request.Constructor<ReadProperty, "_tag">;
|
|
66
|
+
export interface ReadAssociations extends Request.Request<readonly AssociationTarget[], HubSpotObjectReadError> {
|
|
67
|
+
readonly _tag: 'ReadAssociations';
|
|
68
|
+
readonly portalId: string;
|
|
69
|
+
readonly fromObjectType: string;
|
|
70
|
+
readonly toObjectType: string;
|
|
71
|
+
readonly fromId: string;
|
|
72
|
+
}
|
|
73
|
+
export declare const ReadAssociations: Request.Request.Constructor<ReadAssociations, "_tag">;
|
|
74
|
+
export declare const normalizeKeys: (xs: readonly string[]) => readonly string[];
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/effect/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAE,MAAM,QAAQ,CAAC;AAKvC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;;;;AAE7D,qBAAa,sBAAuB,SAAQ,4BAA2C;IACrF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;CAAG;;;;AAEL,qBAAa,qBAAsB,SAAQ,2BAA0C;IACnF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB,CAAC;CAAG;;;;AAEL,qBAAa,wBAAyB,SAAQ,8BAA6C;IACzF,QAAQ,CAAC,MAAM,EAAE,MA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AAS,MAAM,EAAE,CAAC;IAClD,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AACD,eAAO,MAAM,aAAa,oDAAiD,CAAC;AAE5E,MAAM,WAAW,YACf,SAAQ,OAAO,CAAC,OAAO,CAAC,yBAAyB,EAAE,wBAAwB,CAAC;IAC5E,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AACD,eAAO,MAAM,YAAY,mDAA+C,CAAC;AAEzE,MAAM,WAAW,gBACf,SAAQ,OAAO,CAAC,OAAO,CAAC,SAAS,iBAAiB,EAAE,EAAE,sBAAsB,CAAC;IAC7E,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AACD,eAAO,MAAM,gBAAgB,uDAAuD,CAAC;AAMrF,eAAO,MAAM,aAAa,GAAI,IAAI,SAAS,MAAM,EAAE,KAAG,SAAS,MAAM,EACzB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Data, Request } from 'effect';
|
|
2
|
+
export class HubSpotObjectReadError extends Data.TaggedError('HubSpotObjectReadError') {
|
|
3
|
+
}
|
|
4
|
+
export class HubSpotObjectNotFound extends Data.TaggedError('HubSpotObjectNotFound') {
|
|
5
|
+
}
|
|
6
|
+
export class HubSpotPropertyReadError extends Data.TaggedError('HubSpotPropertyReadError') {
|
|
7
|
+
}
|
|
8
|
+
export const ReadCrmObject = Request.tagged('ReadCrmObject');
|
|
9
|
+
export const ReadProperty = Request.tagged('ReadProperty');
|
|
10
|
+
export const ReadAssociations = Request.tagged('ReadAssociations');
|
|
11
|
+
// Cache-key stability: Effect Request equality is structural over fields, so
|
|
12
|
+
// callers must normalize array-valued fields (sorted + deduped) before
|
|
13
|
+
// constructing a Request, otherwise `['email','firstname']` and
|
|
14
|
+
// `['firstname','email']` would miss each other in the cache.
|
|
15
|
+
export const normalizeKeys = (xs) => Data.array(Array.from(new Set(xs)).sort());
|
|
16
|
+
//# sourceMappingURL=requests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requests.js","sourceRoot":"","sources":["../../src/effect/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAOvC,MAAM,OAAO,sBAAuB,SAAQ,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAMnF;CAAG;AAEL,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAGjF;CAAG;AAEL,MAAM,OAAO,wBAAyB,SAAQ,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAMvF;CAAG;AA8BL,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAgB,eAAe,CAAC,CAAC;AAS5E,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAe,cAAc,CAAC,CAAC;AAUzE,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAmB,kBAAkB,CAAC,CAAC;AAErF,6EAA6E;AAC7E,uEAAuE;AACvE,gEAAgE;AAChE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAqB,EAAqB,EAAE,CACxE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect, RequestResolver } from 'effect';
|
|
2
|
+
import { ReadAssociations, ReadCrmObject, ReadProperty } from './requests.js';
|
|
3
|
+
import { HubSpotApiService } from './service.js';
|
|
4
|
+
export declare const ReadCrmObjectResolver: Effect.Effect<RequestResolver.RequestResolver<ReadCrmObject, never>, never, HubSpotApiService>;
|
|
5
|
+
export declare const ReadPropertyResolver: Effect.Effect<RequestResolver.RequestResolver<ReadProperty, never>, never, HubSpotApiService>;
|
|
6
|
+
export declare const ReadAssociationsResolver: Effect.Effect<RequestResolver.RequestResolver<ReadAssociations, never>, never, HubSpotApiService>;
|
|
7
|
+
//# sourceMappingURL=resolvers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../src/effect/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAW,eAAe,EAAY,MAAM,QAAQ,CAAC;AAClF,OAAO,EAIL,gBAAgB,EAChB,aAAa,EACb,YAAY,EAGb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA+JjD,eAAO,MAAM,qBAAqB,gGAEjC,CAAC;AAgFF,eAAO,MAAM,oBAAoB,+FAEhC,CAAC;AA8FF,eAAO,MAAM,wBAAwB,mGAEpC,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Array as Arr, Effect, Request, RequestResolver, Schedule } from 'effect';
|
|
2
|
+
import { HubSpotObjectNotFound, HubSpotObjectReadError, HubSpotPropertyReadError, ReadAssociations, ReadCrmObject, ReadProperty, } from './requests.js';
|
|
3
|
+
import { HubSpotApiService } from './service.js';
|
|
4
|
+
const CHUNK = 100;
|
|
5
|
+
const transientRetry = Schedule.exponential('200 millis', 2).pipe(Schedule.compose(Schedule.recurs(3)));
|
|
6
|
+
const groupBy = (xs, key) => {
|
|
7
|
+
const out = new Map();
|
|
8
|
+
for (const x of xs) {
|
|
9
|
+
const k = key(x);
|
|
10
|
+
const arr = out.get(k);
|
|
11
|
+
if (arr)
|
|
12
|
+
arr.push(x);
|
|
13
|
+
else
|
|
14
|
+
out.set(k, [x]);
|
|
15
|
+
}
|
|
16
|
+
return out;
|
|
17
|
+
};
|
|
18
|
+
// --- ReadCrmObject ----------------------------------------------------------
|
|
19
|
+
const ReadCrmObjectResolverRaw = RequestResolver.makeBatched((requests) => Effect.gen(function* () {
|
|
20
|
+
const api = yield* HubSpotApiService;
|
|
21
|
+
const groups = groupBy(requests, (r) => [
|
|
22
|
+
r.portalId,
|
|
23
|
+
r.objectType,
|
|
24
|
+
r.idProperty ?? 'id',
|
|
25
|
+
r.properties.join(','),
|
|
26
|
+
r.propertiesWithHistory.join(','),
|
|
27
|
+
r.associations.join(','),
|
|
28
|
+
].join('|'));
|
|
29
|
+
yield* Effect.forEach(Array.from(groups.values()), (group) => {
|
|
30
|
+
const first = group[0];
|
|
31
|
+
const chunks = Arr.chunksOf(group, CHUNK);
|
|
32
|
+
return Effect.forEach(chunks, (chunk) => Effect.gen(function* () {
|
|
33
|
+
const body = {
|
|
34
|
+
inputs: chunk.map((r) => ({ id: r.id })),
|
|
35
|
+
properties: first.properties,
|
|
36
|
+
propertiesWithHistory: first.propertiesWithHistory,
|
|
37
|
+
...(first.idProperty ? { idProperty: first.idProperty } : {}),
|
|
38
|
+
};
|
|
39
|
+
const response = yield* api
|
|
40
|
+
.post(first.portalId, `/crm/v3/objects/${first.objectType}/batch/read?archived=false`, body)
|
|
41
|
+
.pipe(Effect.retry(transientRetry));
|
|
42
|
+
const byId = new Map();
|
|
43
|
+
for (const r of response.results ?? [])
|
|
44
|
+
byId.set(String(r.id), r);
|
|
45
|
+
const errorById = new Map();
|
|
46
|
+
for (const e of response.errors ?? []) {
|
|
47
|
+
for (const idCtx of e.context?.ids ?? [])
|
|
48
|
+
errorById.set(String(idCtx), e);
|
|
49
|
+
}
|
|
50
|
+
yield* Effect.forEach(chunk, (req) => {
|
|
51
|
+
const hit = byId.get(req.id);
|
|
52
|
+
if (hit)
|
|
53
|
+
return Request.completeEffect(req, Effect.succeed(hit));
|
|
54
|
+
const err = errorById.get(req.id);
|
|
55
|
+
if (err && err.status === 404) {
|
|
56
|
+
return Request.completeEffect(req, Effect.fail(new HubSpotObjectNotFound({
|
|
57
|
+
objectType: req.objectType,
|
|
58
|
+
id: req.id,
|
|
59
|
+
})));
|
|
60
|
+
}
|
|
61
|
+
return Request.completeEffect(req, Effect.fail(new HubSpotObjectReadError({
|
|
62
|
+
status: err?.status ?? 500,
|
|
63
|
+
objectType: req.objectType,
|
|
64
|
+
id: req.id,
|
|
65
|
+
category: err?.category ?? 'UNKNOWN',
|
|
66
|
+
message: err?.message ?? 'missing from batch response',
|
|
67
|
+
})));
|
|
68
|
+
}, { discard: true });
|
|
69
|
+
}).pipe(
|
|
70
|
+
// Whole-chunk HTTP failure: propagate per-request so siblings
|
|
71
|
+
// still resolve and the resolver itself never errors.
|
|
72
|
+
Effect.catchAll((apiError) => Effect.forEach(chunk, (req) => Request.completeEffect(req, Effect.fail(new HubSpotObjectReadError({
|
|
73
|
+
status: apiError.status,
|
|
74
|
+
objectType: req.objectType,
|
|
75
|
+
id: req.id,
|
|
76
|
+
category: apiError.category,
|
|
77
|
+
message: apiError.message,
|
|
78
|
+
}))), { discard: true }))), { concurrency: 'unbounded', discard: true });
|
|
79
|
+
}, { concurrency: 'unbounded', discard: true });
|
|
80
|
+
}));
|
|
81
|
+
// `Effect.request` requires `RequestResolver<A, never>`, so we pre-provide the
|
|
82
|
+
// service via `contextFromServices`. Callers `yield*` to receive a ready-to-use
|
|
83
|
+
// resolver while the `HubSpotApiService` requirement moves to the effect's R.
|
|
84
|
+
export const ReadCrmObjectResolver = RequestResolver.contextFromServices(HubSpotApiService)(ReadCrmObjectResolverRaw);
|
|
85
|
+
// --- ReadProperty -----------------------------------------------------------
|
|
86
|
+
const ReadPropertyResolverRaw = RequestResolver.makeBatched((requests) => Effect.gen(function* () {
|
|
87
|
+
const api = yield* HubSpotApiService;
|
|
88
|
+
const groups = groupBy(requests, (r) => `${r.portalId}|${r.objectType}`);
|
|
89
|
+
yield* Effect.forEach(Array.from(groups.values()), (group) => {
|
|
90
|
+
const first = group[0];
|
|
91
|
+
const chunks = Arr.chunksOf(group, CHUNK);
|
|
92
|
+
return Effect.forEach(chunks, (chunk) => Effect.gen(function* () {
|
|
93
|
+
const body = { inputs: chunk.map((r) => ({ name: r.name })) };
|
|
94
|
+
const response = yield* api
|
|
95
|
+
.post(first.portalId, `/crm/v3/properties/${first.objectType}/batch/read`, body)
|
|
96
|
+
.pipe(Effect.retry(transientRetry));
|
|
97
|
+
const byName = new Map();
|
|
98
|
+
for (const p of response.results ?? [])
|
|
99
|
+
byName.set(p.name, p);
|
|
100
|
+
yield* Effect.forEach(chunk, (req) => {
|
|
101
|
+
const hit = byName.get(req.name);
|
|
102
|
+
if (hit)
|
|
103
|
+
return Request.completeEffect(req, Effect.succeed(hit));
|
|
104
|
+
return Request.completeEffect(req, Effect.fail(new HubSpotPropertyReadError({
|
|
105
|
+
status: 404,
|
|
106
|
+
objectType: req.objectType,
|
|
107
|
+
name: req.name,
|
|
108
|
+
category: 'OBJECT_NOT_FOUND',
|
|
109
|
+
message: 'property not returned in batch response',
|
|
110
|
+
})));
|
|
111
|
+
}, { discard: true });
|
|
112
|
+
}).pipe(Effect.catchAll((apiError) => Effect.forEach(chunk, (req) => Request.completeEffect(req, Effect.fail(new HubSpotPropertyReadError({
|
|
113
|
+
status: apiError.status,
|
|
114
|
+
objectType: req.objectType,
|
|
115
|
+
name: req.name,
|
|
116
|
+
category: apiError.category,
|
|
117
|
+
message: apiError.message,
|
|
118
|
+
}))), { discard: true }))), { concurrency: 'unbounded', discard: true });
|
|
119
|
+
}, { concurrency: 'unbounded', discard: true });
|
|
120
|
+
}));
|
|
121
|
+
export const ReadPropertyResolver = RequestResolver.contextFromServices(HubSpotApiService)(ReadPropertyResolverRaw);
|
|
122
|
+
// --- ReadAssociations -------------------------------------------------------
|
|
123
|
+
const ReadAssociationsResolverRaw = RequestResolver.makeBatched((requests) => Effect.gen(function* () {
|
|
124
|
+
const api = yield* HubSpotApiService;
|
|
125
|
+
const groups = groupBy(requests, (r) => `${r.portalId}|${r.fromObjectType}|${r.toObjectType}`);
|
|
126
|
+
yield* Effect.forEach(Array.from(groups.values()), (group) => {
|
|
127
|
+
const first = group[0];
|
|
128
|
+
const chunks = Arr.chunksOf(group, CHUNK);
|
|
129
|
+
return Effect.forEach(chunks, (chunk) => Effect.gen(function* () {
|
|
130
|
+
const body = { inputs: chunk.map((r) => ({ id: r.fromId })) };
|
|
131
|
+
const response = yield* api
|
|
132
|
+
.post(first.portalId, `/crm/v4/associations/${first.fromObjectType}/${first.toObjectType}/batch/read`, body)
|
|
133
|
+
.pipe(Effect.retry(transientRetry));
|
|
134
|
+
const byFromId = new Map();
|
|
135
|
+
for (const r of response.results ?? []) {
|
|
136
|
+
byFromId.set(String(r.from.id), r.to);
|
|
137
|
+
}
|
|
138
|
+
const errorById = new Map();
|
|
139
|
+
for (const e of response.errors ?? []) {
|
|
140
|
+
for (const idCtx of e.context?.ids ?? [])
|
|
141
|
+
errorById.set(String(idCtx), e);
|
|
142
|
+
}
|
|
143
|
+
yield* Effect.forEach(chunk, (req) => {
|
|
144
|
+
const hit = byFromId.get(req.fromId);
|
|
145
|
+
if (hit)
|
|
146
|
+
return Request.completeEffect(req, Effect.succeed(hit));
|
|
147
|
+
const err = errorById.get(req.fromId);
|
|
148
|
+
if (!err) {
|
|
149
|
+
// No row + no error = empty associations for that fromId.
|
|
150
|
+
return Request.completeEffect(req, Effect.succeed([]));
|
|
151
|
+
}
|
|
152
|
+
return Request.completeEffect(req, Effect.fail(new HubSpotObjectReadError({
|
|
153
|
+
status: err.status ?? 500,
|
|
154
|
+
objectType: req.fromObjectType,
|
|
155
|
+
id: req.fromId,
|
|
156
|
+
category: err.category ?? 'UNKNOWN',
|
|
157
|
+
message: err.message ?? 'association read failed',
|
|
158
|
+
})));
|
|
159
|
+
}, { discard: true });
|
|
160
|
+
}).pipe(Effect.catchAll((apiError) => Effect.forEach(chunk, (req) => Request.completeEffect(req, Effect.fail(new HubSpotObjectReadError({
|
|
161
|
+
status: apiError.status,
|
|
162
|
+
objectType: req.fromObjectType,
|
|
163
|
+
id: req.fromId,
|
|
164
|
+
category: apiError.category,
|
|
165
|
+
message: apiError.message,
|
|
166
|
+
}))), { discard: true }))), { concurrency: 'unbounded', discard: true });
|
|
167
|
+
}, { concurrency: 'unbounded', discard: true });
|
|
168
|
+
}));
|
|
169
|
+
export const ReadAssociationsResolver = RequestResolver.contextFromServices(HubSpotApiService)(ReadAssociationsResolverRaw);
|
|
170
|
+
//# sourceMappingURL=resolvers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../../src/effect/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,YAAY,GAGb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,KAAK,GAAG,GAAG,CAAC;AAElB,MAAM,cAAc,GAAG,QAAQ,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAC/D,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CACrC,CAAC;AA4BF,MAAM,OAAO,GAAG,CAAK,EAAgB,EAAE,GAAqB,EAAoB,EAAE;IAChF,MAAM,GAAG,GAAG,IAAI,GAAG,EAAe,CAAC;IACnC,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QACnB,MAA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AAE,EAAE,GAAG,CAAC,MAAM;YACd,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;SAC1B,CAAC,CACH,CACF,EACH,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CACF,CACF,EACH,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAC5C,CAAC;IACJ,CAAC,EACD,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAC5C,CAAC;AACJ,CAAC,CAAC,CACL,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAC5F,2BAA2B,CAC5B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from 'effect';
|
|
2
|
+
import { HubSpotApiError } from '../index.js';
|
|
3
|
+
export type ManagedFetch = (input: Request | string | URL, init?: RequestInit) => Promise<Response>;
|
|
4
|
+
export interface HubSpotApiServiceShape {
|
|
5
|
+
readonly post: <T = unknown>(portalId: string, path: string, body: unknown) => Effect.Effect<T, HubSpotApiError>;
|
|
6
|
+
readonly get: <T = unknown>(portalId: string, path: string) => Effect.Effect<T, HubSpotApiError>;
|
|
7
|
+
}
|
|
8
|
+
declare const HubSpotApiService_base: Context.TagClass<HubSpotApiService, "@hs-x/hubspot/ApiService", HubSpotApiServiceShape>;
|
|
9
|
+
export declare class HubSpotApiService extends HubSpotApiService_base {
|
|
10
|
+
}
|
|
11
|
+
export declare const layerFromManagedFetch: (managedFetch: ManagedFetch, baseUrl?: string) => Layer.Layer<HubSpotApiService>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/effect/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,YAAY,GAAG,CACzB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,GAAG,EAC7B,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,OAAO,EACzB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,KACV,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,OAAO,EACxB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,KACT,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;CACxC;;AAED,qBAAa,iBAAkB,SAAQ,sBAGpC;CAAG;AAMN,eAAO,MAAM,qBAAqB,GAChC,cAAc,YAAY,EAC1B,UAAS,MAAyB,KACjC,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAgC5B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from 'effect';
|
|
2
|
+
import { HubSpotApiError } from '../index.js';
|
|
3
|
+
export class HubSpotApiService extends Context.Tag('@hs-x/hubspot/ApiService')() {
|
|
4
|
+
}
|
|
5
|
+
const DEFAULT_BASE_URL = 'https://api.hubapi.com';
|
|
6
|
+
// portalId is informational; the underlying managedFetch already inherits
|
|
7
|
+
// per-install auth + rate-limit accounting from the runtime.
|
|
8
|
+
export const layerFromManagedFetch = (managedFetch, baseUrl = DEFAULT_BASE_URL) => Layer.succeed(HubSpotApiService, {
|
|
9
|
+
post: (_portalId, path, body) => Effect.tryPromise({
|
|
10
|
+
try: async () => {
|
|
11
|
+
const r = await managedFetch(new URL(path, baseUrl), {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
headers: { 'content-type': 'application/json' },
|
|
14
|
+
body: JSON.stringify(body),
|
|
15
|
+
});
|
|
16
|
+
if (!r.ok) {
|
|
17
|
+
const errBody = await r.json().catch(() => ({}));
|
|
18
|
+
throw new HubSpotApiError(r.status, errBody);
|
|
19
|
+
}
|
|
20
|
+
return (await r.json());
|
|
21
|
+
},
|
|
22
|
+
catch: (e) => e instanceof HubSpotApiError ? e : new HubSpotApiError(0, { message: String(e) }),
|
|
23
|
+
}),
|
|
24
|
+
get: (_portalId, path) => Effect.tryPromise({
|
|
25
|
+
try: async () => {
|
|
26
|
+
const r = await managedFetch(new URL(path, baseUrl), { method: 'GET' });
|
|
27
|
+
if (!r.ok) {
|
|
28
|
+
const errBody = await r.json().catch(() => ({}));
|
|
29
|
+
throw new HubSpotApiError(r.status, errBody);
|
|
30
|
+
}
|
|
31
|
+
return (await r.json());
|
|
32
|
+
},
|
|
33
|
+
catch: (e) => e instanceof HubSpotApiError ? e : new HubSpotApiError(0, { message: String(e) }),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/effect/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAmB9C,MAAM,OAAO,iBAAkB,SAAQ,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,EAG3E;CAAG;AAEN,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAElD,0EAA0E;AAC1E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,YAA0B,EAC1B,UAAkB,gBAAgB,EACF,EAAE,CAClC,KAAK,CAAC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EAAE,CAAC;gBACV,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAA4B,CAAC;gBAC5E,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC/C,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAM,CAAC;QAC/B,CAAC;QACD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CACX,CAAC,YAAY,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;KACpF,CAAC;CACL,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { HubSpot, APIError as SdkAPIError, RateLimitError as SdkRateLimitError } from '@hubspot/sdk';
|
|
2
|
+
import type { Redacted as RedactedValue } from 'effect/Redacted';
|
|
3
|
+
export declare const HUBSPOT_CLIENT_VERSION = "0.2.0";
|
|
4
|
+
export { HubSpot } from '@hubspot/sdk';
|
|
5
|
+
/**
|
|
6
|
+
* SDK-thrown error classes re-exported for `instanceof` checks against the
|
|
7
|
+
* managed client. Distinct from `HubSpotApiError` below, which is a
|
|
8
|
+
* lightweight class used by non-runtime tools (CLI, codegen) that talk to
|
|
9
|
+
* the HubSpot REST API directly without going through `@hubspot/sdk`.
|
|
10
|
+
*/
|
|
11
|
+
export { APIError as HubSpotSdkApiError, RateLimitError as HubSpotSdkRateLimitError, NotFoundError as HubSpotSdkNotFoundError, AuthenticationError as HubSpotSdkAuthenticationError, } from '@hubspot/sdk';
|
|
12
|
+
export interface HubSpotErrorBody {
|
|
13
|
+
readonly status?: string;
|
|
14
|
+
readonly message?: string;
|
|
15
|
+
readonly category?: string;
|
|
16
|
+
readonly correlationId?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Lightweight error class for hand-rolled HubSpot REST calls (CLI, codegen).
|
|
20
|
+
* The managed runtime client uses the SDK's error hierarchy instead — see
|
|
21
|
+
* `HubSpotSdkApiError` / `HubSpotSdkRateLimitError`.
|
|
22
|
+
*/
|
|
23
|
+
export declare class HubSpotApiError extends Error {
|
|
24
|
+
readonly name = "HubSpotApiError";
|
|
25
|
+
readonly status: number;
|
|
26
|
+
readonly category: string;
|
|
27
|
+
readonly body: HubSpotErrorBody;
|
|
28
|
+
constructor(status: number, body: HubSpotErrorBody);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The HubSpot client surface workers receive on `context.hubspot`.
|
|
32
|
+
*
|
|
33
|
+
* Backed by `@hubspot/sdk` so every typed namespace (crm, marketing,
|
|
34
|
+
* automation, …) and the per-verb path escape hatches (`hubspot.get`,
|
|
35
|
+
* `hubspot.post`, …) share one transport. HS-X owns retry, backoff,
|
|
36
|
+
* auth, and rate-limit accounting via the SDK's custom-fetch hook —
|
|
37
|
+
* the SDK's own retry loop is always disabled (`maxRetries: 0`).
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* The `batch` property is populated by the runtime's managed client (see
|
|
41
|
+
* `@hs-x/hubspot/effect`'s `createBatchingHubSpotClient`). Unscoped /
|
|
42
|
+
* standalone clients leave it `undefined`.
|
|
43
|
+
*/
|
|
44
|
+
export type HubSpotClient = HubSpot & {
|
|
45
|
+
readonly batch?: import('./effect/client.js').BatchingHubSpotClient;
|
|
46
|
+
};
|
|
47
|
+
export type HubSpotFetch = (input: Request | string | URL, init?: RequestInit) => Promise<Response>;
|
|
48
|
+
export interface HubSpotClientOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Bearer token presented on every outbound request. The runtime's
|
|
51
|
+
* managed client passes a placeholder here and rewrites the
|
|
52
|
+
* Authorization header inside `fetch` once the per-install token is
|
|
53
|
+
* resolved.
|
|
54
|
+
*/
|
|
55
|
+
readonly accessToken: string | RedactedValue<string>;
|
|
56
|
+
readonly baseUrl?: string;
|
|
57
|
+
readonly fetch?: HubSpotFetch;
|
|
58
|
+
}
|
|
59
|
+
export declare function createHubSpotClient(options: HubSpotClientOptions): HubSpotClient;
|
|
60
|
+
/** True for any error the managed SDK client throws (network, 4xx, 5xx). */
|
|
61
|
+
export declare function isHubSpotSdkApiError(value: unknown): value is SdkAPIError;
|
|
62
|
+
/** True for a 429 thrown by the managed SDK client. */
|
|
63
|
+
export declare function isHubSpotRateLimitError(value: unknown): value is SdkRateLimitError;
|
|
64
|
+
export interface HubSpotMigrationAppList {
|
|
65
|
+
readonly results: readonly unknown[];
|
|
66
|
+
}
|
|
67
|
+
export interface HubSpotMigrateCardViewsRequest {
|
|
68
|
+
readonly appId: number;
|
|
69
|
+
readonly legacyCrmCardId: string | number;
|
|
70
|
+
readonly replacementAppCardId: string;
|
|
71
|
+
readonly helpDeskAppCardId?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface HubSpotPropertyDefinition {
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly label?: string;
|
|
76
|
+
readonly type: string;
|
|
77
|
+
readonly fieldType?: string;
|
|
78
|
+
readonly groupName?: string;
|
|
79
|
+
readonly options?: readonly unknown[];
|
|
80
|
+
}
|
|
81
|
+
export interface HubSpotPropertyList {
|
|
82
|
+
readonly results: readonly HubSpotPropertyDefinition[];
|
|
83
|
+
}
|
|
84
|
+
export interface HubSpotListPropertiesRequest {
|
|
85
|
+
readonly objectType: string;
|
|
86
|
+
}
|
|
87
|
+
export interface HubSpotCreatePropertyRequest {
|
|
88
|
+
readonly objectType: string;
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly label: string;
|
|
91
|
+
readonly type: string;
|
|
92
|
+
readonly fieldType?: string;
|
|
93
|
+
readonly groupName?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface HubSpotUpdatePropertyRequest {
|
|
96
|
+
readonly objectType: string;
|
|
97
|
+
readonly propertyName: string;
|
|
98
|
+
readonly label?: string;
|
|
99
|
+
readonly type?: string;
|
|
100
|
+
readonly fieldType?: string;
|
|
101
|
+
readonly groupName?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface HubSpotObjectSchema {
|
|
104
|
+
readonly name?: string;
|
|
105
|
+
readonly objectTypeId?: string;
|
|
106
|
+
readonly labels?: Record<string, string>;
|
|
107
|
+
readonly properties?: readonly HubSpotPropertyDefinition[];
|
|
108
|
+
}
|
|
109
|
+
export interface HubSpotSchemaList {
|
|
110
|
+
readonly results: readonly HubSpotObjectSchema[];
|
|
111
|
+
}
|
|
112
|
+
export interface HubSpotCreateSchemaRequest {
|
|
113
|
+
readonly name: string;
|
|
114
|
+
readonly labels: Record<string, string>;
|
|
115
|
+
readonly properties?: readonly HubSpotCreatePropertyRequest[];
|
|
116
|
+
}
|
|
117
|
+
export type HttpFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
118
|
+
export interface HttpClient {
|
|
119
|
+
/**
|
|
120
|
+
* Fetch an absolute URL on a non-HubSpot host. HubSpot hosts are rejected —
|
|
121
|
+
* use `context.hubspot` (typed namespaces or `hubspot.get/post/…`) instead,
|
|
122
|
+
* which carries auth, rate-limit accounting, and tracing.
|
|
123
|
+
*/
|
|
124
|
+
fetch: HttpFetch;
|
|
125
|
+
}
|
|
126
|
+
export interface HttpClientOptions {
|
|
127
|
+
readonly fetch?: typeof fetch;
|
|
128
|
+
}
|
|
129
|
+
export declare class HttpHubSpotHostRejectedError extends Error {
|
|
130
|
+
readonly name = "HttpHubSpotHostRejectedError";
|
|
131
|
+
constructor(host: string);
|
|
132
|
+
}
|
|
133
|
+
export declare function createHttpClient(options?: HttpClientOptions): HttpClient;
|
|
134
|
+
export { exchangePersonalAccessKey, uploadHubSpotProject, validateIntermediateRepresentation, InvalidProjectIntermediateRepresentation, type ExchangePersonalAccessKeyInput, type ExchangePersonalAccessKeyResult, type UploadHubSpotProjectInput, type UploadHubSpotProjectResult, } from './project-upload.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IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,4BAA4B,EAAE,CAAC;CAC/D;AASD,MAAM,MAAM,SAAS,GAAG,CACtB,KAAK,EAAE,MAAM,GAAG,GAAG,EACnB,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CAC/B;AAED,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,SAAkB,IAAI,kCAAkC;gBAC5C,IAAI,EAAE,MAAM;CAKzB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,UAAU,CAgB5E;AAGD,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,kCAAkC,EAClC,wCAAwC,EACxC,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EACpC,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,GAChC,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { HubSpot, APIError as SdkAPIError, RateLimitError as SdkRateLimitError, } from '@hubspot/sdk';
|
|
2
|
+
import { Redacted } from 'effect';
|
|
3
|
+
export const HUBSPOT_CLIENT_VERSION = '0.2.0';
|
|
4
|
+
export { HubSpot } from '@hubspot/sdk';
|
|
5
|
+
/**
|
|
6
|
+
* SDK-thrown error classes re-exported for `instanceof` checks against the
|
|
7
|
+
* managed client. Distinct from `HubSpotApiError` below, which is a
|
|
8
|
+
* lightweight class used by non-runtime tools (CLI, codegen) that talk to
|
|
9
|
+
* the HubSpot REST API directly without going through `@hubspot/sdk`.
|
|
10
|
+
*/
|
|
11
|
+
export { APIError as HubSpotSdkApiError, RateLimitError as HubSpotSdkRateLimitError, NotFoundError as HubSpotSdkNotFoundError, AuthenticationError as HubSpotSdkAuthenticationError, } from '@hubspot/sdk';
|
|
12
|
+
/**
|
|
13
|
+
* Lightweight error class for hand-rolled HubSpot REST calls (CLI, codegen).
|
|
14
|
+
* The managed runtime client uses the SDK's error hierarchy instead — see
|
|
15
|
+
* `HubSpotSdkApiError` / `HubSpotSdkRateLimitError`.
|
|
16
|
+
*/
|
|
17
|
+
export class HubSpotApiError extends Error {
|
|
18
|
+
name = 'HubSpotApiError';
|
|
19
|
+
status;
|
|
20
|
+
category;
|
|
21
|
+
body;
|
|
22
|
+
constructor(status, body) {
|
|
23
|
+
super(body.message ?? `HubSpot API request failed with status ${status}`);
|
|
24
|
+
this.status = status;
|
|
25
|
+
this.category = body.category ?? 'UNKNOWN';
|
|
26
|
+
this.body = body;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function createHubSpotClient(options) {
|
|
30
|
+
return new HubSpot({
|
|
31
|
+
accessToken: readSecret(options.accessToken),
|
|
32
|
+
maxRetries: 0,
|
|
33
|
+
...(options.baseUrl ? { baseURL: options.baseUrl } : {}),
|
|
34
|
+
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function readSecret(value) {
|
|
38
|
+
return Redacted.isRedacted(value) ? Redacted.value(value) : value;
|
|
39
|
+
}
|
|
40
|
+
/** True for any error the managed SDK client throws (network, 4xx, 5xx). */
|
|
41
|
+
export function isHubSpotSdkApiError(value) {
|
|
42
|
+
return value instanceof SdkAPIError;
|
|
43
|
+
}
|
|
44
|
+
/** True for a 429 thrown by the managed SDK client. */
|
|
45
|
+
export function isHubSpotRateLimitError(value) {
|
|
46
|
+
return value instanceof SdkRateLimitError;
|
|
47
|
+
}
|
|
48
|
+
// --- HttpClient: third-party outbound fetch --------------------------------
|
|
49
|
+
// Lives here (not in @hs-x/sdk) so we can guarantee the host-refusal rule
|
|
50
|
+
// stays in sync with HubSpot's known hosts. Workers reach this via
|
|
51
|
+
// `context.http`; HubSpot calls MUST go through `context.hubspot`.
|
|
52
|
+
const HUBSPOT_HOST_PATTERN = /(?:^|\.)(?:hubapi\.com|hubspot\.com|hubspotapi\.com)$/i;
|
|
53
|
+
export class HttpHubSpotHostRejectedError extends Error {
|
|
54
|
+
name = 'HttpHubSpotHostRejectedError';
|
|
55
|
+
constructor(host) {
|
|
56
|
+
super(`http.fetch refused HubSpot host "${host}". Use context.hubspot for HubSpot API calls so auth, rate limits, and tracing apply.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function createHttpClient(options = {}) {
|
|
60
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
61
|
+
return {
|
|
62
|
+
async fetch(input, init) {
|
|
63
|
+
if (typeof input === 'string' && !/^https?:\/\//i.test(input)) {
|
|
64
|
+
throw new Error(`http.fetch requires an absolute URL (got ${JSON.stringify(input)}). Use context.hubspot for HubSpot API paths.`);
|
|
65
|
+
}
|
|
66
|
+
const url = input instanceof URL ? input : new URL(input);
|
|
67
|
+
if (HUBSPOT_HOST_PATTERN.test(url.host)) {
|
|
68
|
+
throw new HttpHubSpotHostRejectedError(url.host);
|
|
69
|
+
}
|
|
70
|
+
return fetchImpl(url, init);
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// Portable (Bun + node + workerd) HubSpot project upload + PAK exchange.
|
|
75
|
+
export { exchangePersonalAccessKey, uploadHubSpotProject, validateIntermediateRepresentation, InvalidProjectIntermediateRepresentation, } from './project-upload.js';
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,QAAQ,IAAI,WAAW,EACvB,cAAc,IAAI,iBAAiB,GAC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ACnD,CAAC;YACD,OAAO,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,kCAAkC,EAClC,wCAAwC,GAKzC,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** A web-standard `fetch`, injectable so callers/tests can stub the transport. */
|
|
2
|
+
type FetchLike = typeof globalThis.fetch;
|
|
3
|
+
declare const InvalidProjectIntermediateRepresentation_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
4
|
+
readonly _tag: "InvalidProjectIntermediateRepresentation";
|
|
5
|
+
} & Readonly<A>;
|
|
6
|
+
/**
|
|
7
|
+
* Thrown when the project intermediate representation does not satisfy the
|
|
8
|
+
* minimal contract HubSpot's `upload/new-api` pipeline requires. Surfacing this
|
|
9
|
+
* before the network call turns what was an opaque gateway 400 into a message
|
|
10
|
+
* that names the offending field. It is a `Data.TaggedError`, so it is also a
|
|
11
|
+
* plain `Error` (callers that only read `.message` keep working).
|
|
12
|
+
*/
|
|
13
|
+
export declare class InvalidProjectIntermediateRepresentation extends InvalidProjectIntermediateRepresentation_base<{
|
|
14
|
+
readonly message: string;
|
|
15
|
+
}> {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validate a project IR before it reaches HubSpot. A missing IR (`undefined`)
|
|
19
|
+
* is left to the caller's legacy no-component path; a present-but-malformed IR
|
|
20
|
+
* throws {@link InvalidProjectIntermediateRepresentation}.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateIntermediateRepresentation(intermediateRepresentation: unknown): void;
|
|
23
|
+
export interface ExchangePersonalAccessKeyInput {
|
|
24
|
+
readonly personalAccessKey: string;
|
|
25
|
+
readonly portalId: number | string;
|
|
26
|
+
/** Override the API base (e.g. a HubSpot QA environment). Defaults to prod. */
|
|
27
|
+
readonly baseUrl?: string;
|
|
28
|
+
/** Override the transport (tests, custom workerd fetch). Defaults to global `fetch`. */
|
|
29
|
+
readonly fetchImpl?: FetchLike;
|
|
30
|
+
}
|
|
31
|
+
export interface ExchangePersonalAccessKeyResult {
|
|
32
|
+
readonly accessToken: string;
|
|
33
|
+
readonly expiresAtMillis?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Exchange a HubSpot personal access key (PAK) for a short-lived OAuth access
|
|
37
|
+
* token via `localdevauth/v1/auth/refresh`. Runs anywhere `fetch` exists.
|
|
38
|
+
*/
|
|
39
|
+
export declare function exchangePersonalAccessKey(input: ExchangePersonalAccessKeyInput): Promise<ExchangePersonalAccessKeyResult>;
|
|
40
|
+
export interface UploadHubSpotProjectInput {
|
|
41
|
+
readonly accessToken: string;
|
|
42
|
+
readonly portalId: number | string;
|
|
43
|
+
readonly projectName: string;
|
|
44
|
+
/** The project source archive (zip) as bytes or a Blob. */
|
|
45
|
+
readonly zip: Uint8Array | ArrayBuffer | Blob;
|
|
46
|
+
/**
|
|
47
|
+
* The intermediate representation describing the project's components, sent
|
|
48
|
+
* as the `uploadRequest` field. `projectName` and `buildMessage` are merged
|
|
49
|
+
* in. Required by the `upload/new-api` pipeline for platform 2026.x and
|
|
50
|
+
* validated via {@link validateIntermediateRepresentation} before upload.
|
|
51
|
+
*/
|
|
52
|
+
readonly intermediateRepresentation: unknown;
|
|
53
|
+
readonly platformVersion?: string;
|
|
54
|
+
readonly buildMessage?: string;
|
|
55
|
+
readonly baseUrl?: string;
|
|
56
|
+
/** Override the transport (tests, custom workerd fetch). Defaults to global `fetch`. */
|
|
57
|
+
readonly fetchImpl?: FetchLike;
|
|
58
|
+
}
|
|
59
|
+
export interface UploadHubSpotProjectResult {
|
|
60
|
+
readonly buildId: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Upload a HubSpot project to the `upload/new-api` build pipeline. The project
|
|
64
|
+
* must already exist (create it first; this endpoint does not auto-create).
|
|
65
|
+
*
|
|
66
|
+
* Crucially this does NOT set `Content-Type` by hand — `bodyFormData` strips it
|
|
67
|
+
* so the runtime sets the multipart boundary. Setting it manually breaks the
|
|
68
|
+
* boundary and yields a gateway 400.
|
|
69
|
+
*/
|
|
70
|
+
export declare function uploadHubSpotProject(input: UploadHubSpotProjectInput): Promise<UploadHubSpotProjectResult>;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=project-upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-upload.d.ts","sourceRoot":"","sources":["../src/project-upload.ts"],"names":[],"mappings":"AAyCA,kFAAkF;AAClF,KAAK,SAAS,GAAG,OAAO,UAAU,CAAC,KAAK,CAAC;;;;AAMzC;;;;;;GAMG;AACH,qBAAa,wCAAyC,SAAQ,8CAE5D;IACA,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;CAAG;AAqCL;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,0BAA0B,EAAE,OAAO,GAAG,IAAI,CAY5F;AAsED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wFAAwF;IACxF,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,+BAA+B,CAAC,CAsB1C;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2DAA2D;IAC3D,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,CAAC;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,0BAA0B,EAAE,OAAO,CAAC;IAC7C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wFAAwF;IACxF,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,0BAA0B,CAAC,CAqCrC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable HubSpot project upload primitives.
|
|
3
|
+
*
|
|
4
|
+
* These talk to HubSpot's REST API over the shared `@hs-x/types/http` Effect
|
|
5
|
+
* HTTP client, using only web-standard `fetch` / `FormData` / `Blob` under the
|
|
6
|
+
* hood, with no Node-specific dependencies (no `fs` streams, no axios). That is
|
|
7
|
+
* deliberate: the same code must run under Bun (the local CLI) and under
|
|
8
|
+
* workerd (the control plane / dashboard-driven deploys).
|
|
9
|
+
*
|
|
10
|
+
* The CLI previously uploaded via `@hubspot/local-dev-lib`, which builds the
|
|
11
|
+
* multipart body from a Node `fs.createReadStream` through axios. Under Bun
|
|
12
|
+
* that produced a malformed multipart request that HubSpot rejected with an
|
|
13
|
+
* opaque Jetty `HTTP 400`. A plain `FormData` + `Blob` upload is accepted, and
|
|
14
|
+
* is portable to workerd where `fs` does not exist at all. `@effect/platform`'s
|
|
15
|
+
* `bodyFormData` preserves that behaviour exactly — it strips `Content-Type`
|
|
16
|
+
* so the runtime sets the multipart boundary, the same invariant the hand-
|
|
17
|
+
* rolled `fetch` relied on.
|
|
18
|
+
*
|
|
19
|
+
* Going through the shared client (rather than a bare `fetch`) adds a request
|
|
20
|
+
* timeout and transient-failure retry/backoff to the deploy path, and turns a
|
|
21
|
+
* malformed intermediate representation into a typed error naming the failing
|
|
22
|
+
* field instead of an opaque HubSpot 400.
|
|
23
|
+
*/
|
|
24
|
+
import { Data, Effect, Either, ParseResult, Schedule, Schema } from 'effect';
|
|
25
|
+
import { DEFAULT_HTTP_RETRY_SCHEDULE, HsxHttpClientRaw, HsxHttpClientRawFromFetch, HttpClient, HttpClientRequest, } from '@hs-x/types/http';
|
|
26
|
+
import { HubSpotApiError } from './index.js';
|
|
27
|
+
const HUBSPOT_API_BASE = 'https://api.hubapi.com';
|
|
28
|
+
const PROJECT_UPLOAD_PATH = 'project-components-external/v3/upload/new-api';
|
|
29
|
+
const PAK_EXCHANGE_PATH = 'localdevauth/v1/auth/refresh';
|
|
30
|
+
const DEFAULT_PLATFORM_VERSION = '2026.03';
|
|
31
|
+
/** Status codes worth retrying: rate limiting and transient gateway errors. */
|
|
32
|
+
const RETRYABLE_STATUSES = new Set([429, 500, 502, 503, 504]);
|
|
33
|
+
function isRecord(value) {
|
|
34
|
+
return typeof value === 'object' && value !== null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Thrown when the project intermediate representation does not satisfy the
|
|
38
|
+
* minimal contract HubSpot's `upload/new-api` pipeline requires. Surfacing this
|
|
39
|
+
* before the network call turns what was an opaque gateway 400 into a message
|
|
40
|
+
* that names the offending field. It is a `Data.TaggedError`, so it is also a
|
|
41
|
+
* plain `Error` (callers that only read `.message` keep working).
|
|
42
|
+
*/
|
|
43
|
+
export class InvalidProjectIntermediateRepresentation extends Data.TaggedError('InvalidProjectIntermediateRepresentation') {
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The minimal shape `upload/new-api` accepts. The IR carries more per-node
|
|
47
|
+
* fields (`componentDeps`, `metaFilePath`, `files`, …) and a top-level
|
|
48
|
+
* `profileData`; `Schema.Struct` ignores those excess keys, so we only assert
|
|
49
|
+
* the parts whose absence makes HubSpot reject the build.
|
|
50
|
+
*/
|
|
51
|
+
const ProjectComponentNode = Schema.Struct({
|
|
52
|
+
uid: Schema.String,
|
|
53
|
+
componentType: Schema.String,
|
|
54
|
+
config: Schema.Record({ key: Schema.String, value: Schema.Unknown }),
|
|
55
|
+
});
|
|
56
|
+
const ProjectIntermediateRepresentation = Schema.Struct({
|
|
57
|
+
intermediateNodesIndexedByUid: Schema.Record({
|
|
58
|
+
key: Schema.String,
|
|
59
|
+
value: ProjectComponentNode,
|
|
60
|
+
}),
|
|
61
|
+
}).pipe(Schema.filter((ir) => {
|
|
62
|
+
const nodes = Object.values(ir.intermediateNodesIndexedByUid);
|
|
63
|
+
if (nodes.length === 0) {
|
|
64
|
+
return 'intermediateNodesIndexedByUid must contain at least one component node';
|
|
65
|
+
}
|
|
66
|
+
if (!nodes.some((node) => node.componentType === 'APPLICATION')) {
|
|
67
|
+
return 'project has no APPLICATION component (HubSpot rejects the build with NO_COMPONENTS)';
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
}));
|
|
71
|
+
const decodeIntermediateRepresentation = Schema.decodeUnknownEither(ProjectIntermediateRepresentation, { errors: 'all' });
|
|
72
|
+
/**
|
|
73
|
+
* Validate a project IR before it reaches HubSpot. A missing IR (`undefined`)
|
|
74
|
+
* is left to the caller's legacy no-component path; a present-but-malformed IR
|
|
75
|
+
* throws {@link InvalidProjectIntermediateRepresentation}.
|
|
76
|
+
*/
|
|
77
|
+
export function validateIntermediateRepresentation(intermediateRepresentation) {
|
|
78
|
+
if (intermediateRepresentation === undefined) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const decoded = decodeIntermediateRepresentation(intermediateRepresentation);
|
|
82
|
+
if (Either.isLeft(decoded)) {
|
|
83
|
+
throw new InvalidProjectIntermediateRepresentation({
|
|
84
|
+
message: 'Project intermediate representation is malformed; HubSpot would reject the upload with an opaque 400.\n' +
|
|
85
|
+
ParseResult.TreeFormatter.formatErrorSync(decoded.left),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Retryable HubSpot status, carried in the error channel so the policy can see it. */
|
|
90
|
+
class TransientHubSpotFailure extends Data.TaggedError('TransientHubSpotFailure') {
|
|
91
|
+
}
|
|
92
|
+
const parseErrorBody = (status, text) => {
|
|
93
|
+
try {
|
|
94
|
+
const parsed = JSON.parse(text);
|
|
95
|
+
if (isRecord(parsed)) {
|
|
96
|
+
return parsed;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
// HubSpot returns a bare HTML page for some gateway-level 400s.
|
|
101
|
+
}
|
|
102
|
+
return { message: text.slice(0, 300) || `HubSpot request failed (${status}).` };
|
|
103
|
+
};
|
|
104
|
+
/** Retry transient HubSpot statuses with the shared exponential backoff. */
|
|
105
|
+
const retryTransientStatus = DEFAULT_HTTP_RETRY_SCHEDULE.pipe(Schedule.intersect(Schedule.recurs(2)), Schedule.whileInput((error) => error instanceof TransientHubSpotFailure));
|
|
106
|
+
/**
|
|
107
|
+
* Execute a HubSpot REST request through the shared HTTP client and return the
|
|
108
|
+
* decoded JSON body. Non-2xx responses become a `HubSpotApiError` (terminal) or
|
|
109
|
+
* a retried `TransientHubSpotFailure`; transport/timeout failures are mapped to
|
|
110
|
+
* a `HubSpotApiError` with status 0 so callers see one consistent error type.
|
|
111
|
+
*/
|
|
112
|
+
function runHubSpotRequest(request, fetchImpl) {
|
|
113
|
+
const program = Effect.gen(function* () {
|
|
114
|
+
const client = yield* HttpClient.HttpClient;
|
|
115
|
+
const response = yield* client.execute(request);
|
|
116
|
+
if (response.status >= 200 && response.status < 300) {
|
|
117
|
+
const body = yield* response.json.pipe(Effect.orElseSucceed(() => ({})));
|
|
118
|
+
return isRecord(body) ? body : {};
|
|
119
|
+
}
|
|
120
|
+
const text = yield* response.text.pipe(Effect.orElseSucceed(() => ''));
|
|
121
|
+
const body = parseErrorBody(response.status, text);
|
|
122
|
+
return yield* Effect.fail(RETRYABLE_STATUSES.has(response.status)
|
|
123
|
+
? new TransientHubSpotFailure({ status: response.status, body })
|
|
124
|
+
: new HubSpotApiError(response.status, body));
|
|
125
|
+
}).pipe(Effect.retry(retryTransientStatus), Effect.catchTag('TransientHubSpotFailure', (error) => Effect.fail(new HubSpotApiError(error.status, error.body))), Effect.catchTags({
|
|
126
|
+
RequestError: (error) => Effect.fail(new HubSpotApiError(0, { message: error.message })),
|
|
127
|
+
ResponseError: (error) => Effect.fail(new HubSpotApiError(0, { message: error.message })),
|
|
128
|
+
}));
|
|
129
|
+
const layer = fetchImpl ? HsxHttpClientRawFromFetch(fetchImpl) : HsxHttpClientRaw;
|
|
130
|
+
return Effect.runPromise(Effect.either(program.pipe(Effect.provide(layer)))).then((result) => {
|
|
131
|
+
if (Either.isLeft(result)) {
|
|
132
|
+
throw result.left;
|
|
133
|
+
}
|
|
134
|
+
return result.right;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Exchange a HubSpot personal access key (PAK) for a short-lived OAuth access
|
|
139
|
+
* token via `localdevauth/v1/auth/refresh`. Runs anywhere `fetch` exists.
|
|
140
|
+
*/
|
|
141
|
+
export async function exchangePersonalAccessKey(input) {
|
|
142
|
+
const url = new URL(`${input.baseUrl ?? HUBSPOT_API_BASE}/${PAK_EXCHANGE_PATH}`);
|
|
143
|
+
url.searchParams.set('portalId', String(input.portalId));
|
|
144
|
+
const request = HttpClientRequest.post(url.toString()).pipe(HttpClientRequest.bodyText(JSON.stringify({ encodedOAuthRefreshToken: input.personalAccessKey }), 'application/json'));
|
|
145
|
+
const body = await runHubSpotRequest(request, input.fetchImpl);
|
|
146
|
+
const accessToken = body.oauthAccessToken ?? body.accessToken;
|
|
147
|
+
if (typeof accessToken !== 'string' || accessToken.length === 0) {
|
|
148
|
+
throw new HubSpotApiError(200, {
|
|
149
|
+
message: 'HubSpot PAK exchange response did not include an access token.',
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
accessToken,
|
|
154
|
+
...(typeof body.expiresAtMillis === 'number' ? { expiresAtMillis: body.expiresAtMillis } : {}),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Upload a HubSpot project to the `upload/new-api` build pipeline. The project
|
|
159
|
+
* must already exist (create it first; this endpoint does not auto-create).
|
|
160
|
+
*
|
|
161
|
+
* Crucially this does NOT set `Content-Type` by hand — `bodyFormData` strips it
|
|
162
|
+
* so the runtime sets the multipart boundary. Setting it manually breaks the
|
|
163
|
+
* boundary and yields a gateway 400.
|
|
164
|
+
*/
|
|
165
|
+
export async function uploadHubSpotProject(input) {
|
|
166
|
+
validateIntermediateRepresentation(input.intermediateRepresentation);
|
|
167
|
+
const url = new URL(`${input.baseUrl ?? HUBSPOT_API_BASE}/${PROJECT_UPLOAD_PATH}`);
|
|
168
|
+
url.searchParams.set('portalId', String(input.portalId));
|
|
169
|
+
const zipBlob = input.zip instanceof Blob
|
|
170
|
+
? input.zip
|
|
171
|
+
: new Blob([input.zip], { type: 'application/zip' });
|
|
172
|
+
const safeName = input.projectName.replace(/[^a-zA-Z0-9._-]+/g, '-');
|
|
173
|
+
const form = new FormData();
|
|
174
|
+
form.append('projectFilesZip', zipBlob, `${safeName}-hubspot-project.zip`);
|
|
175
|
+
form.append('platformVersion', input.platformVersion ?? DEFAULT_PLATFORM_VERSION);
|
|
176
|
+
form.append('uploadRequest', JSON.stringify({
|
|
177
|
+
...(isRecord(input.intermediateRepresentation) ? input.intermediateRepresentation : {}),
|
|
178
|
+
projectName: input.projectName,
|
|
179
|
+
buildMessage: input.buildMessage ?? 'HS-X deploy',
|
|
180
|
+
}));
|
|
181
|
+
const request = HttpClientRequest.post(url.toString()).pipe(HttpClientRequest.setHeader('authorization', `Bearer ${input.accessToken}`), HttpClientRequest.bodyFormData(form));
|
|
182
|
+
const body = await runHubSpotRequest(request, input.fetchImpl);
|
|
183
|
+
const buildId = body.createdBuildId ?? body.buildId;
|
|
184
|
+
if (typeof buildId !== 'number') {
|
|
185
|
+
throw new HubSpotApiError(200, {
|
|
186
|
+
message: 'HubSpot upload succeeded but the response did not include a build id.',
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return { buildId };
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=project-upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-upload.js","sourceRoot":"","sources":["../src/project-upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7E,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,yBAAyB,EACzB,UAAU,EACV,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAyB,MAAM,YAAY,CAAC;AAEpE,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAClD,MAAM,mBAAmB,GAAG,+CAA+C,CAAC;AAC5E,MAAM,iBAAiB,GAAG,8BAA8B,CAAC;AACzD,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAE3C,+EAA+E;AAC/E,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAK9D,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,K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+1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hs-x/hubspot",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Thin wrap over @hubspot/sdk with install scoping, portal-schema typing, and rate-limiter integration.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./effect": {
|
|
14
|
+
"types": "./dist/effect/index.d.ts",
|
|
15
|
+
"default": "./dist/effect/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -b",
|
|
24
|
+
"clean": "tsc -b --clean"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^25.8.0"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@hs-x/types": "0.1.0",
|
|
34
|
+
"@hubspot/sdk": "0.1.0-alpha.9",
|
|
35
|
+
"effect": "^3.10.19"
|
|
36
|
+
}
|
|
37
|
+
}
|