n8n-nodes-kapacity 0.1.4 → 0.1.6

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
@@ -31,8 +31,8 @@ The package contains two nodes.
31
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
- | Contract | Send (from a template, for e-signature), Get (with its audit trail), Get Many |
35
- | Contract Template | Get Many |
34
+ | Contract | Send (from a template, for e-signature, with other signers if you want), Get (with its audit trail and where each signer stands), Get Many (filter by status: Draft, Sent, Viewed, In Signing, Signed) |
35
+ | Contract Template | Get Many (with the roles that sign each template) |
36
36
  | Appointment | Get Many |
37
37
  | Appointment Type | Get Many |
38
38
  | Form | Get Many |
@@ -50,6 +50,7 @@ What the node does for you, so you never write a request body:
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
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.
53
+ - **Several signers.** **Contract, Send** takes other signers next to the contact (**Signers**: role, name, e-mail; 7 at most). The roles are listed from the chosen template; **No Role** makes the person sign at the end of the contract. Each signer gets their own signing link (in the output, under `signataires`). The contract is **In Signing** once someone has signed, and **Signed** when the last one has.
53
54
 
54
55
  ### Kapacity Trigger
55
56
 
@@ -74,7 +75,7 @@ You need a Kapacity workspace, as an administrator, and an API key. The Kapacity
74
75
  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.
75
76
  3. Click **Créer la clé** and copy the key (it starts with `kap_live_`): it is shown only once.
76
77
  4. Copy the workspace ID shown in the same card (**Identifiant de votre espace**).
77
- 5. In n8n, create a **Kapacity API** credential and paste the key and the workspace ID. Leave **Base URL** as `https://kapacity.app`.
78
+ 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).
78
79
 
79
80
  n8n checks the credential by calling the API: a wrong key or a key from another workspace is reported at once.
80
81
 
@@ -102,6 +103,14 @@ The API has a monthly quota per workspace. Each call counts, so prefer the trigg
102
103
 
103
104
  ## Version history
104
105
 
106
+ ### 0.1.6
107
+
108
+ Contract, Send: other signers next to the contact (role from the template, name, e-mail), each with their own signing link. Contract, Get Many: the **In Signing** status.
109
+
110
+ ### 0.1.5
111
+
112
+ Credentials: a Base URL pasted with the API path (`https://kapacity.app/api/v1/w/<workspace>`) is brought back to the Kapacity address, so lists no longer stay empty without an error.
113
+
105
114
  ### 0.1.4
106
115
 
107
116
  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.
@@ -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
  },
@@ -12,6 +12,7 @@ export declare class Kapacity implements INodeType {
12
12
  };
13
13
  loadOptions: {
14
14
  getContactStatuses(this: import("n8n-workflow").ILoadOptionsFunctions): Promise<import("n8n-workflow").INodePropertyOptions[]>;
15
+ getContractTemplateRoles(this: import("n8n-workflow").ILoadOptionsFunctions): Promise<import("n8n-workflow").INodePropertyOptions[]>;
15
16
  getTableColumns(this: import("n8n-workflow").ILoadOptionsFunctions): Promise<import("n8n-workflow").INodePropertyOptions[]>;
16
17
  };
17
18
  resourceMapping: {
@@ -177,6 +177,24 @@ function filterValue(columns, condition) {
177
177
  }
178
178
  return raw;
179
179
  }
180
+ function signersOf(ctx, i) {
181
+ const lines = param(ctx, 'signers', i, {}).signer;
182
+ return (lines !== null && lines !== void 0 ? lines : []).map((line, n) => {
183
+ var _a, _b, _c;
184
+ const nom = String((_a = line.name) !== null && _a !== void 0 ? _a : '').trim();
185
+ if (!nom) {
186
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `Signer ${n + 1}: the name is required`, { itemIndex: i });
187
+ }
188
+ const signer = { nom };
189
+ const role = String((_b = line.role) !== null && _b !== void 0 ? _b : '').trim();
190
+ if (role)
191
+ signer.role = role;
192
+ const email = String((_c = line.email) !== null && _c !== void 0 ? _c : '').trim();
193
+ if (email)
194
+ signer.email = email;
195
+ return signer;
196
+ });
197
+ }
180
198
  async function contract(ctx, operation, i) {
181
199
  var _a, _b, _c;
182
200
  switch (operation) {
@@ -194,6 +212,9 @@ async function contract(ctx, operation, i) {
194
212
  body.envoyer_email = false;
195
213
  if (more.emailTemplateId)
196
214
  body.message_email_id = String(more.emailTemplateId).trim();
215
+ const signataires = signersOf(ctx, i);
216
+ if (signataires.length)
217
+ body.signataires = signataires;
197
218
  const headers = more.idempotencyKey ? { 'Idempotency-Key': String(more.idempotencyKey) } : {};
198
219
  const response = await transport_1.kapacityApiRequest.call(ctx, 'POST', '/contracts', automationsQs(more), body, headers);
199
220
  const email = (_a = response.email) !== null && _a !== void 0 ? _a : {};
@@ -9,6 +9,7 @@ export declare const listSearch: {
9
9
  };
10
10
  export declare const loadOptions: {
11
11
  getContactStatuses(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
12
+ getContractTemplateRoles(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
12
13
  getTableColumns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
13
14
  };
14
15
  export declare const resourceMapping: {
@@ -84,6 +84,21 @@ exports.loadOptions = {
84
84
  const status = (await columns_1.getColumns.call(this, base)).find((c) => c.id === 'status_id');
85
85
  return ((_b = status === null || status === void 0 ? void 0 : status.options) !== null && _b !== void 0 ? _b : []).map((o) => ({ name: o.libelle, value: o.id }));
86
86
  },
87
+ async getContractTemplateRoles() {
88
+ var _a, _b;
89
+ const noRole = {
90
+ name: 'No Role',
91
+ value: '',
92
+ description: 'The person signs at the end of the contract',
93
+ };
94
+ const templateId = locatorValue(this, 'templateId').trim();
95
+ if (!templateId || templateId.startsWith('='))
96
+ return [noRole];
97
+ const response = await transport_1.kapacityApiRequest.call(this, 'GET', '/contract-templates');
98
+ const template = ((_a = response.modeles) !== null && _a !== void 0 ? _a : []).find((t) => String(t.id) === templateId);
99
+ const roles = ((_b = template === null || template === void 0 ? void 0 : template.roles) !== null && _b !== void 0 ? _b : []).filter((r) => r.id !== 'client' && r.signature_posee !== true);
100
+ return [noRole, ...roles.map((r) => { var _a; return ({ name: String((_a = r.libelle) !== null && _a !== void 0 ? _a : r.id), value: String(r.id) }); })];
101
+ },
87
102
  async getTableColumns() {
88
103
  const table = locatorValue(this, 'table');
89
104
  if (!table)
@@ -1,6 +1,11 @@
1
1
  import type { INodeProperties } from 'n8n-workflow';
2
- export declare const CONTRACT_STATUSES: {
2
+ export declare const CONTRACT_STATUSES: ({
3
3
  name: string;
4
4
  value: string;
5
- }[];
5
+ description?: undefined;
6
+ } | {
7
+ name: string;
8
+ value: string;
9
+ description: string;
10
+ })[];
6
11
  export declare const contractDescription: INodeProperties[];
@@ -8,6 +8,7 @@ exports.CONTRACT_STATUSES = [
8
8
  { name: 'Draft', value: 'brouillon' },
9
9
  { name: 'Sent', value: 'envoye' },
10
10
  { name: 'Viewed', value: 'vu' },
11
+ { name: 'In Signing', value: 'en_cours', description: 'At least one signer has signed, not all of them yet' },
11
12
  { name: 'Signed', value: 'signe' },
12
13
  ];
13
14
  exports.contractDescription = [
@@ -47,6 +48,49 @@ exports.contractDescription = [
47
48
  description: 'The contract amount, written in the contract in place of {{montant}}',
48
49
  displayOptions: { show: on('send') },
49
50
  },
51
+ {
52
+ displayName: 'Signers',
53
+ name: 'signers',
54
+ type: 'fixedCollection',
55
+ typeOptions: { multipleValues: true },
56
+ placeholder: 'Add Signer',
57
+ default: {},
58
+ description: 'Other people who sign the contract with the contact (7 at most). The contact always signs, as the Client. A role of the template that you do not give here is removed from this contract. Each signer gets their own signing link, by e-mail if they have an address.',
59
+ displayOptions: { show: on('send') },
60
+ options: [
61
+ {
62
+ displayName: 'Signer',
63
+ name: 'signer',
64
+ values: [
65
+ {
66
+ displayName: 'Role Name or ID',
67
+ name: 'role',
68
+ type: 'options',
69
+ typeOptions: { loadOptionsMethod: 'getContractTemplateRoles', loadOptionsDependsOn: ['templateId.value'] },
70
+ default: '',
71
+ description: 'The role of the template this person signs as. Roles whose signature is already placed in the template are not listed. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
72
+ },
73
+ {
74
+ displayName: 'Name',
75
+ name: 'name',
76
+ type: 'string',
77
+ default: '',
78
+ required: true,
79
+ placeholder: 'e.g. Marc Martin',
80
+ description: 'The full name of the person who signs',
81
+ },
82
+ {
83
+ displayName: 'E-Mail',
84
+ name: 'email',
85
+ type: 'string',
86
+ default: '',
87
+ placeholder: 'e.g. marc@example.com',
88
+ description: 'Where Kapacity e-mails their signing link (not when Send E-Mail is off). Leave empty to send the link yourself: it is in the output, under signataires.',
89
+ },
90
+ ],
91
+ },
92
+ ],
93
+ },
50
94
  {
51
95
  displayName: 'Additional Fields',
52
96
  name: 'additionalFields',
@@ -28,7 +28,7 @@ exports.tableDescription = [
28
28
  ];
29
29
  exports.contractTemplateDescription = [
30
30
  operations('contractTemplate', [
31
- getAll('contract templates', 'Retrieve the contract templates, and whether each one can be sent now'),
31
+ getAll('contract templates', 'Retrieve the contract templates, whether each one can be sent now, and the roles that sign it'),
32
32
  ]),
33
33
  ];
34
34
  exports.appointmentDescription = [
@@ -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.4",
3
+ "version": "0.1.6",
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.4",
3
+ "version": "0.1.6",
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",