@hubspot/local-dev-lib 0.3.0 → 0.3.2

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,7 +1,20 @@
1
1
  import { FetchSchemasResponse, Schema } from '../types/Schemas';
2
- export declare function batchCreateObjects(accountId: number, objectTypeId: string, objects: JSON): Promise<void>;
2
+ type CreateObjectsResponse = {
3
+ status: string;
4
+ startedAt: string;
5
+ completedAt: string;
6
+ results: Array<{
7
+ id: string;
8
+ properties: Array<any>;
9
+ createdAt: string;
10
+ updatedAt: string;
11
+ archived: boolean;
12
+ }>;
13
+ };
14
+ export declare function batchCreateObjects(accountId: number, objectTypeId: string, objects: JSON): Promise<CreateObjectsResponse>;
3
15
  export declare function createObjectSchema(accountId: number, schema: JSON): Promise<Schema>;
4
16
  export declare function updateObjectSchema(accountId: number, schemaObjectType: string, schema: Schema): Promise<Schema>;
5
17
  export declare function fetchObjectSchema(accountId: number, schemaObjectType: string): Promise<Schema>;
6
18
  export declare function fetchObjectSchemas(accountId: number): Promise<FetchSchemasResponse>;
7
19
  export declare function deleteObjectSchema(accountId: number, schemaObjectType: string): Promise<void>;
20
+ export {};
@@ -8,7 +8,7 @@ const http_1 = __importDefault(require("../http"));
8
8
  const CUSTOM_OBJECTS_API_PATH = 'crm/v3/objects';
9
9
  const SCHEMA_API_PATH = 'crm-object-schemas/v3/schemas';
10
10
  async function batchCreateObjects(accountId, objectTypeId, objects) {
11
- http_1.default.post(accountId, {
11
+ return http_1.default.post(accountId, {
12
12
  url: `${CUSTOM_OBJECTS_API_PATH}/${objectTypeId}/batch/create`,
13
13
  data: objects,
14
14
  });
@@ -0,0 +1,3 @@
1
+ export declare function createSchemaFromHubFile(accountId: number, filepath: string): Promise<unknown>;
2
+ export declare function updateSchemaFromHubFile(accountId: number, filepath: string): Promise<unknown>;
3
+ export declare function fetchHubFileSchema(accountId: number, objectName: string, path: string): Promise<import("axios").AxiosResponse<any, any>>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchHubFileSchema = exports.updateSchemaFromHubFile = exports.createSchemaFromHubFile = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const path_2 = require("../lib/path");
10
+ const http_1 = __importDefault(require("../http"));
11
+ const HUBFILES_API_PATH = '/file-transport/v1/hubfiles';
12
+ async function createSchemaFromHubFile(accountId, filepath) {
13
+ const file = fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), filepath));
14
+ return http_1.default.post(accountId, {
15
+ url: `${HUBFILES_API_PATH}/object-schemas`,
16
+ data: {
17
+ file,
18
+ },
19
+ headers: { 'Content-Type': 'multipart/form-data' },
20
+ });
21
+ }
22
+ exports.createSchemaFromHubFile = createSchemaFromHubFile;
23
+ async function updateSchemaFromHubFile(accountId, filepath) {
24
+ const file = fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), filepath));
25
+ return http_1.default.put(accountId, {
26
+ url: `${HUBFILES_API_PATH}/object-schemas`,
27
+ data: {
28
+ file,
29
+ },
30
+ headers: { 'Content-Type': 'multipart/form-data' },
31
+ });
32
+ }
33
+ exports.updateSchemaFromHubFile = updateSchemaFromHubFile;
34
+ async function fetchHubFileSchema(accountId, objectName, path) {
35
+ return http_1.default.getOctetStream(accountId, {
36
+ url: `${HUBFILES_API_PATH}/object-schemas/${objectName}`,
37
+ }, path);
38
+ }
39
+ exports.fetchHubFileSchema = fetchHubFileSchema;
package/api/hubdb.js CHANGED
@@ -29,6 +29,9 @@ exports.updateTable = updateTable;
29
29
  async function publishTable(accountId, tableId) {
30
30
  return http_1.default.post(accountId, {
31
31
  url: `${HUBDB_API_PATH}/tables/${tableId}/draft/publish`,
32
+ headers: {
33
+ 'Content-Type': 'application/json',
34
+ },
32
35
  });
33
36
  }
34
37
  exports.publishTable = publishTable;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
4
- // NOTE this is the legacy config file name (We still need to keep it around though)
5
4
  exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
6
5
  exports.HUBSPOT_CONFIGURATION_FOLDER = '.hubspot';
7
6
  exports.HUBSPOT_CONFIGURATION_FILE = 'config.yml';
package/http/index.js CHANGED
@@ -102,7 +102,7 @@ async function putRequest(accountId, options) {
102
102
  }
103
103
  async function patchRequest(accountId, options) {
104
104
  const configWithAuth = await withAuth(accountId, options);
105
- const { data } = await (0, axios_1.default)({ ...configWithAuth, method: 'put' });
105
+ const { data } = await (0, axios_1.default)({ ...configWithAuth, method: 'patch' });
106
106
  return data;
107
107
  }
108
108
  async function deleteRequest(accountId, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "main": "lib/index.js",
6
6
  "repository": {