@hobokengrace/n8n-nodes-pco 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/LICENSE.md +21 -0
- package/README.md +79 -0
- package/dist/credentials/PlanningCenterPatApi.credentials.d.ts +9 -0
- package/dist/credentials/PlanningCenterPatApi.credentials.js +84 -0
- package/dist/credentials/PlanningCenterPatApi.credentials.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/assets/api.svg +4 -0
- package/dist/nodes/assets/calendar.svg +4 -0
- package/dist/nodes/assets/check-ins.svg +4 -0
- package/dist/nodes/assets/current.svg +4 -0
- package/dist/nodes/assets/giving.svg +4 -0
- package/dist/nodes/assets/groups.svg +4 -0
- package/dist/nodes/assets/pco.svg +4 -0
- package/dist/nodes/assets/people.svg +4 -0
- package/dist/nodes/assets/publishing.svg +4 -0
- package/dist/nodes/assets/registrations.svg +4 -0
- package/dist/nodes/assets/services.svg +4 -0
- package/dist/nodes/assets/webhooks.svg +4 -0
- package/dist/nodes/generated/api/PlanningCenterApi.node.d.ts +16 -0
- package/dist/nodes/generated/api/PlanningCenterApi.node.js +745 -0
- package/dist/nodes/generated/api/PlanningCenterApi.node.js.map +1 -0
- package/dist/nodes/generated/api/api.svg +4 -0
- package/dist/nodes/generated/api/pco.svg +4 -0
- package/dist/nodes/generated/calendar/PlanningCenterCalendar.node.d.ts +305 -0
- package/dist/nodes/generated/calendar/PlanningCenterCalendar.node.js +33813 -0
- package/dist/nodes/generated/calendar/PlanningCenterCalendar.node.js.map +1 -0
- package/dist/nodes/generated/calendar/calendar.svg +4 -0
- package/dist/nodes/generated/calendar/pco.svg +4 -0
- package/dist/nodes/generated/check-ins/PlanningCenterCheckIns.node.d.ts +308 -0
- package/dist/nodes/generated/check-ins/PlanningCenterCheckIns.node.js +29142 -0
- package/dist/nodes/generated/check-ins/PlanningCenterCheckIns.node.js.map +1 -0
- package/dist/nodes/generated/check-ins/check-ins.svg +4 -0
- package/dist/nodes/generated/check-ins/pco.svg +4 -0
- package/dist/nodes/generated/current/PlanningCenterCurrent.node.d.ts +13 -0
- package/dist/nodes/generated/current/PlanningCenterCurrent.node.js +564 -0
- package/dist/nodes/generated/current/PlanningCenterCurrent.node.js.map +1 -0
- package/dist/nodes/generated/current/current.svg +4 -0
- package/dist/nodes/generated/current/pco.svg +4 -0
- package/dist/nodes/generated/giving/PlanningCenterGiving.node.d.ts +308 -0
- package/dist/nodes/generated/giving/PlanningCenterGiving.node.js +25566 -0
- package/dist/nodes/generated/giving/PlanningCenterGiving.node.js.map +1 -0
- package/dist/nodes/generated/giving/giving.svg +4 -0
- package/dist/nodes/generated/giving/pco.svg +4 -0
- package/dist/nodes/generated/groups/PlanningCenterGroups.node.d.ts +189 -0
- package/dist/nodes/generated/groups/PlanningCenterGroups.node.js +15344 -0
- package/dist/nodes/generated/groups/PlanningCenterGroups.node.js.map +1 -0
- package/dist/nodes/generated/groups/groups.svg +4 -0
- package/dist/nodes/generated/groups/pco.svg +4 -0
- package/dist/nodes/generated/people/PlanningCenterPeople.node.d.ts +979 -0
- package/dist/nodes/generated/people/PlanningCenterPeople.node.js +102040 -0
- package/dist/nodes/generated/people/PlanningCenterPeople.node.js.map +1 -0
- package/dist/nodes/generated/people/pco.svg +4 -0
- package/dist/nodes/generated/people/people.svg +4 -0
- package/dist/nodes/generated/publishing/PlanningCenterPublishing.node.d.ts +130 -0
- package/dist/nodes/generated/publishing/PlanningCenterPublishing.node.js +10671 -0
- package/dist/nodes/generated/publishing/PlanningCenterPublishing.node.js.map +1 -0
- package/dist/nodes/generated/publishing/pco.svg +4 -0
- package/dist/nodes/generated/publishing/publishing.svg +4 -0
- package/dist/nodes/generated/registrations/PlanningCenterRegistrations.node.d.ts +55 -0
- package/dist/nodes/generated/registrations/PlanningCenterRegistrations.node.js +3640 -0
- package/dist/nodes/generated/registrations/PlanningCenterRegistrations.node.js.map +1 -0
- package/dist/nodes/generated/registrations/pco.svg +4 -0
- package/dist/nodes/generated/registrations/registrations.svg +4 -0
- package/dist/nodes/generated/services/PlanningCenterServices.node.d.ts +1032 -0
- package/dist/nodes/generated/services/PlanningCenterServices.node.js +82196 -0
- package/dist/nodes/generated/services/PlanningCenterServices.node.js.map +1 -0
- package/dist/nodes/generated/services/pco.svg +4 -0
- package/dist/nodes/generated/services/services.svg +4 -0
- package/dist/nodes/generated/webhooks/PlanningCenterWebhooks.node.d.ts +25 -0
- package/dist/nodes/generated/webhooks/PlanningCenterWebhooks.node.js +1346 -0
- package/dist/nodes/generated/webhooks/PlanningCenterWebhooks.node.js.map +1 -0
- package/dist/nodes/generated/webhooks/pco.svg +4 -0
- package/dist/nodes/generated/webhooks/webhooks.svg +4 -0
- package/dist/src/generator/checkGenerated.d.ts +1 -0
- package/dist/src/generator/checkGenerated.js +34 -0
- package/dist/src/generator/checkGenerated.js.map +1 -0
- package/dist/src/generator/config.d.ts +13 -0
- package/dist/src/generator/config.js +114 -0
- package/dist/src/generator/config.js.map +1 -0
- package/dist/src/generator/generate.d.ts +1 -0
- package/dist/src/generator/generate.js +26 -0
- package/dist/src/generator/generate.js.map +1 -0
- package/dist/src/generator/labels.d.ts +3 -0
- package/dist/src/generator/labels.js +23 -0
- package/dist/src/generator/labels.js.map +1 -0
- package/dist/src/generator/model.d.ts +81 -0
- package/dist/src/generator/model.js +3 -0
- package/dist/src/generator/model.js.map +1 -0
- package/dist/src/generator/openapi.d.ts +3 -0
- package/dist/src/generator/openapi.js +667 -0
- package/dist/src/generator/openapi.js.map +1 -0
- package/dist/src/generator/refreshSnapshots.d.ts +1 -0
- package/dist/src/generator/refreshSnapshots.js +28 -0
- package/dist/src/generator/refreshSnapshots.js.map +1 -0
- package/dist/src/generator/render.d.ts +3 -0
- package/dist/src/generator/render.js +580 -0
- package/dist/src/generator/render.js.map +1 -0
- package/dist/src/runtime/execute.d.ts +2 -0
- package/dist/src/runtime/execute.js +25 -0
- package/dist/src/runtime/execute.js.map +1 -0
- package/dist/src/runtime/jsonApi.d.ts +3 -0
- package/dist/src/runtime/jsonApi.js +43 -0
- package/dist/src/runtime/jsonApi.js.map +1 -0
- package/dist/src/runtime/pagination.d.ts +8 -0
- package/dist/src/runtime/pagination.js +68 -0
- package/dist/src/runtime/pagination.js.map +1 -0
- package/dist/src/runtime/request.d.ts +22 -0
- package/dist/src/runtime/request.js +93 -0
- package/dist/src/runtime/request.js.map +1 -0
- package/dist/src/runtime/resourceLocator.d.ts +1 -0
- package/dist/src/runtime/resourceLocator.js +15 -0
- package/dist/src/runtime/resourceLocator.js.map +1 -0
- package/dist/tests/generator.test.d.ts +1 -0
- package/dist/tests/generator.test.js +622 -0
- package/dist/tests/generator.test.js.map +1 -0
- package/dist/tests/metadata.test.d.ts +1 -0
- package/dist/tests/metadata.test.js +124 -0
- package/dist/tests/metadata.test.js.map +1 -0
- package/dist/tests/runtime.test.d.ts +1 -0
- package/dist/tests/runtime.test.js +181 -0
- package/dist/tests/runtime.test.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderNode = renderNode;
|
|
4
|
+
const labels_1 = require("./labels");
|
|
5
|
+
const QUERY_OPTION_GROUPS = [
|
|
6
|
+
{ group: 'filter', displayName: 'Filter', placeholder: 'Filter by' },
|
|
7
|
+
{ group: 'order', displayName: 'Order', placeholder: 'Order by' },
|
|
8
|
+
{ group: 'include', displayName: 'Include', placeholder: 'Include data' },
|
|
9
|
+
];
|
|
10
|
+
function q(value) {
|
|
11
|
+
return JSON.stringify(value);
|
|
12
|
+
}
|
|
13
|
+
function bodyFieldDisplayName(prefix, displayName) {
|
|
14
|
+
return `${prefix}: ${(0, labels_1.normalizeIdentifierDisplayLabel)(displayName)}`;
|
|
15
|
+
}
|
|
16
|
+
function locatorDefault() {
|
|
17
|
+
return q({ mode: 'list', value: '' });
|
|
18
|
+
}
|
|
19
|
+
function locatorModes(lookup) {
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
displayName: 'List',
|
|
23
|
+
name: 'list',
|
|
24
|
+
type: 'list',
|
|
25
|
+
typeOptions: {
|
|
26
|
+
searchListMethod: lookup.methodName,
|
|
27
|
+
searchable: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
displayName: 'ID',
|
|
32
|
+
name: 'id',
|
|
33
|
+
type: 'string',
|
|
34
|
+
placeholder: 'e.g. 12345',
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
function fieldProperty(field, operation, source) {
|
|
39
|
+
const displayOptions = {
|
|
40
|
+
show: {
|
|
41
|
+
resource: [operation.resource],
|
|
42
|
+
operation: [operation.id],
|
|
43
|
+
...(source === 'attribute' ? { bodyMode: ['fields'] } : {}),
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
return ` {
|
|
47
|
+
displayName: ${q(source === 'attribute' ? bodyFieldDisplayName('Attribute', field.displayName) : field.displayName)},
|
|
48
|
+
name: ${q(`${operation.id}_${field.name}`)},
|
|
49
|
+
type: ${q(field.lookup ? 'resourceLocator' : field.type)},
|
|
50
|
+
default: ${field.lookup ? locatorDefault() : field.type === 'number' ? 'undefined' : field.type === 'boolean' ? 'false' : "''"},
|
|
51
|
+
required: ${field.required},
|
|
52
|
+
${field.lookup ? `modes: ${q(locatorModes(field.lookup))},\n ` : ''}displayOptions: ${q(displayOptions)},
|
|
53
|
+
},`;
|
|
54
|
+
}
|
|
55
|
+
function renderOperations(operations) {
|
|
56
|
+
const runtimeOperations = operations.map(({ lookupQueryParameterNames: _lookupQueryParameterNames, ...operation }) => ({
|
|
57
|
+
...operation,
|
|
58
|
+
queryParameters: operation.queryParameters.map(({ valueOptions: _valueOptions, ...parameter }) => parameter),
|
|
59
|
+
queryOptions: operation.queryOptions.map(({ valueOptions: _valueOptions, ...option }) => option),
|
|
60
|
+
}));
|
|
61
|
+
return JSON.stringify(runtimeOperations, null, 2);
|
|
62
|
+
}
|
|
63
|
+
function renderOperationSubtitle(operations) {
|
|
64
|
+
const descriptions = Object.fromEntries(operations.map((operation) => [operation.id, operation.description]));
|
|
65
|
+
return `={{(${JSON.stringify(descriptions)})[$parameter["operation"]] || $parameter["operation"]}}`;
|
|
66
|
+
}
|
|
67
|
+
function renderQueryOptionValues(option) {
|
|
68
|
+
return [
|
|
69
|
+
...(option.kind === 'operator'
|
|
70
|
+
? [
|
|
71
|
+
{
|
|
72
|
+
displayName: 'Operator',
|
|
73
|
+
name: 'operator',
|
|
74
|
+
type: 'options',
|
|
75
|
+
options: option.operators?.map((operator) => ({ name: operator.name, value: operator.value })) ?? [],
|
|
76
|
+
default: option.operators?.[0]?.value ?? '',
|
|
77
|
+
},
|
|
78
|
+
]
|
|
79
|
+
: []),
|
|
80
|
+
{
|
|
81
|
+
displayName: 'Value',
|
|
82
|
+
name: 'value',
|
|
83
|
+
type: option.lookup ? 'resourceLocator' : option.valueOptions?.length ? 'options' : option.type,
|
|
84
|
+
...(option.valueOptions?.length ? { options: option.valueOptions } : {}),
|
|
85
|
+
...(option.lookup ? { modes: locatorModes(option.lookup) } : {}),
|
|
86
|
+
default: option.lookup ? { mode: 'list', value: '' } : option.valueOptions?.length ? '' : option.type === 'number' ? undefined : option.type === 'boolean' ? false : '',
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
function operationLookups(operations) {
|
|
91
|
+
const lookups = new Map();
|
|
92
|
+
for (const operation of operations) {
|
|
93
|
+
for (const field of operation.pathParameters)
|
|
94
|
+
if (field.lookup)
|
|
95
|
+
lookups.set(field.lookup.methodName, field.lookup);
|
|
96
|
+
for (const option of operation.queryOptions)
|
|
97
|
+
if (option.lookup)
|
|
98
|
+
lookups.set(option.lookup.methodName, option.lookup);
|
|
99
|
+
for (const field of operation.attributeFields)
|
|
100
|
+
if (field.lookup)
|
|
101
|
+
lookups.set(field.lookup.methodName, field.lookup);
|
|
102
|
+
for (const field of operation.relationshipFields)
|
|
103
|
+
if (field.lookup)
|
|
104
|
+
lookups.set(field.lookup.methodName, field.lookup);
|
|
105
|
+
}
|
|
106
|
+
return [...lookups.values()].sort((a, b) => a.methodName.localeCompare(b.methodName));
|
|
107
|
+
}
|
|
108
|
+
function renderLookupSources(operations) {
|
|
109
|
+
const sources = Object.fromEntries(operationLookups(operations).map((lookup) => [lookup.methodName, lookup]));
|
|
110
|
+
return JSON.stringify(sources, null, 2);
|
|
111
|
+
}
|
|
112
|
+
function renderListSearchMethods(operations) {
|
|
113
|
+
const lookups = operationLookups(operations);
|
|
114
|
+
if (!lookups.length)
|
|
115
|
+
return '{}';
|
|
116
|
+
return `{
|
|
117
|
+
${lookups.map((lookup) => ` ${lookup.methodName}: async function(this: ILoadOptionsFunctions, filter?: string): Promise<INodeListSearchResult> {
|
|
118
|
+
return searchLookup(this, LOOKUP_SOURCES[${q(lookup.methodName)}], filter);
|
|
119
|
+
},`).join('\n')}
|
|
120
|
+
}`;
|
|
121
|
+
}
|
|
122
|
+
function renderQueryOptionsProperty(operation, definition) {
|
|
123
|
+
const groupOptions = operation.queryOptions.filter((option) => option.group === definition.group);
|
|
124
|
+
if (!groupOptions.length)
|
|
125
|
+
return undefined;
|
|
126
|
+
const displayOptions = { show: { resource: [operation.resource], operation: [operation.id] } };
|
|
127
|
+
const options = groupOptions.map((option) => ({
|
|
128
|
+
displayName: option.displayName,
|
|
129
|
+
name: option.name,
|
|
130
|
+
values: renderQueryOptionValues(option),
|
|
131
|
+
}));
|
|
132
|
+
return ` {
|
|
133
|
+
displayName: ${q(definition.displayName)},
|
|
134
|
+
name: ${q(`${operation.id}_${definition.group}`)},
|
|
135
|
+
type: 'fixedCollection',
|
|
136
|
+
default: {},
|
|
137
|
+
placeholder: ${q(definition.placeholder)},
|
|
138
|
+
typeOptions: { multipleValues: true },
|
|
139
|
+
displayOptions: ${q(displayOptions)},
|
|
140
|
+
options: ${q(options)},
|
|
141
|
+
},`;
|
|
142
|
+
}
|
|
143
|
+
function renderProperties(operations) {
|
|
144
|
+
const resources = [...new Set(operations.map((operation) => operation.resource))].sort();
|
|
145
|
+
const resourceOptions = resources.map((resource) => ({ name: resource, value: resource }));
|
|
146
|
+
const operationOptionsByResource = resources.map((resource) => {
|
|
147
|
+
const options = operations
|
|
148
|
+
.filter((operation) => operation.resource === resource)
|
|
149
|
+
.map((operation) => ({
|
|
150
|
+
name: operation.operation,
|
|
151
|
+
value: operation.id,
|
|
152
|
+
description: operation.description,
|
|
153
|
+
action: operation.operation,
|
|
154
|
+
}));
|
|
155
|
+
return ` {
|
|
156
|
+
displayName: 'Operation',
|
|
157
|
+
name: 'operation',
|
|
158
|
+
type: 'options',
|
|
159
|
+
noDataExpression: true,
|
|
160
|
+
displayOptions: ${q({ show: { resource: [resource] } })},
|
|
161
|
+
options: ${q(options)},
|
|
162
|
+
default: ${q(options[0]?.value ?? '')},
|
|
163
|
+
},`;
|
|
164
|
+
});
|
|
165
|
+
const extraFields = operations.flatMap((operation) => {
|
|
166
|
+
const displayOptions = { show: { resource: [operation.resource], operation: [operation.id] } };
|
|
167
|
+
const fields = [
|
|
168
|
+
...operation.pathParameters.map((field) => fieldProperty(field, operation, 'path')),
|
|
169
|
+
];
|
|
170
|
+
fields.push(...QUERY_OPTION_GROUPS.flatMap((definition) => renderQueryOptionsProperty(operation, definition) ?? []));
|
|
171
|
+
if (operation.isList) {
|
|
172
|
+
fields.push(` {
|
|
173
|
+
displayName: 'Return All',
|
|
174
|
+
name: ${q(`${operation.id}_returnAll`)},
|
|
175
|
+
type: 'boolean',
|
|
176
|
+
default: false,
|
|
177
|
+
displayOptions: ${q(displayOptions)},
|
|
178
|
+
},`);
|
|
179
|
+
fields.push(` {
|
|
180
|
+
displayName: 'Limit',
|
|
181
|
+
name: ${q(`${operation.id}_limit`)},
|
|
182
|
+
type: 'number',
|
|
183
|
+
default: 100,
|
|
184
|
+
typeOptions: { minValue: 1 },
|
|
185
|
+
displayOptions: ${q({ show: { resource: [operation.resource], operation: [operation.id], [`${operation.id}_returnAll`]: [false] } })},
|
|
186
|
+
},`);
|
|
187
|
+
}
|
|
188
|
+
if (operation.attributeFields.length || operation.relationshipFields.length || ['POST', 'PUT', 'PATCH'].includes(operation.method)) {
|
|
189
|
+
fields.push(` {
|
|
190
|
+
displayName: 'Body Mode',
|
|
191
|
+
name: 'bodyMode',
|
|
192
|
+
type: 'options',
|
|
193
|
+
options: ${q([{ name: 'Fields', value: 'fields' }, { name: 'Raw JSON', value: 'rawJson' }])},
|
|
194
|
+
default: 'fields',
|
|
195
|
+
displayOptions: ${q(displayOptions)},
|
|
196
|
+
},`);
|
|
197
|
+
fields.push(...operation.attributeFields.map((field) => fieldProperty(field, operation, 'attribute')));
|
|
198
|
+
for (const relationship of operation.relationshipFields) {
|
|
199
|
+
fields.push(` {
|
|
200
|
+
displayName: ${q(bodyFieldDisplayName('Relationship', relationship.displayName))},
|
|
201
|
+
name: ${q(`${operation.id}_${relationship.name}`)},
|
|
202
|
+
type: ${q(relationship.lookup ? 'resourceLocator' : 'string')},
|
|
203
|
+
default: ${relationship.lookup ? locatorDefault() : "''"},
|
|
204
|
+
${relationship.lookup ? `modes: ${q(locatorModes(relationship.lookup))},\n ` : ''}description: ${q(relationship.multiple ? 'Comma-separated relationship IDs.' : 'Relationship ID.')},
|
|
205
|
+
displayOptions: ${q({ show: { resource: [operation.resource], operation: [operation.id], bodyMode: ['fields'] } })},
|
|
206
|
+
},`);
|
|
207
|
+
}
|
|
208
|
+
fields.push(` {
|
|
209
|
+
displayName: 'Raw JSON Body',
|
|
210
|
+
name: 'rawJsonBody',
|
|
211
|
+
type: 'json',
|
|
212
|
+
default: '{}',
|
|
213
|
+
displayOptions: ${q({ show: { resource: [operation.resource], operation: [operation.id], bodyMode: ['rawJson'] } })},
|
|
214
|
+
},`);
|
|
215
|
+
}
|
|
216
|
+
fields.push(` {
|
|
217
|
+
displayName: 'Additional Query Parameters',
|
|
218
|
+
name: 'additionalQueryParameters',
|
|
219
|
+
type: 'fixedCollection',
|
|
220
|
+
default: {},
|
|
221
|
+
placeholder: 'Add Parameter',
|
|
222
|
+
typeOptions: { multipleValues: true },
|
|
223
|
+
displayOptions: ${q(displayOptions)},
|
|
224
|
+
options: [{
|
|
225
|
+
displayName: 'Parameter',
|
|
226
|
+
name: 'parameters',
|
|
227
|
+
values: [
|
|
228
|
+
{ displayName: 'Name', name: 'name', type: 'string', default: '' },
|
|
229
|
+
{ displayName: 'Value', name: 'value', type: 'string', default: '' },
|
|
230
|
+
],
|
|
231
|
+
}],
|
|
232
|
+
},`);
|
|
233
|
+
return fields;
|
|
234
|
+
});
|
|
235
|
+
return `[
|
|
236
|
+
{
|
|
237
|
+
displayName: 'Resource',
|
|
238
|
+
name: 'resource',
|
|
239
|
+
type: 'options',
|
|
240
|
+
noDataExpression: true,
|
|
241
|
+
options: ${q(resourceOptions)},
|
|
242
|
+
default: ${q(resourceOptions[0]?.value ?? '')},
|
|
243
|
+
},
|
|
244
|
+
${operationOptionsByResource.join('\n')}
|
|
245
|
+
${extraFields.join('\n')}
|
|
246
|
+
]`;
|
|
247
|
+
}
|
|
248
|
+
function renderNode(config, result) {
|
|
249
|
+
return `import type { IDataObject, IExecuteFunctions, IHttpRequestMethods, ILoadOptionsFunctions, INodeExecutionData, INodeListSearchResult, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
250
|
+
|
|
251
|
+
import { executeItemWithContinueOnFail } from '../../../src/runtime/execute';
|
|
252
|
+
import { normalizeJsonApiResponse } from '../../../src/runtime/jsonApi';
|
|
253
|
+
import { collectPaginatedPlanningCenterResults } from '../../../src/runtime/pagination';
|
|
254
|
+
import { planningCenterApiRequest } from '../../../src/runtime/request';
|
|
255
|
+
import { extractResourceLocatorId } from '../../../src/runtime/resourceLocator';
|
|
256
|
+
|
|
257
|
+
interface GeneratedLookupParentBinding {
|
|
258
|
+
sourceName: string;
|
|
259
|
+
fieldName: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface GeneratedLookupSplitNameSearch {
|
|
263
|
+
firstNameFilter: string;
|
|
264
|
+
lastNameFilter: string;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
interface GeneratedLookup {
|
|
268
|
+
methodName: string;
|
|
269
|
+
sourcePath: string;
|
|
270
|
+
parentBindings: GeneratedLookupParentBinding[];
|
|
271
|
+
searchFilter?: string;
|
|
272
|
+
splitNameSearch?: GeneratedLookupSplitNameSearch;
|
|
273
|
+
labelFields: string[];
|
|
274
|
+
resultLimit: number;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
interface GeneratedField {
|
|
278
|
+
name: string;
|
|
279
|
+
sourceName: string;
|
|
280
|
+
displayName: string;
|
|
281
|
+
required: boolean;
|
|
282
|
+
type: 'boolean' | 'number' | 'string';
|
|
283
|
+
lookup?: GeneratedLookup;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
interface GeneratedQueryOptionOperator {
|
|
287
|
+
name: string;
|
|
288
|
+
value: string;
|
|
289
|
+
sourceName: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
interface GeneratedQueryOption {
|
|
293
|
+
name: string;
|
|
294
|
+
displayName: string;
|
|
295
|
+
group: 'filter' | 'order' | 'include';
|
|
296
|
+
type: 'boolean' | 'number' | 'string';
|
|
297
|
+
kind: 'single' | 'operator';
|
|
298
|
+
sourceName?: string;
|
|
299
|
+
operators?: GeneratedQueryOptionOperator[];
|
|
300
|
+
lookup?: GeneratedLookup;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
interface QueryOptionSelection {
|
|
304
|
+
operator?: string;
|
|
305
|
+
value?: unknown;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
interface GeneratedRelationshipField {
|
|
309
|
+
name: string;
|
|
310
|
+
displayName: string;
|
|
311
|
+
relationshipName: string;
|
|
312
|
+
relationshipType: string;
|
|
313
|
+
multiple: boolean;
|
|
314
|
+
lookup?: GeneratedLookup;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
interface Operation {
|
|
318
|
+
id: string;
|
|
319
|
+
resource: string;
|
|
320
|
+
operation: string;
|
|
321
|
+
description: string;
|
|
322
|
+
method: IHttpRequestMethods;
|
|
323
|
+
path: string;
|
|
324
|
+
deprecated: boolean;
|
|
325
|
+
isList: boolean;
|
|
326
|
+
lookupTarget: string;
|
|
327
|
+
pathParameters: GeneratedField[];
|
|
328
|
+
queryParameters: GeneratedField[];
|
|
329
|
+
queryOptions: GeneratedQueryOption[];
|
|
330
|
+
attributeFields: GeneratedField[];
|
|
331
|
+
relationshipFields: GeneratedRelationshipField[];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const OPERATIONS: Operation[] = ${renderOperations(result.operations)};
|
|
335
|
+
|
|
336
|
+
const LOOKUP_SOURCES: Record<string, GeneratedLookup> = ${renderLookupSources(result.operations)};
|
|
337
|
+
|
|
338
|
+
const NODE_PROPERTIES = Function('return ' + ${q(renderProperties(result.operations))})() as any;
|
|
339
|
+
|
|
340
|
+
function lookupResultName(item: any, lookup: GeneratedLookup): string {
|
|
341
|
+
const id = item?.id === undefined || item?.id === null ? '' : String(item.id);
|
|
342
|
+
const attributes = item?.attributes && typeof item.attributes === 'object' ? item.attributes as Record<string, unknown> : {};
|
|
343
|
+
const display = lookup.labelFields
|
|
344
|
+
.map((field) => {
|
|
345
|
+
const values = field.split(' ').map((part) => attributes[part]);
|
|
346
|
+
if (values.some((value) => typeof value !== 'string' || !value.trim())) return '';
|
|
347
|
+
return values.map((value) => String(value).trim()).join(' ');
|
|
348
|
+
})
|
|
349
|
+
.find((value) => value.trim());
|
|
350
|
+
|
|
351
|
+
return display ? String(display) + ' (' + id + ')' : id;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function lookupPath(context: ILoadOptionsFunctions, lookup: GeneratedLookup): string | undefined {
|
|
355
|
+
let path = lookup.sourcePath;
|
|
356
|
+
for (const binding of lookup.parentBindings) {
|
|
357
|
+
const id = extractResourceLocatorId(context.getNodeParameter(binding.fieldName, ''));
|
|
358
|
+
if (!id) return undefined;
|
|
359
|
+
path = path.replace('{' + binding.sourceName + '}', encodeURIComponent(id));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return path;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
async function requestLookup(context: ILoadOptionsFunctions, path: string, qs: IDataObject): Promise<any[]> {
|
|
366
|
+
const response = await planningCenterApiRequest.call(context as unknown as IExecuteFunctions, { method: 'GET', path, qs });
|
|
367
|
+
return Array.isArray((response as any)?.data) ? (response as any).data : [];
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function lookupResults(dataSets: any[][], lookup: GeneratedLookup): INodeListSearchResult {
|
|
371
|
+
const seen = new Set<string>();
|
|
372
|
+
const results: INodeListSearchResult['results'] = [];
|
|
373
|
+
|
|
374
|
+
for (const data of dataSets) {
|
|
375
|
+
for (const item of data) {
|
|
376
|
+
const value = item?.id === undefined || item?.id === null ? '' : String(item.id);
|
|
377
|
+
if (!value || seen.has(value)) continue;
|
|
378
|
+
seen.add(value);
|
|
379
|
+
results.push({ name: lookupResultName(item, lookup), value });
|
|
380
|
+
if (results.length >= lookup.resultLimit) return { results };
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return { results };
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function splitNameRequests(lookup: GeneratedLookup, filter: string): IDataObject[] {
|
|
388
|
+
const terms = filter.trim().split(/\\s+/).filter(Boolean);
|
|
389
|
+
const splitNameSearch = lookup.splitNameSearch;
|
|
390
|
+
if (!terms.length || !splitNameSearch) return [];
|
|
391
|
+
|
|
392
|
+
return [
|
|
393
|
+
{ per_page: lookup.resultLimit, [splitNameSearch.firstNameFilter]: terms[0] },
|
|
394
|
+
{ per_page: lookup.resultLimit, [splitNameSearch.lastNameFilter]: terms[terms.length - 1] },
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
async function searchLookup(context: ILoadOptionsFunctions, lookup: GeneratedLookup, filter?: string): Promise<INodeListSearchResult> {
|
|
399
|
+
const path = lookupPath(context, lookup);
|
|
400
|
+
if (!path) return { results: [] };
|
|
401
|
+
|
|
402
|
+
const trimmedFilter = filter?.trim() ?? '';
|
|
403
|
+
let requests: IDataObject[] = [{ per_page: lookup.resultLimit }];
|
|
404
|
+
if (trimmedFilter && lookup.searchFilter) {
|
|
405
|
+
requests = [{ per_page: lookup.resultLimit, [lookup.searchFilter]: trimmedFilter }];
|
|
406
|
+
} else if (trimmedFilter && lookup.splitNameSearch) {
|
|
407
|
+
requests = splitNameRequests(lookup, trimmedFilter);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
const dataSets = await Promise.all(requests.map((qs) => requestLookup(context, path, qs)));
|
|
411
|
+
return lookupResults(dataSets, lookup);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function addAdditionalQuery(context: IExecuteFunctions, itemIndex: number, operation: Operation, qs: Record<string, unknown>): void {
|
|
415
|
+
const additional = context.getNodeParameter('additionalQueryParameters', itemIndex, {}) as { parameters?: Array<{ name?: string; value?: unknown }> };
|
|
416
|
+
for (const parameter of additional.parameters ?? []) {
|
|
417
|
+
if (parameter.name) {
|
|
418
|
+
qs[parameter.name] = parameter.value;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function queryOptionSelections(
|
|
424
|
+
groupOptions: Record<string, QueryOptionSelection | QueryOptionSelection[] | undefined>,
|
|
425
|
+
optionName: string,
|
|
426
|
+
): QueryOptionSelection[] {
|
|
427
|
+
const selected = groupOptions[optionName];
|
|
428
|
+
if (Array.isArray(selected)) return selected;
|
|
429
|
+
return selected ? [selected] : [];
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function addQueryStringValue(qs: Record<string, unknown>, sourceName: string, value: unknown): void {
|
|
433
|
+
if (qs[sourceName] === undefined) {
|
|
434
|
+
qs[sourceName] = value;
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
qs[sourceName] = String(qs[sourceName]) + ',' + String(value);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function addQueryOptions(context: IExecuteFunctions, itemIndex: number, operation: Operation, qs: Record<string, unknown>): void {
|
|
442
|
+
for (const option of operation.queryOptions) {
|
|
443
|
+
const options = context.getNodeParameter(\`${'${operation.id}'}_${'${option.group}'}\`, itemIndex, {}) as Record<string, QueryOptionSelection | QueryOptionSelection[] | undefined>;
|
|
444
|
+
for (const selected of queryOptionSelections(options, option.name)) {
|
|
445
|
+
const value = option.lookup ? extractResourceLocatorId(selected.value) : selected.value;
|
|
446
|
+
if (value === undefined || value === '') continue;
|
|
447
|
+
|
|
448
|
+
if (option.kind === 'operator') {
|
|
449
|
+
const operator = option.operators?.find((candidate) => candidate.value === selected.operator) ?? option.operators?.[0];
|
|
450
|
+
if (operator) addQueryStringValue(qs, operator.sourceName, value);
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (option.sourceName) {
|
|
455
|
+
addQueryStringValue(qs, option.sourceName, value);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function buildBody(context: IExecuteFunctions, itemIndex: number, operation: Operation): unknown {
|
|
462
|
+
if (!['POST', 'PUT', 'PATCH'].includes(operation.method)) return undefined;
|
|
463
|
+
|
|
464
|
+
const bodyMode = context.getNodeParameter('bodyMode', itemIndex, 'fields') as string;
|
|
465
|
+
if (bodyMode === 'rawJson') {
|
|
466
|
+
return JSON.parse(context.getNodeParameter('rawJsonBody', itemIndex, '{}') as string);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const attributes: Record<string, unknown> = {};
|
|
470
|
+
for (const field of operation.attributeFields) {
|
|
471
|
+
const value = field.required
|
|
472
|
+
? context.getNodeParameter(\`${'${operation.id}'}_\${field.name}\`, itemIndex)
|
|
473
|
+
: context.getNodeParameter(\`${'${operation.id}'}_\${field.name}\`, itemIndex, '');
|
|
474
|
+
const attributeValue = field.lookup ? extractResourceLocatorId(value) : value;
|
|
475
|
+
if (attributeValue !== undefined && attributeValue !== '') {
|
|
476
|
+
attributes[field.sourceName] = attributeValue;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const relationships: Record<string, unknown> = {};
|
|
481
|
+
for (const field of operation.relationshipFields) {
|
|
482
|
+
const rawValue = context.getNodeParameter(\`${'${operation.id}'}_\${field.name}\`, itemIndex, '');
|
|
483
|
+
const value = field.lookup ? extractResourceLocatorId(rawValue) : String(rawValue);
|
|
484
|
+
if (!value) continue;
|
|
485
|
+
const ids = field.multiple ? value.split(',').map((id) => id.trim()).filter(Boolean) : [value];
|
|
486
|
+
relationships[field.relationshipName] = {
|
|
487
|
+
data: field.multiple
|
|
488
|
+
? ids.map((id) => ({ type: field.relationshipType, id }))
|
|
489
|
+
: { type: field.relationshipType, id: ids[0] },
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return {
|
|
494
|
+
data: {
|
|
495
|
+
type: operation.resource,
|
|
496
|
+
...(Object.keys(attributes).length ? { attributes } : {}),
|
|
497
|
+
...(Object.keys(relationships).length ? { relationships } : {}),
|
|
498
|
+
},
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function buildPath(context: IExecuteFunctions, itemIndex: number, operation: Operation): string {
|
|
503
|
+
let path = operation.path;
|
|
504
|
+
for (const parameter of operation.pathParameters) {
|
|
505
|
+
const value = extractResourceLocatorId(context.getNodeParameter(\`${'${operation.id}'}_\${parameter.name}\`, itemIndex));
|
|
506
|
+
path = path.replace(\`{\${parameter.sourceName}}\`, encodeURIComponent(value));
|
|
507
|
+
}
|
|
508
|
+
return path;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
async function executeOperation(context: IExecuteFunctions, itemIndex: number, operation: Operation): Promise<INodeExecutionData[]> {
|
|
512
|
+
const qs: IDataObject = {};
|
|
513
|
+
addQueryOptions(context, itemIndex, operation, qs);
|
|
514
|
+
addAdditionalQuery(context, itemIndex, operation, qs);
|
|
515
|
+
|
|
516
|
+
const request = {
|
|
517
|
+
method: operation.method,
|
|
518
|
+
path: buildPath(context, itemIndex, operation),
|
|
519
|
+
qs,
|
|
520
|
+
body: buildBody(context, itemIndex, operation),
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
const data = operation.isList
|
|
524
|
+
? await collectPaginatedPlanningCenterResults.call(context, request, {
|
|
525
|
+
returnAll: context.getNodeParameter(\`${'${operation.id}'}_returnAll\`, itemIndex, false) as boolean,
|
|
526
|
+
limit: context.getNodeParameter(\`${'${operation.id}'}_limit\`, itemIndex, 100) as number,
|
|
527
|
+
})
|
|
528
|
+
: normalizeJsonApiResponse(await planningCenterApiRequest.call(context, request));
|
|
529
|
+
|
|
530
|
+
return data.map((json) => ({ json, pairedItem: { item: itemIndex } }));
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export class ${config.className} implements INodeType {
|
|
534
|
+
description: INodeTypeDescription = {
|
|
535
|
+
displayName: ${q(config.displayName)},
|
|
536
|
+
name: ${q(config.nodeName)},
|
|
537
|
+
icon: 'file:${config.product}.svg',
|
|
538
|
+
group: ['transform'],
|
|
539
|
+
version: 1,
|
|
540
|
+
subtitle: ${q(renderOperationSubtitle(result.operations))},
|
|
541
|
+
description: ${q(`${config.displayName} generated from the Planning Center OpenAPI snapshot.`)},
|
|
542
|
+
defaults: {
|
|
543
|
+
name: ${q(config.displayName)},
|
|
544
|
+
},
|
|
545
|
+
inputs: ['main'],
|
|
546
|
+
outputs: ['main'],
|
|
547
|
+
credentials: [
|
|
548
|
+
{
|
|
549
|
+
name: 'planningCenterPatApi',
|
|
550
|
+
required: true,
|
|
551
|
+
},
|
|
552
|
+
],
|
|
553
|
+
properties: NODE_PROPERTIES,
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
methods = {
|
|
557
|
+
listSearch: ${renderListSearchMethods(result.operations)},
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
561
|
+
const items = this.getInputData();
|
|
562
|
+
const returnData: INodeExecutionData[] = [];
|
|
563
|
+
|
|
564
|
+
for (let itemIndex = 0; itemIndex < items.length; itemIndex += 1) {
|
|
565
|
+
const resource = this.getNodeParameter('resource', itemIndex) as string;
|
|
566
|
+
const operationId = this.getNodeParameter('operation', itemIndex) as string;
|
|
567
|
+
const operation = OPERATIONS.find((candidate) => candidate.resource === resource && candidate.id === operationId);
|
|
568
|
+
if (!operation) {
|
|
569
|
+
throw new Error(\`Unsupported ${config.displayName} operation: \${resource}.\${operationId}\`);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
returnData.push(...(await executeItemWithContinueOnFail(this, itemIndex, () => executeOperation(this, itemIndex, operation))));
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
return [returnData];
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
`;
|
|
579
|
+
}
|
|
580
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/generator/render.ts"],"names":[],"mappings":";;AAkRA,gCA2UC;AA5lBD,qCAA2D;AAK3D,MAAM,mBAAmB,GAIpB;IACH,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE;IACpE,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE;IACjE,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE;CAC1E,CAAC;AAEF,SAAS,CAAC,CAAC,KAAc;IACvB,OAAO,IAAI,CA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BAAmB,CAAC,MAAM,CAAC,UAAU,CAAC;;+CAEjD,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDAyGpC,iBAAiB,IAAI,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA6BlD,iBAAiB;qCACjB,iBAAiB;;;;;;;;;kDASJ,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;wEAuBK,iBAAiB;;;;;;;;;;;;;;;;;;;;gDAoBzC,iBAAiB;4CACrB,iBAAiB;;;;;;;eAO9C,MAAM,CAAC,SAAS;;mBAEZ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;YAC5B,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;kBACZ,MAAM,CAAC,OAAO;;;gBAGhB,CAAC,CAAC,uBAAuB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;mBAC1C,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,uDAAuD,CAAC;;cAEpF,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;;;;;;;;;;;;;;kBAcjB,uBAAuB,CAAC,MAAM,CAAC,UAAU,CAAC;;;;;;;;;;;;wCAYpB,MAAM,CAAC,WAAW;;;;;;;;;CASzD,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeItemWithContinueOnFail = executeItemWithContinueOnFail;
|
|
4
|
+
const request_1 = require("./request");
|
|
5
|
+
async function executeItemWithContinueOnFail(context, itemIndex, operation) {
|
|
6
|
+
try {
|
|
7
|
+
return await operation();
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (context.continueOnFail()) {
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
json: {
|
|
14
|
+
error: (0, request_1.toNodeOperationError)(context, error, itemIndex).message,
|
|
15
|
+
},
|
|
16
|
+
pairedItem: {
|
|
17
|
+
item: itemIndex,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
throw (0, request_1.toNodeOperationError)(context, error, itemIndex);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/runtime/execute.ts"],"names":[],"mappings":";;AAIA,sEAuBC;AAzBD,uCAAiD;AAE1C,KAAK,UAAU,6BAA6B,CACjD,OAA0B,EAC1B,SAAiB,EACjB,SAA8C;IAE9C,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;YAC7B,OAAO;gBACL;oBACE,IAAI,EAAE;wBACJ,KAAK,EAAE,IAAA,8BAAoB,EAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,OAAO;qBAC/D;oBACD,UAAU,EAAE;wBACV,IAAI,EAAE,SAAS;qBAChB;iBACF;aACF,CAAC;QACJ,CAAC;QAED,MAAM,IAAA,8BAAoB,EAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeJsonApiResource = normalizeJsonApiResource;
|
|
4
|
+
exports.normalizeJsonApiResponse = normalizeJsonApiResponse;
|
|
5
|
+
const RESERVED_OUTPUT_KEYS = new Set(['id', 'type', 'relationships', 'links', 'meta']);
|
|
6
|
+
function isObject(value) {
|
|
7
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function normalizeJsonApiResource(resource) {
|
|
10
|
+
if (!isObject(resource)) {
|
|
11
|
+
return { value: resource };
|
|
12
|
+
}
|
|
13
|
+
const output = {};
|
|
14
|
+
if ('id' in resource)
|
|
15
|
+
output.id = resource.id;
|
|
16
|
+
if ('type' in resource)
|
|
17
|
+
output.type = resource.type;
|
|
18
|
+
const attributes = isObject(resource.attributes) ? resource.attributes : {};
|
|
19
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
20
|
+
output[RESERVED_OUTPUT_KEYS.has(key) ? `attribute_${key}` : key] = value;
|
|
21
|
+
}
|
|
22
|
+
if ('relationships' in resource)
|
|
23
|
+
output.relationships = resource.relationships;
|
|
24
|
+
if ('links' in resource)
|
|
25
|
+
output.links = resource.links;
|
|
26
|
+
if ('meta' in resource)
|
|
27
|
+
output.meta = resource.meta;
|
|
28
|
+
return output;
|
|
29
|
+
}
|
|
30
|
+
function normalizeJsonApiResponse(response) {
|
|
31
|
+
if (!isObject(response) || !('data' in response)) {
|
|
32
|
+
return [isObject(response) ? response : { value: response }];
|
|
33
|
+
}
|
|
34
|
+
const { data } = response;
|
|
35
|
+
if (Array.isArray(data)) {
|
|
36
|
+
return data.map(normalizeJsonApiResource);
|
|
37
|
+
}
|
|
38
|
+
if (data === null) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
return [normalizeJsonApiResource(data)];
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=jsonApi.js.map
|