n8n-nodes-kapacity 0.1.3 → 0.1.5

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/README.md CHANGED
@@ -28,7 +28,7 @@ The package contains two nodes.
28
28
 
29
29
  | Resource | Operations |
30
30
  | --- | --- |
31
- | Contact | Create, Create or Update (by e-mail), Delete, Get, Get Many, Update |
31
+ | Contact | Create, Create or Update (by e-mail), Delete, Get, Get Many, Move, Update |
32
32
  | Row (your own CRM tables) | Create, Delete, Get, Get Many, Update |
33
33
  | Table | Get Columns, Get Many |
34
34
  | Contract | Send (from a template, for e-signature), Get (with its audit trail), Get Many |
@@ -49,6 +49,7 @@ What the node does for you, so you never write a request body:
49
49
  - **Readable output.** By default a contact or a row comes out with column names, option labels and member names instead of IDs. Choose **Output Format: Raw** to get the API response as is.
50
50
  - **Pagination.** **Return All** reads every page for you.
51
51
  - **Contacts found by e-mail.** **Create or Update** updates the contact that has this e-mail, or creates it.
52
+ - **Setting to Mon Pipe.** **Move** hands a contact over from Setting to Mon Pipe (or back), as the Base menu of its record does: same contact, default status of the new base, automations of the new base.
52
53
 
53
54
  ### Kapacity Trigger
54
55
 
@@ -73,7 +74,7 @@ You need a Kapacity workspace, as an administrator, and an API key. The Kapacity
73
74
  2. Click **Nouvelle clé**. Choose **Lecture et écriture** (read and write) if the workflow creates or changes data, or uses the trigger. Choose **Lecture seule** (read only) otherwise.
74
75
  3. Click **Créer la clé** and copy the key (it starts with `kap_live_`): it is shown only once.
75
76
  4. Copy the workspace ID shown in the same card (**Identifiant de votre espace**).
76
- 5. In n8n, create a **Kapacity API** credential and paste the key and the workspace ID. Leave **Base URL** as `https://kapacity.app`.
77
+ 5. In n8n, create a **Kapacity API** credential and paste the key and the workspace ID. Leave **Base URL** as `https://kapacity.app`: the Kapacity address only, without `/api/v1/w/…` after it (since 0.1.5, a Base URL pasted with that path is brought back to the Kapacity address).
77
78
 
78
79
  n8n checks the credential by calling the API: a wrong key or a key from another workspace is reported at once.
79
80
 
@@ -101,6 +102,10 @@ The API has a monthly quota per workspace. Each call counts, so prefer the trigg
101
102
 
102
103
  ## Version history
103
104
 
105
+ ### 0.1.4
106
+
107
+ Contact, Move: hands a contact over from Setting to Mon Pipe, or back. A contact can be created with only an e-mail or only a phone.
108
+
104
109
  ### 0.1.3
105
110
 
106
111
  Installs on n8n instances upgraded from 1.x that still keep an old n8n-workflow in ~/.n8n/nodes (the install used to fail with "Class could not be found").
@@ -32,7 +32,7 @@ class KapacityApi {
32
32
  name: 'baseUrl',
33
33
  type: 'string',
34
34
  default: 'https://kapacity.app',
35
- description: 'Only change this if Kapacity gave you another address',
35
+ description: 'The Kapacity address only, without /api/v1/w/… after it: the node adds that path itself. Only change this if Kapacity gave you another address',
36
36
  },
37
37
  ];
38
38
  this.authenticate = {
@@ -45,7 +45,7 @@ class KapacityApi {
45
45
  };
46
46
  this.test = {
47
47
  request: {
48
- baseURL: '={{$credentials.baseUrl.replace(/\\/+$/, "")}}/api/v1/w/{{$credentials.workspaceId}}',
48
+ baseURL: '={{$credentials.baseUrl.trim().replace(/\\/+$/, "").replace(/\\/api(\\/v1(\\/w(\\/[^/]*)?)?)?$/i, "")}}/api/v1/w/{{$credentials.workspaceId}}',
49
49
  url: '/me',
50
50
  method: 'GET',
51
51
  },
@@ -101,6 +101,12 @@ async function contact(ctx, cache, operation, i) {
101
101
  return updateRecord(ctx, cache, base, locator(ctx, 'contactId', i), i);
102
102
  case 'delete':
103
103
  return deleteRecord(ctx, locator(ctx, 'contactId', i));
104
+ case 'move': {
105
+ const destination = param(ctx, 'destination', i, 'leads');
106
+ const options = param(ctx, 'options', i, {});
107
+ const response = await transport_1.kapacityApiRequest.call(ctx, 'PATCH', `/records/${locator(ctx, 'contactToMove', i)}`, automationsQs(options), { base: destination });
108
+ return present(ctx, cache, destination, response.ligne, options);
109
+ }
104
110
  case 'getAll': {
105
111
  const filters = param(ctx, 'filters', i, {});
106
112
  const conditions = [];
@@ -22,12 +22,32 @@ exports.contactDescription = [
22
22
  { name: 'Delete', value: 'delete', action: 'Delete contact', description: 'Delete a contact permanently' },
23
23
  { name: 'Get', value: 'get', action: 'Get contact', description: 'Retrieve a contact' },
24
24
  { name: 'Get Many', value: 'getAll', action: 'Get many contacts', description: 'Retrieve a list of contacts' },
25
+ {
26
+ name: 'Move',
27
+ value: 'move',
28
+ action: 'Move contact',
29
+ description: 'Move a contact from Setting to Mon Pipe, or back, as the Base menu of its record does',
30
+ },
25
31
  { name: 'Update', value: 'update', action: 'Update contact', description: 'Update the fields of a contact' },
26
32
  ],
27
33
  default: 'create',
28
34
  },
29
- (0, descriptions_1.contactBaseSelect)(show),
35
+ (0, descriptions_1.contactBaseSelect)(on('create', 'upsert', 'get', 'update', 'delete', 'getAll')),
30
36
  (0, descriptions_1.contactLocator)(on('get', 'update', 'delete')),
37
+ (0, descriptions_1.contactLocator)(on('move'), 'contactToMove'),
38
+ {
39
+ displayName: 'Move To',
40
+ name: 'destination',
41
+ type: 'options',
42
+ noDataExpression: true,
43
+ options: [
44
+ { name: 'Mon Pipe', value: 'leads', description: 'The closing pipeline' },
45
+ { name: 'Setting', value: 'leads_setting', description: 'The setting pipeline' },
46
+ ],
47
+ default: 'leads',
48
+ description: 'The base the contact goes to. It stays the same contact, with its appointments, answers and contracts. Its status becomes the default status of that base. A contact moved to Mon Pipe stays visible in Setting, marked as handed over to the closer.',
49
+ displayOptions: { show: on('move') },
50
+ },
31
51
  {
32
52
  displayName: 'E-Mail',
33
53
  name: 'email',
@@ -45,7 +65,7 @@ exports.contactDescription = [
45
65
  noDataExpression: true,
46
66
  default: { mappingMode: 'defineBelow', value: null },
47
67
  required: true,
48
- description: 'A new contact needs at least a first name or a last name. Fields left empty are not changed.',
68
+ description: 'A new contact needs at least a first name, a last name, an email or a phone. Fields left empty are not changed.',
49
69
  typeOptions: {
50
70
  loadOptionsDependsOn: ['base'],
51
71
  resourceMapper: {
@@ -1,5 +1,6 @@
1
1
  import type { IDataObject, IExecuteFunctions, IHookFunctions, IHttpRequestMethods, ILoadOptionsFunctions } from 'n8n-workflow';
2
2
  type Context = IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions;
3
+ export declare function kapacityOrigin(raw: unknown): string;
3
4
  export declare function kapacityApiRequest(this: Context, method: IHttpRequestMethods, path: string, qs?: IDataObject, body?: IDataObject | undefined, headers?: IDataObject): Promise<IDataObject>;
4
5
  export declare function kapacityApiRequestAll(this: IExecuteFunctions | ILoadOptionsFunctions, path: string, listKey: string, qs?: IDataObject, limit?: number): Promise<IDataObject[]>;
5
6
  export {};
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kapacityOrigin = kapacityOrigin;
3
4
  exports.kapacityApiRequest = kapacityApiRequest;
4
5
  exports.kapacityApiRequestAll = kapacityApiRequestAll;
5
6
  const n8n_workflow_1 = require("n8n-workflow");
@@ -19,11 +20,18 @@ const MESSAGES = {
19
20
  disjoncteur: 'Writes to this record are paused: it was changed too often in a few seconds (loop protection)',
20
21
  limite_plan: 'A limit of the workspace plan is reached',
21
22
  api_fermee: 'The API is not open on this workspace yet',
23
+ adresse_de_base: 'The Base URL of the credentials already contains the API path: set it to https://kapacity.app only, the node adds the rest',
24
+ adresse_inconnue: 'This address does not exist in the Kapacity API',
22
25
  };
26
+ function kapacityOrigin(raw) {
27
+ const base = String(raw || 'https://kapacity.app')
28
+ .trim()
29
+ .replace(/\/+$/, '');
30
+ return base.replace(/\/api(\/v1(\/w(\/[^/]*)?)?)?$/i, '') || 'https://kapacity.app';
31
+ }
23
32
  async function baseOf(ctx) {
24
33
  const credentials = await ctx.getCredentials('kapacityApi');
25
- const base = String(credentials.baseUrl || 'https://kapacity.app').replace(/\/+$/, '');
26
- return `${base}/api/v1/w/${String(credentials.workspaceId).trim()}`;
34
+ return `${kapacityOrigin(credentials.baseUrl)}/api/v1/w/${String(credentials.workspaceId).trim()}`;
27
35
  }
28
36
  async function kapacityApiRequest(method, path, qs = {}, body = undefined, headers = {}) {
29
37
  var _a;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-kapacity",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "n8n nodes for Kapacity, the all-in-one sales CRM: contacts, CRM tables, contracts with e-signature, appointments, forms, payments and real-time webhooks.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/kapacity-saas/n8n-nodes-kapacity#readme",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-kapacity",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "n8n nodes for Kapacity, the all-in-one sales CRM: contacts, CRM tables, contracts with e-signature, appointments, forms, payments and real-time webhooks.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/kapacity-saas/n8n-nodes-kapacity#readme",