@thegraphitelab/n8n-nodes-servicetitan 0.6.0 → 0.7.1
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/nodes/ServiceTitan/ServiceTitanTrigger.node.d.ts +6 -1
- package/dist/nodes/ServiceTitan/ServiceTitanTrigger.node.js +110 -122
- package/dist/nodes/ServiceTitan/ServiceTitanTrigger.node.js.map +1 -1
- package/dist/nodes/ServiceTitan/TglServiceTitan.node.d.ts +8 -6
- package/dist/nodes/ServiceTitan/TglServiceTitan.node.js +10 -8
- package/dist/nodes/ServiceTitan/TglServiceTitan.node.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/nodes/ServiceTitan/triggerResources.d.ts +0 -37
- package/dist/nodes/ServiceTitan/triggerResources.js +0 -39
- package/dist/nodes/ServiceTitan/triggerResources.js.map +0 -1
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import { type INodeExecutionData, type INodeType, type INodeTypeDescription, type IPollFunctions } from 'n8n-workflow';
|
|
1
|
+
import { type ILoadOptionsFunctions, type INodeExecutionData, type INodePropertyOptions, type INodeType, type INodeTypeDescription, type IPollFunctions } from 'n8n-workflow';
|
|
2
2
|
export declare class ServiceTitanTrigger implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
getBusinessUnits(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
4
9
|
poll(this: IPollFunctions): Promise<INodeExecutionData[][] | null>;
|
|
5
10
|
}
|
|
@@ -3,34 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ServiceTitanTrigger = void 0;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const GenericFunctions_1 = require("./GenericFunctions");
|
|
6
|
-
const triggerResources_1 = require("./triggerResources");
|
|
7
6
|
const JOB_STATUSES = ['Scheduled', 'InProgress', 'Hold', 'Completed', 'Canceled'];
|
|
8
|
-
/**
|
|
9
|
-
* Resource dropdown options, derived from the TRIGGER_RESOURCES table.
|
|
10
|
-
*/
|
|
11
|
-
const resourceOptions = triggerResources_1.TRIGGER_RESOURCES.map((r) => ({
|
|
12
|
-
name: r.resourceLabel,
|
|
13
|
-
value: r.resource,
|
|
14
|
-
}));
|
|
15
|
-
/**
|
|
16
|
-
* Event property descriptors — one per resource, gated by displayOptions.show.resource.
|
|
17
|
-
* n8n renders the union of these as a single "Event" field whose option list swaps
|
|
18
|
-
* based on the selected Resource.
|
|
19
|
-
*/
|
|
20
|
-
const eventPropertyDefinitions = triggerResources_1.TRIGGER_RESOURCES.map((r) => ({
|
|
21
|
-
displayName: 'Event',
|
|
22
|
-
name: 'event',
|
|
23
|
-
type: 'options',
|
|
24
|
-
noDataExpression: true,
|
|
25
|
-
default: r.events[0]?.event ?? '',
|
|
26
|
-
displayOptions: { show: { resource: [r.resource] } },
|
|
27
|
-
options: r.events.map((e) => ({
|
|
28
|
-
name: e.label,
|
|
29
|
-
value: e.event,
|
|
30
|
-
description: e.description,
|
|
31
|
-
})),
|
|
32
|
-
description: 'ServiceTitan updates modifiedOn for any field change including internal status churn, so expect more fires than human-meaningful changes — filter downstream',
|
|
33
|
-
}));
|
|
34
7
|
class ServiceTitanTrigger {
|
|
35
8
|
description = {
|
|
36
9
|
displayName: 'ServiceTitan Trigger',
|
|
@@ -41,7 +14,7 @@ class ServiceTitanTrigger {
|
|
|
41
14
|
},
|
|
42
15
|
group: ['trigger'],
|
|
43
16
|
version: 1,
|
|
44
|
-
description: '
|
|
17
|
+
description: 'Fires for new ServiceTitan jobs',
|
|
45
18
|
subtitle: '={{$parameter.resource}}: {{$parameter.event}}',
|
|
46
19
|
defaults: {
|
|
47
20
|
name: 'ServiceTitan Trigger',
|
|
@@ -63,12 +36,24 @@ class ServiceTitanTrigger {
|
|
|
63
36
|
type: 'options',
|
|
64
37
|
noDataExpression: true,
|
|
65
38
|
default: 'job',
|
|
66
|
-
options:
|
|
39
|
+
options: [{ name: 'Job', value: 'job' }],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Event',
|
|
43
|
+
name: 'event',
|
|
44
|
+
type: 'options',
|
|
45
|
+
noDataExpression: true,
|
|
46
|
+
default: 'newJob',
|
|
47
|
+
displayOptions: { show: { resource: ['job'] } },
|
|
48
|
+
options: [
|
|
49
|
+
{
|
|
50
|
+
name: 'New Job',
|
|
51
|
+
value: 'newJob',
|
|
52
|
+
description: 'Fires for each new job created in ServiceTitan (mirrors the Zapier query_jobs trigger: latest 100 per poll, dedup by job ID)',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
67
55
|
},
|
|
68
|
-
...eventPropertyDefinitions,
|
|
69
56
|
{
|
|
70
|
-
// Job-specific filters. Gated on resource='job' so we can add other
|
|
71
|
-
// resources' filter collections side-by-side later.
|
|
72
57
|
displayName: 'Filters',
|
|
73
58
|
name: 'filters',
|
|
74
59
|
type: 'collection',
|
|
@@ -77,11 +62,19 @@ class ServiceTitanTrigger {
|
|
|
77
62
|
displayOptions: { show: { resource: ['job'] } },
|
|
78
63
|
options: [
|
|
79
64
|
{
|
|
80
|
-
displayName: 'Business Unit ID',
|
|
65
|
+
displayName: 'Business Unit Name or ID',
|
|
81
66
|
name: 'businessUnitId',
|
|
82
|
-
type: '
|
|
67
|
+
type: 'options',
|
|
68
|
+
typeOptions: { loadOptionsMethod: 'getBusinessUnits' },
|
|
83
69
|
default: '',
|
|
84
|
-
description: '
|
|
70
|
+
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
displayName: 'Created On or After',
|
|
74
|
+
name: 'createdOnOrAfter',
|
|
75
|
+
type: 'dateTime',
|
|
76
|
+
default: '',
|
|
77
|
+
description: 'Only jobs created on or after this date/time',
|
|
85
78
|
},
|
|
86
79
|
{
|
|
87
80
|
displayName: 'Customer ID',
|
|
@@ -94,15 +87,17 @@ class ServiceTitanTrigger {
|
|
|
94
87
|
name: 'includeInactive',
|
|
95
88
|
type: 'boolean',
|
|
96
89
|
default: false,
|
|
97
|
-
description: 'Whether to include soft-deleted jobs
|
|
90
|
+
description: 'Whether to include soft-deleted jobs in the results',
|
|
98
91
|
},
|
|
99
92
|
{
|
|
100
93
|
displayName: 'Job Status',
|
|
101
94
|
name: 'jobStatus',
|
|
102
|
-
type: '
|
|
103
|
-
default:
|
|
104
|
-
options:
|
|
105
|
-
|
|
95
|
+
type: 'options',
|
|
96
|
+
default: '',
|
|
97
|
+
options: [
|
|
98
|
+
{ name: 'Any', value: '' },
|
|
99
|
+
...JOB_STATUSES.map((s) => ({ name: s, value: s })),
|
|
100
|
+
],
|
|
106
101
|
},
|
|
107
102
|
{
|
|
108
103
|
displayName: 'Job Type ID',
|
|
@@ -110,110 +105,103 @@ class ServiceTitanTrigger {
|
|
|
110
105
|
type: 'string',
|
|
111
106
|
default: '',
|
|
112
107
|
},
|
|
108
|
+
{
|
|
109
|
+
displayName: 'Modified Before',
|
|
110
|
+
name: 'modifiedBefore',
|
|
111
|
+
type: 'dateTime',
|
|
112
|
+
default: '',
|
|
113
|
+
description: 'Only jobs whose modifiedOn is before this date/time',
|
|
114
|
+
},
|
|
113
115
|
],
|
|
114
116
|
},
|
|
115
117
|
],
|
|
116
118
|
};
|
|
119
|
+
methods = {
|
|
120
|
+
loadOptions: {
|
|
121
|
+
async getBusinessUnits() {
|
|
122
|
+
const credentials = await this.getCredentials('serviceTitanApi');
|
|
123
|
+
const tenantId = credentials.tenantId;
|
|
124
|
+
const response = (await GenericFunctions_1.serviceTitanApiRequest.call(this, 'GET', `/settings/v2/tenant/${tenantId}/business-units`, { pageSize: 200, active: true }));
|
|
125
|
+
const rows = Array.isArray(response.data) ? response.data : [];
|
|
126
|
+
return rows
|
|
127
|
+
.map((bu) => ({
|
|
128
|
+
name: bu.name ?? `Business Unit ${bu.id}`,
|
|
129
|
+
value: String(bu.id),
|
|
130
|
+
}))
|
|
131
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
};
|
|
117
135
|
async poll() {
|
|
118
136
|
const credentials = await this.getCredentials('serviceTitanApi');
|
|
119
137
|
const tenantId = credentials.tenantId;
|
|
120
138
|
const staticData = this.getWorkflowStaticData('node');
|
|
121
|
-
//
|
|
139
|
+
// Tenant-swap detection: if the credential's tenant changed, wipe the
|
|
140
|
+
// dedup cursor so we don't reuse another tenant's ID watermark.
|
|
122
141
|
if (staticData.tenantId && staticData.tenantId !== tenantId) {
|
|
123
|
-
delete staticData.
|
|
124
|
-
delete staticData.boundaryIds;
|
|
142
|
+
delete staticData.highestSeenId;
|
|
125
143
|
}
|
|
126
144
|
staticData.tenantId = tenantId;
|
|
127
|
-
const
|
|
128
|
-
//
|
|
129
|
-
const
|
|
130
|
-
const boundaryIds = new Set(staticData.boundaryIds ?? []);
|
|
131
|
-
const resource = this.getNodeParameter('resource', 0);
|
|
132
|
-
const event = this.getNodeParameter('event', 0);
|
|
133
|
-
const eventConfig = (0, triggerResources_1.findTriggerEvent)(resource, event);
|
|
134
|
-
if (!eventConfig) {
|
|
135
|
-
// Unrecognized resource/event pair — silently no-op rather than throw,
|
|
136
|
-
// matching the previous trigger's defensive shape.
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
const path = eventConfig.path.replace('{tenantId}', tenantId);
|
|
140
|
-
const timestampField = eventConfig.timestampField;
|
|
141
|
-
// Resource-specific filter handling. Job is the only one in Phase 1.
|
|
142
|
-
const baseQs = {
|
|
143
|
-
sort: eventConfig.sortField,
|
|
145
|
+
const filters = this.getNodeParameter('filters', 0, {});
|
|
146
|
+
// Mirror the Zapier query_jobs param shape: pageSize=100, active filter, plus user filters.
|
|
147
|
+
const qs = {
|
|
144
148
|
pageSize: 100,
|
|
145
|
-
|
|
149
|
+
active: filters.includeInactive ? 'Any' : 'True',
|
|
146
150
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (filters.businessUnitId)
|
|
161
|
-
baseQs.businessUnitId = filters.businessUnitId;
|
|
162
|
-
if (filters.jobTypeId)
|
|
163
|
-
baseQs.jobTypeId = filters.jobTypeId;
|
|
164
|
-
if (filters.customerId)
|
|
165
|
-
baseQs.customerId = filters.customerId;
|
|
166
|
-
}
|
|
167
|
-
const collected = [];
|
|
168
|
-
let page = 1;
|
|
169
|
-
const maxPages = 50;
|
|
151
|
+
if (filters.businessUnitId)
|
|
152
|
+
qs.businessUnitId = filters.businessUnitId;
|
|
153
|
+
if (filters.createdOnOrAfter)
|
|
154
|
+
qs.createdOnOrAfter = filters.createdOnOrAfter;
|
|
155
|
+
if (filters.customerId)
|
|
156
|
+
qs.customerId = filters.customerId;
|
|
157
|
+
if (filters.jobStatus)
|
|
158
|
+
qs.jobStatus = filters.jobStatus;
|
|
159
|
+
if (filters.jobTypeId)
|
|
160
|
+
qs.jobTypeId = filters.jobTypeId;
|
|
161
|
+
if (filters.modifiedBefore)
|
|
162
|
+
qs.modifiedBefore = filters.modifiedBefore;
|
|
163
|
+
let response;
|
|
170
164
|
try {
|
|
171
|
-
|
|
172
|
-
const response = (await GenericFunctions_1.serviceTitanApiRequest.call(this, 'GET', path, { ...baseQs, page }));
|
|
173
|
-
const rows = Array.isArray(response.data) ? response.data : [];
|
|
174
|
-
for (const row of rows) {
|
|
175
|
-
const id = Number(row.id);
|
|
176
|
-
if (Number.isFinite(id) && boundaryIds.has(id))
|
|
177
|
-
continue;
|
|
178
|
-
// Decision: emit BOTH raw customFields[] AND a flattened
|
|
179
|
-
// customFieldsByName sibling.
|
|
180
|
-
collected.push((0, GenericFunctions_1.flattenCustomFields)(row));
|
|
181
|
-
}
|
|
182
|
-
if (!response.hasMore)
|
|
183
|
-
break;
|
|
184
|
-
page += 1;
|
|
185
|
-
}
|
|
165
|
+
response = (await GenericFunctions_1.serviceTitanApiRequest.call(this, 'GET', `/jpm/v2/tenant/${tenantId}/jobs`, qs));
|
|
186
166
|
}
|
|
187
167
|
catch (error) {
|
|
188
|
-
// Bubble up so n8n's poll runner logs it and retries next tick. We do NOT
|
|
189
|
-
// advance staticData here — same window will be re-polled.
|
|
190
168
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
|
|
191
169
|
}
|
|
192
|
-
|
|
193
|
-
|
|
170
|
+
const rows = Array.isArray(response.data) ? response.data : [];
|
|
171
|
+
const previousHighest = staticData.highestSeenId;
|
|
172
|
+
const maxIdSeen = rows.reduce((m, j) => Math.max(m, Number(j.id) || 0), 0);
|
|
173
|
+
// First activation: seed the cursor at the current highest job ID and emit
|
|
174
|
+
// nothing. Avoids draining the latest 100 jobs into n8n on activation.
|
|
175
|
+
if (previousHighest === undefined) {
|
|
176
|
+
staticData.highestSeenId = maxIdSeen;
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
// Dedup: only jobs with ID > the watermark. ST job IDs are monotonically
|
|
180
|
+
// increasing, so id > watermark === "newer than what we last saw".
|
|
181
|
+
const newJobs = rows
|
|
182
|
+
.filter((j) => Number.isFinite(Number(j.id)) && Number(j.id) > previousHighest)
|
|
183
|
+
.sort((a, b) => Number(a.id) - Number(b.id)); // ascending — older-new before newer-new
|
|
184
|
+
// Manual mode ("Fetch Test Event"): return one sample without burning the
|
|
185
|
+
// watermark. If there are no new jobs, fall back to the most recent one
|
|
186
|
+
// so the user can wire downstream nodes against a real row.
|
|
194
187
|
if (this.getMode() === 'manual') {
|
|
195
|
-
|
|
188
|
+
const sample = newJobs[0] ?? (rows.length > 0
|
|
189
|
+
? [...rows].sort((a, b) => Number(b.id) - Number(a.id))[0]
|
|
190
|
+
: undefined);
|
|
191
|
+
if (!sample)
|
|
196
192
|
return null;
|
|
197
|
-
return [
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
// the new cursor, so the next poll's inclusive lower-bound doesn't
|
|
203
|
-
// duplicate-fire.
|
|
204
|
-
const newBoundary = [];
|
|
205
|
-
for (const row of collected) {
|
|
206
|
-
const ts = row[timestampField];
|
|
207
|
-
if (typeof ts === 'string' && ts === now) {
|
|
208
|
-
const id = Number(row.id);
|
|
209
|
-
if (Number.isFinite(id))
|
|
210
|
-
newBoundary.push(id);
|
|
211
|
-
}
|
|
193
|
+
return [
|
|
194
|
+
this.helpers.returnJsonArray([
|
|
195
|
+
(0, GenericFunctions_1.flattenCustomFields)(sample),
|
|
196
|
+
]),
|
|
197
|
+
];
|
|
212
198
|
}
|
|
213
|
-
|
|
214
|
-
if (collected.length === 0)
|
|
199
|
+
if (newJobs.length === 0)
|
|
215
200
|
return null;
|
|
216
|
-
|
|
201
|
+
// Advance cursor to the highest ID emitted.
|
|
202
|
+
staticData.highestSeenId = Math.max(previousHighest, ...newJobs.map((j) => Number(j.id)));
|
|
203
|
+
const enriched = newJobs.map((j) => (0, GenericFunctions_1.flattenCustomFields)(j));
|
|
204
|
+
return [this.helpers.returnJsonArray(enriched)];
|
|
217
205
|
}
|
|
218
206
|
}
|
|
219
207
|
exports.ServiceTitanTrigger = ServiceTitanTrigger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceTitanTrigger.node.js","sourceRoot":"","sources":["../../../nodes/ServiceTitan/ServiceTitanTrigger.node.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"ServiceTitanTrigger.node.js","sourceRoot":"","sources":["../../../nodes/ServiceTitan/ServiceTitanTrigger.node.ts"],"names":[],"mappings":";;;AAAA,+CAWsB;AAEtB,yDAAiF;AAQjF,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE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5C,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1D,CAAC,CAAC,SAAS,CAAC,CAAC;YACd,IAAI,CAAC,MAAM;gBAAE,OAAO,IAAI,CAAC;YACzB,OAAO;gBACN,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;oBAC5B,IAAA,sCAAmB,EAAC,MAAgC,CAAC;iBACrD,CAAC;aACF,CAAC;QACH,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEtC,4CAA4C;QAC5C,UAAU,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAE1F,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAClC,IAAA,sCAAmB,EAAC,CAA2B,CAAC,CAChD,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;IACjD,CAAC;CACD;AArOD,kDAqOC"}
|
|
@@ -2,12 +2,14 @@ import { type INodeType, type INodeTypeDescription } from 'n8n-workflow';
|
|
|
2
2
|
/**
|
|
3
3
|
* Action node for ServiceTitan.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* n8n
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Naming note: n8n's community-node loader derives the exported class name from
|
|
6
|
+
* the FILE BASENAME, not the n8n manifest path or the `name` field. It does
|
|
7
|
+
* `new require(file)[fileBasename]()`. So this file MUST be named
|
|
8
|
+
* `TglServiceTitan.node.ts` AND export a class named `TglServiceTitan`. The
|
|
9
|
+
* `tgl` prefix is collision-safety against any future official n8n ServiceTitan
|
|
10
|
+
* node. The display name in the n8n UI is "ServiceTitan" — users never see
|
|
11
|
+
* "TglServiceTitan" in the picker.
|
|
10
12
|
*/
|
|
11
|
-
export declare class
|
|
13
|
+
export declare class TglServiceTitan implements INodeType {
|
|
12
14
|
description: INodeTypeDescription;
|
|
13
15
|
}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TglServiceTitan = void 0;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const resources_1 = require("./resources");
|
|
6
6
|
/**
|
|
7
7
|
* Action node for ServiceTitan.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* n8n
|
|
11
|
-
* `
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* Naming note: n8n's community-node loader derives the exported class name from
|
|
10
|
+
* the FILE BASENAME, not the n8n manifest path or the `name` field. It does
|
|
11
|
+
* `new require(file)[fileBasename]()`. So this file MUST be named
|
|
12
|
+
* `TglServiceTitan.node.ts` AND export a class named `TglServiceTitan`. The
|
|
13
|
+
* `tgl` prefix is collision-safety against any future official n8n ServiceTitan
|
|
14
|
+
* node. The display name in the n8n UI is "ServiceTitan" — users never see
|
|
15
|
+
* "TglServiceTitan" in the picker.
|
|
14
16
|
*/
|
|
15
|
-
class
|
|
17
|
+
class TglServiceTitan {
|
|
16
18
|
description = {
|
|
17
19
|
displayName: 'ServiceTitan',
|
|
18
20
|
name: 'tglServiceTitan',
|
|
@@ -57,5 +59,5 @@ class ServiceTitan {
|
|
|
57
59
|
],
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
|
-
exports.
|
|
62
|
+
exports.TglServiceTitan = TglServiceTitan;
|
|
61
63
|
//# sourceMappingURL=TglServiceTitan.node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TglServiceTitan.node.js","sourceRoot":"","sources":["../../../nodes/ServiceTitan/TglServiceTitan.node.ts"],"names":[],"mappings":";;;AAAA,+CAIsB;AAEtB,2CAAkE;AAElE
|
|
1
|
+
{"version":3,"file":"TglServiceTitan.node.js","sourceRoot":"","sources":["../../../nodes/ServiceTitan/TglServiceTitan.node.ts"],"names":[],"mappings":";;;AAAA,+CAIsB;AAEtB,2CAAkE;AAElE;;;;;;;;;;GAUG;AACH,MAAa,eAAe;IAC3B,WAAW,GAAyB;QACnC,WAAW,EAAE,cAAc;QAC3B,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE;YACL,KAAK,EAAE,uBAAuB;YAC9B,IAAI,EAAE,4BAA4B;SAClC;QACD,KAAK,EAAE,CAAC,WAAW,CAAC;QACpB,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,oDAAoD;QAC9D,WAAW,EAAE,oCAAoC;QACjD,QAAQ,EAAE;YACT,IAAI,EAAE,cAAc;SACpB;QACD,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;QAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;QACnC,WAAW,EAAE;YACZ;gBACC,IAAI,EAAE,iBAAiB;gBACvB,QAAQ,EAAE,IAAI;aACd;SACD;QACD,eAAe,EAAE;YAChB,OAAO,EACN,oHAAoH;YACrH,OAAO,EAAE;gBACR,cAAc,EAAE,kBAAkB;gBAClC,MAAM,EAAE,kBAAkB;aAC1B;SACD;QACD,UAAU,EAAE;YACX;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,SAAS;gBACf,gBAAgB,EAAE,IAAI;gBACtB,OAAO,EAAE,iCAAqB;gBAC9B,OAAO,EAAE,UAAU;aACnB;YACD,GAAG,wBAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC;YACpD,GAAG,wBAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC;SAChD;KACD,CAAC;CACF;AA7CD,0CA6CC"}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trigger resource/event configuration table.
|
|
3
|
-
*
|
|
4
|
-
* The ServiceTitan trigger uses a two-level Resource → Event picker. This
|
|
5
|
-
* table is the single source of truth for which (resource, event) pairs the
|
|
6
|
-
* trigger supports and how they map to the underlying ST list endpoint.
|
|
7
|
-
*
|
|
8
|
-
* To add a new event in Phase 3, add an entry here and (if needed) gate any
|
|
9
|
-
* resource-specific filters on `resource` via displayOptions in the node.
|
|
10
|
-
*/
|
|
11
|
-
export interface TriggerEventConfig {
|
|
12
|
-
/** Internal event value within the resource (e.g. 'createdOrModified'). */
|
|
13
|
-
event: string;
|
|
14
|
-
/** UI label for the event dropdown. */
|
|
15
|
-
label: string;
|
|
16
|
-
/** UI description shown under the dropdown. */
|
|
17
|
-
description: string;
|
|
18
|
-
/** ServiceTitan list endpoint path. `{tenantId}` is substituted at poll-time. */
|
|
19
|
-
path: string;
|
|
20
|
-
/** Sort parameter to pass to ST (e.g. '+ModifiedOn'). */
|
|
21
|
-
sortField: string;
|
|
22
|
-
/** Field on the row used for boundary-id dedup (e.g. 'modifiedOn'). */
|
|
23
|
-
timestampField: string;
|
|
24
|
-
}
|
|
25
|
-
export interface TriggerResourceConfig {
|
|
26
|
-
/** Internal resource value (e.g. 'job'). */
|
|
27
|
-
resource: string;
|
|
28
|
-
/** UI label for the resource dropdown. */
|
|
29
|
-
resourceLabel: string;
|
|
30
|
-
events: TriggerEventConfig[];
|
|
31
|
-
}
|
|
32
|
-
export declare const TRIGGER_RESOURCES: TriggerResourceConfig[];
|
|
33
|
-
/**
|
|
34
|
-
* Lookup helper — returns the event config for the chosen resource+event, or
|
|
35
|
-
* undefined if the pair isn't recognized.
|
|
36
|
-
*/
|
|
37
|
-
export declare function findTriggerEvent(resource: string, event: string): TriggerEventConfig | undefined;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Trigger resource/event configuration table.
|
|
4
|
-
*
|
|
5
|
-
* The ServiceTitan trigger uses a two-level Resource → Event picker. This
|
|
6
|
-
* table is the single source of truth for which (resource, event) pairs the
|
|
7
|
-
* trigger supports and how they map to the underlying ST list endpoint.
|
|
8
|
-
*
|
|
9
|
-
* To add a new event in Phase 3, add an entry here and (if needed) gate any
|
|
10
|
-
* resource-specific filters on `resource` via displayOptions in the node.
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.TRIGGER_RESOURCES = void 0;
|
|
14
|
-
exports.findTriggerEvent = findTriggerEvent;
|
|
15
|
-
exports.TRIGGER_RESOURCES = [
|
|
16
|
-
{
|
|
17
|
-
resource: 'job',
|
|
18
|
-
resourceLabel: 'Job',
|
|
19
|
-
events: [
|
|
20
|
-
{
|
|
21
|
-
event: 'createdOrModified',
|
|
22
|
-
label: 'Created or Modified',
|
|
23
|
-
description: 'Fires for any job whose modifiedOn has advanced since the last poll',
|
|
24
|
-
path: '/jpm/v2/tenant/{tenantId}/jobs',
|
|
25
|
-
sortField: '+ModifiedOn',
|
|
26
|
-
timestampField: 'modifiedOn',
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
/**
|
|
32
|
-
* Lookup helper — returns the event config for the chosen resource+event, or
|
|
33
|
-
* undefined if the pair isn't recognized.
|
|
34
|
-
*/
|
|
35
|
-
function findTriggerEvent(resource, event) {
|
|
36
|
-
const r = exports.TRIGGER_RESOURCES.find((entry) => entry.resource === resource);
|
|
37
|
-
return r?.events.find((e) => e.event === event);
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=triggerResources.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"triggerResources.js","sourceRoot":"","sources":["../../../nodes/ServiceTitan/triggerResources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AA+CH,4CAMC;AA5BY,QAAA,iBAAiB,GAA4B;IACzD;QACC,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,KAAK;QACpB,MAAM,EAAE;YACP;gBACC,KAAK,EAAE,mBAAmB;gBAC1B,KAAK,EAAE,qBAAqB;gBAC5B,WAAW,EACV,qEAAqE;gBACtE,IAAI,EAAE,gCAAgC;gBACtC,SAAS,EAAE,aAAa;gBACxB,cAAc,EAAE,YAAY;aAC5B;SACD;KACD;CACD,CAAC;AAEF;;;GAGG;AACH,SAAgB,gBAAgB,CAC/B,QAAgB,EAChB,KAAa;IAEb,MAAM,CAAC,GAAG,yBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;AACjD,CAAC"}
|