@rachelallyson/planning-center-people-ts 1.0.0 → 2.0.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/CHANGELOG.md +248 -1
- package/README.md +28 -0
- package/dist/auth.d.ts +64 -0
- package/dist/auth.js +98 -0
- package/dist/batch.d.ts +47 -0
- package/dist/batch.js +376 -0
- package/dist/client-manager.d.ts +66 -0
- package/dist/client-manager.js +150 -0
- package/dist/client.d.ts +71 -0
- package/dist/client.js +123 -0
- package/dist/core/http.d.ts +47 -0
- package/dist/core/http.js +242 -0
- package/dist/core/pagination.d.ts +34 -0
- package/dist/core/pagination.js +164 -0
- package/dist/core.d.ts +5 -0
- package/dist/core.js +12 -0
- package/dist/helpers.d.ts +125 -100
- package/dist/helpers.js +315 -275
- package/dist/index.d.ts +17 -5
- package/dist/index.js +39 -5
- package/dist/matching/matcher.d.ts +41 -0
- package/dist/matching/matcher.js +161 -0
- package/dist/matching/scoring.d.ts +35 -0
- package/dist/matching/scoring.js +141 -0
- package/dist/matching/strategies.d.ts +35 -0
- package/dist/matching/strategies.js +79 -0
- package/dist/modules/base.d.ts +46 -0
- package/dist/modules/base.js +82 -0
- package/dist/modules/contacts.d.ts +103 -0
- package/dist/modules/contacts.js +130 -0
- package/dist/modules/fields.d.ts +157 -0
- package/dist/modules/fields.js +294 -0
- package/dist/modules/households.d.ts +42 -0
- package/dist/modules/households.js +74 -0
- package/dist/modules/lists.d.ts +62 -0
- package/dist/modules/lists.js +92 -0
- package/dist/modules/notes.d.ts +74 -0
- package/dist/modules/notes.js +125 -0
- package/dist/modules/people.d.ts +196 -0
- package/dist/modules/people.js +221 -0
- package/dist/modules/workflows.d.ts +131 -0
- package/dist/modules/workflows.js +221 -0
- package/dist/monitoring.d.ts +53 -0
- package/dist/monitoring.js +142 -0
- package/dist/people/contacts.d.ts +43 -0
- package/dist/people/contacts.js +122 -0
- package/dist/people/core.d.ts +28 -0
- package/dist/people/core.js +69 -0
- package/dist/people/fields.d.ts +62 -0
- package/dist/people/fields.js +293 -0
- package/dist/people/households.d.ts +15 -0
- package/dist/people/households.js +31 -0
- package/dist/people/index.d.ts +8 -0
- package/dist/people/index.js +25 -0
- package/dist/people/lists.d.ts +30 -0
- package/dist/people/lists.js +37 -0
- package/dist/people/notes.d.ts +30 -0
- package/dist/people/notes.js +37 -0
- package/dist/people/organization.d.ts +12 -0
- package/dist/people/organization.js +15 -0
- package/dist/people/workflows.d.ts +37 -0
- package/dist/people/workflows.js +75 -0
- package/dist/testing/index.d.ts +9 -0
- package/dist/testing/index.js +24 -0
- package/dist/testing/recorder.d.ts +58 -0
- package/dist/testing/recorder.js +195 -0
- package/dist/testing/simple-builders.d.ts +33 -0
- package/dist/testing/simple-builders.js +124 -0
- package/dist/testing/simple-factories.d.ts +91 -0
- package/dist/testing/simple-factories.js +279 -0
- package/dist/testing/types.d.ts +160 -0
- package/dist/testing/types.js +5 -0
- package/dist/types/batch.d.ts +50 -0
- package/dist/types/batch.js +5 -0
- package/dist/types/client.d.ts +81 -0
- package/dist/types/client.js +5 -0
- package/dist/types/events.d.ts +85 -0
- package/dist/types/events.js +5 -0
- package/dist/types/people.d.ts +73 -79
- package/package.json +14 -3
- package/dist/people.d.ts +0 -205
- package/dist/people.js +0 -598
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWorkflowCardNotes = getWorkflowCardNotes;
|
|
4
|
+
exports.createWorkflowCardNote = createWorkflowCardNote;
|
|
5
|
+
exports.getWorkflowCards = getWorkflowCards;
|
|
6
|
+
exports.createWorkflowCard = createWorkflowCard;
|
|
7
|
+
exports.getWorkflows = getWorkflows;
|
|
8
|
+
exports.getWorkflow = getWorkflow;
|
|
9
|
+
const core_1 = require("../core");
|
|
10
|
+
const helpers_1 = require("../helpers");
|
|
11
|
+
/**
|
|
12
|
+
* List notes for a workflow card
|
|
13
|
+
*/
|
|
14
|
+
async function getWorkflowCardNotes(client, personId, workflowCardId, context) {
|
|
15
|
+
return (0, core_1.getList)(client, `/people/${personId}/workflow_cards/${workflowCardId}/notes`, undefined, {
|
|
16
|
+
...context,
|
|
17
|
+
endpoint: `/people/${personId}/workflow_cards/${workflowCardId}/notes`,
|
|
18
|
+
method: 'GET',
|
|
19
|
+
personId,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a note for a workflow card
|
|
24
|
+
*/
|
|
25
|
+
async function createWorkflowCardNote(client, personId, workflowCardId, data, context) {
|
|
26
|
+
return (0, core_1.post)(client, `/people/${personId}/workflow_cards/${workflowCardId}/notes`, data, undefined, {
|
|
27
|
+
...context,
|
|
28
|
+
endpoint: `/people/${personId}/workflow_cards/${workflowCardId}/notes`,
|
|
29
|
+
method: 'POST',
|
|
30
|
+
personId,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* List workflow cards for a person
|
|
35
|
+
*/
|
|
36
|
+
async function getWorkflowCards(client, personId, context) {
|
|
37
|
+
return (0, core_1.getList)(client, `/people/${personId}/workflow_cards`, undefined, {
|
|
38
|
+
...context,
|
|
39
|
+
endpoint: `/people/${personId}/workflow_cards`,
|
|
40
|
+
method: 'GET',
|
|
41
|
+
personId,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a workflow card in a workflow for a person
|
|
46
|
+
*/
|
|
47
|
+
async function createWorkflowCard(client, workflowId, personId, context) {
|
|
48
|
+
return (0, core_1.post)(client, `/workflows/${workflowId}/cards`, { person_id: personId }, undefined, {
|
|
49
|
+
...context,
|
|
50
|
+
endpoint: `/workflows/${workflowId}/cards`,
|
|
51
|
+
metadata: { ...(context?.metadata ?? {}), workflowId },
|
|
52
|
+
method: 'POST',
|
|
53
|
+
personId,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get all workflows
|
|
58
|
+
*/
|
|
59
|
+
async function getWorkflows(client, params, context) {
|
|
60
|
+
return (0, core_1.getList)(client, '/workflows', (0, helpers_1.buildQueryParams)(params), {
|
|
61
|
+
...context,
|
|
62
|
+
endpoint: '/workflows',
|
|
63
|
+
method: 'GET',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get a single workflow
|
|
68
|
+
*/
|
|
69
|
+
async function getWorkflow(client, workflowId, params, context) {
|
|
70
|
+
return (0, core_1.getSingle)(client, `/workflows/${workflowId}`, (0, helpers_1.buildQueryParams)(params), {
|
|
71
|
+
...context,
|
|
72
|
+
endpoint: `/workflows/${workflowId}`,
|
|
73
|
+
method: 'GET',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 Testing Utilities
|
|
3
|
+
*/
|
|
4
|
+
export { SimpleMockResponseBuilder as MockResponseBuilder } from './simple-builders';
|
|
5
|
+
export { SimpleMockPcoClient as MockPcoClient, createSimpleMockClient as createMockClient, createTestClient, createErrorMockClient, createSlowMockClient } from './simple-factories';
|
|
6
|
+
export type { SimpleMockClientConfig as MockClientConfig } from './simple-factories';
|
|
7
|
+
export { RequestRecorder } from './recorder';
|
|
8
|
+
export type { RecordingConfig } from './types';
|
|
9
|
+
export declare function createRecordingClient(config: any, recordingConfig: any): any;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* v2.0.0 Testing Utilities
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RequestRecorder = exports.createSlowMockClient = exports.createErrorMockClient = exports.createTestClient = exports.createMockClient = exports.MockPcoClient = exports.MockResponseBuilder = void 0;
|
|
7
|
+
exports.createRecordingClient = createRecordingClient;
|
|
8
|
+
// Export simplified versions that work without complex type issues
|
|
9
|
+
var simple_builders_1 = require("./simple-builders");
|
|
10
|
+
Object.defineProperty(exports, "MockResponseBuilder", { enumerable: true, get: function () { return simple_builders_1.SimpleMockResponseBuilder; } });
|
|
11
|
+
var simple_factories_1 = require("./simple-factories");
|
|
12
|
+
Object.defineProperty(exports, "MockPcoClient", { enumerable: true, get: function () { return simple_factories_1.SimpleMockPcoClient; } });
|
|
13
|
+
Object.defineProperty(exports, "createMockClient", { enumerable: true, get: function () { return simple_factories_1.createSimpleMockClient; } });
|
|
14
|
+
Object.defineProperty(exports, "createTestClient", { enumerable: true, get: function () { return simple_factories_1.createTestClient; } });
|
|
15
|
+
Object.defineProperty(exports, "createErrorMockClient", { enumerable: true, get: function () { return simple_factories_1.createErrorMockClient; } });
|
|
16
|
+
Object.defineProperty(exports, "createSlowMockClient", { enumerable: true, get: function () { return simple_factories_1.createSlowMockClient; } });
|
|
17
|
+
// Export recorder (simplified)
|
|
18
|
+
var recorder_1 = require("./recorder");
|
|
19
|
+
Object.defineProperty(exports, "RequestRecorder", { enumerable: true, get: function () { return recorder_1.RequestRecorder; } });
|
|
20
|
+
// Export createRecordingClient (simplified)
|
|
21
|
+
function createRecordingClient(config, recordingConfig) {
|
|
22
|
+
// Simplified implementation
|
|
23
|
+
return new (require('./simple-factories').SimpleMockPcoClient)(config);
|
|
24
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.0.0 Request/Response Recorder
|
|
3
|
+
*/
|
|
4
|
+
import type { RecordingConfig, RecordedRequest } from './types';
|
|
5
|
+
export declare class RequestRecorder {
|
|
6
|
+
private config;
|
|
7
|
+
private requests;
|
|
8
|
+
private isRecording;
|
|
9
|
+
constructor(config: RecordingConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Start recording requests
|
|
12
|
+
*/
|
|
13
|
+
startRecording(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Stop recording and save to file
|
|
16
|
+
*/
|
|
17
|
+
stopRecording(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Record a request/response pair
|
|
20
|
+
*/
|
|
21
|
+
recordRequest(endpoint: string, method: string, params: Record<string, any> | undefined, data: any, response: any): void;
|
|
22
|
+
/**
|
|
23
|
+
* Replay a recorded request
|
|
24
|
+
*/
|
|
25
|
+
replayRequest(endpoint: string, method: string, params: Record<string, any> | undefined, data: any): any | null;
|
|
26
|
+
/**
|
|
27
|
+
* Check if we should record or replay
|
|
28
|
+
*/
|
|
29
|
+
shouldRecord(endpoint: string, method: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Get all recorded requests
|
|
32
|
+
*/
|
|
33
|
+
getRequests(): RecordedRequest[];
|
|
34
|
+
/**
|
|
35
|
+
* Clear recorded requests
|
|
36
|
+
*/
|
|
37
|
+
clearRequests(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Save the current session to file
|
|
40
|
+
*/
|
|
41
|
+
private saveSession;
|
|
42
|
+
/**
|
|
43
|
+
* Load a session from file
|
|
44
|
+
*/
|
|
45
|
+
private loadSession;
|
|
46
|
+
/**
|
|
47
|
+
* Ensure the record directory exists
|
|
48
|
+
*/
|
|
49
|
+
private ensureRecordDirectory;
|
|
50
|
+
/**
|
|
51
|
+
* Compare two parameter objects
|
|
52
|
+
*/
|
|
53
|
+
private compareParams;
|
|
54
|
+
/**
|
|
55
|
+
* Compare two data objects
|
|
56
|
+
*/
|
|
57
|
+
private compareData;
|
|
58
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* v2.0.0 Request/Response Recorder
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.RequestRecorder = void 0;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
class RequestRecorder {
|
|
43
|
+
constructor(config) {
|
|
44
|
+
this.requests = [];
|
|
45
|
+
this.isRecording = false;
|
|
46
|
+
this.config = config;
|
|
47
|
+
this.ensureRecordDirectory();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Start recording requests
|
|
51
|
+
*/
|
|
52
|
+
startRecording() {
|
|
53
|
+
this.isRecording = true;
|
|
54
|
+
this.requests = [];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Stop recording and save to file
|
|
58
|
+
*/
|
|
59
|
+
stopRecording() {
|
|
60
|
+
this.isRecording = false;
|
|
61
|
+
this.saveSession();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Record a request/response pair
|
|
65
|
+
*/
|
|
66
|
+
recordRequest(endpoint, method, params, data, response) {
|
|
67
|
+
if (!this.isRecording)
|
|
68
|
+
return;
|
|
69
|
+
// Apply filter if provided
|
|
70
|
+
if (this.config.filter && !this.config.filter(endpoint, method)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const request = {
|
|
74
|
+
endpoint,
|
|
75
|
+
method,
|
|
76
|
+
params,
|
|
77
|
+
data,
|
|
78
|
+
response: this.config.transform ? this.config.transform(response) : response,
|
|
79
|
+
timestamp: new Date().toISOString(),
|
|
80
|
+
};
|
|
81
|
+
this.requests.push(request);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Replay a recorded request
|
|
85
|
+
*/
|
|
86
|
+
replayRequest(endpoint, method, params, data) {
|
|
87
|
+
const session = this.loadSession();
|
|
88
|
+
if (!session)
|
|
89
|
+
return null;
|
|
90
|
+
const request = session.requests.find(req => req.endpoint === endpoint &&
|
|
91
|
+
req.method === method &&
|
|
92
|
+
this.compareParams(req.params, params) &&
|
|
93
|
+
this.compareData(req.data, data));
|
|
94
|
+
return request ? request.response : null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Check if we should record or replay
|
|
98
|
+
*/
|
|
99
|
+
shouldRecord(endpoint, method) {
|
|
100
|
+
if (this.config.mode === 'record')
|
|
101
|
+
return true;
|
|
102
|
+
if (this.config.mode === 'replay')
|
|
103
|
+
return false;
|
|
104
|
+
// Auto mode: record if no existing session, otherwise replay
|
|
105
|
+
const session = this.loadSession();
|
|
106
|
+
return !session;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get all recorded requests
|
|
110
|
+
*/
|
|
111
|
+
getRequests() {
|
|
112
|
+
return [...this.requests];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Clear recorded requests
|
|
116
|
+
*/
|
|
117
|
+
clearRequests() {
|
|
118
|
+
this.requests = [];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Save the current session to file
|
|
122
|
+
*/
|
|
123
|
+
saveSession() {
|
|
124
|
+
const session = {
|
|
125
|
+
requests: this.requests,
|
|
126
|
+
metadata: {
|
|
127
|
+
recordedAt: new Date().toISOString(),
|
|
128
|
+
version: '2.0.0',
|
|
129
|
+
config: {}, // Would be filled with actual config
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
try {
|
|
133
|
+
fs.writeFileSync(this.config.recordPath, JSON.stringify(session, null, 2));
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
console.error('Failed to save recording session:', error);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Load a session from file
|
|
141
|
+
*/
|
|
142
|
+
loadSession() {
|
|
143
|
+
try {
|
|
144
|
+
if (!fs.existsSync(this.config.recordPath)) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const content = fs.readFileSync(this.config.recordPath, 'utf-8');
|
|
148
|
+
return JSON.parse(content);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
console.error('Failed to load recording session:', error);
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Ensure the record directory exists
|
|
157
|
+
*/
|
|
158
|
+
ensureRecordDirectory() {
|
|
159
|
+
const dir = path.dirname(this.config.recordPath);
|
|
160
|
+
if (!fs.existsSync(dir)) {
|
|
161
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Compare two parameter objects
|
|
166
|
+
*/
|
|
167
|
+
compareParams(params1, params2) {
|
|
168
|
+
if (!params1 && !params2)
|
|
169
|
+
return true;
|
|
170
|
+
if (!params1 || !params2)
|
|
171
|
+
return false;
|
|
172
|
+
const keys1 = Object.keys(params1).sort();
|
|
173
|
+
const keys2 = Object.keys(params2).sort();
|
|
174
|
+
if (keys1.length !== keys2.length)
|
|
175
|
+
return false;
|
|
176
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
177
|
+
if (keys1[i] !== keys2[i])
|
|
178
|
+
return false;
|
|
179
|
+
if (params1[keys1[i]] !== params2[keys2[i]])
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Compare two data objects
|
|
186
|
+
*/
|
|
187
|
+
compareData(data1, data2) {
|
|
188
|
+
if (!data1 && !data2)
|
|
189
|
+
return true;
|
|
190
|
+
if (!data1 || !data2)
|
|
191
|
+
return false;
|
|
192
|
+
return JSON.stringify(data1) === JSON.stringify(data2);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.RequestRecorder = RequestRecorder;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified Mock Response Builders for Testing
|
|
3
|
+
*/
|
|
4
|
+
export declare class SimpleMockResponseBuilder {
|
|
5
|
+
/**
|
|
6
|
+
* Build a simple mock person resource
|
|
7
|
+
*/
|
|
8
|
+
static person(overrides?: any): any;
|
|
9
|
+
/**
|
|
10
|
+
* Build a simple mock email resource
|
|
11
|
+
*/
|
|
12
|
+
static email(overrides?: any): any;
|
|
13
|
+
/**
|
|
14
|
+
* Build a simple mock phone number resource
|
|
15
|
+
*/
|
|
16
|
+
static phoneNumber(overrides?: any): any;
|
|
17
|
+
/**
|
|
18
|
+
* Build a simple mock workflow resource
|
|
19
|
+
*/
|
|
20
|
+
static workflow(overrides?: any): any;
|
|
21
|
+
/**
|
|
22
|
+
* Build a simple paginated response
|
|
23
|
+
*/
|
|
24
|
+
static paginated(data: any[], meta?: any): any;
|
|
25
|
+
/**
|
|
26
|
+
* Build a simple single resource response
|
|
27
|
+
*/
|
|
28
|
+
static single(data: any): any;
|
|
29
|
+
/**
|
|
30
|
+
* Build a simple error response
|
|
31
|
+
*/
|
|
32
|
+
static error(status: number, message: string, details?: any): any;
|
|
33
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Simplified Mock Response Builders for Testing
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SimpleMockResponseBuilder = void 0;
|
|
7
|
+
class SimpleMockResponseBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* Build a simple mock person resource
|
|
10
|
+
*/
|
|
11
|
+
static person(overrides = {}) {
|
|
12
|
+
return {
|
|
13
|
+
type: 'Person',
|
|
14
|
+
id: overrides.id || `person_${Date.now()}`,
|
|
15
|
+
attributes: {
|
|
16
|
+
id: overrides.id || `person_${Date.now()}`,
|
|
17
|
+
first_name: overrides.first_name || 'John',
|
|
18
|
+
last_name: overrides.last_name || 'Doe',
|
|
19
|
+
status: 'active',
|
|
20
|
+
...overrides,
|
|
21
|
+
},
|
|
22
|
+
relationships: {
|
|
23
|
+
emails: { data: [] },
|
|
24
|
+
phone_numbers: { data: [] },
|
|
25
|
+
field_data: { data: [] },
|
|
26
|
+
workflow_cards: { data: [] },
|
|
27
|
+
household: { data: null },
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build a simple mock email resource
|
|
33
|
+
*/
|
|
34
|
+
static email(overrides = {}) {
|
|
35
|
+
return {
|
|
36
|
+
type: 'Email',
|
|
37
|
+
id: overrides.id || `email_${Date.now()}`,
|
|
38
|
+
attributes: {
|
|
39
|
+
id: overrides.id || `email_${Date.now()}`,
|
|
40
|
+
address: overrides.address || 'john@example.com',
|
|
41
|
+
location: 'Home',
|
|
42
|
+
primary: true,
|
|
43
|
+
...overrides,
|
|
44
|
+
},
|
|
45
|
+
relationships: {
|
|
46
|
+
person: { data: { type: 'Person', id: 'person_123' } },
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build a simple mock phone number resource
|
|
52
|
+
*/
|
|
53
|
+
static phoneNumber(overrides = {}) {
|
|
54
|
+
return {
|
|
55
|
+
type: 'PhoneNumber',
|
|
56
|
+
id: overrides.id || `phone_${Date.now()}`,
|
|
57
|
+
attributes: {
|
|
58
|
+
id: overrides.id || `phone_${Date.now()}`,
|
|
59
|
+
number: overrides.number || '555-1234',
|
|
60
|
+
location: 'Mobile',
|
|
61
|
+
primary: true,
|
|
62
|
+
...overrides,
|
|
63
|
+
},
|
|
64
|
+
relationships: {
|
|
65
|
+
person: { data: { type: 'Person', id: 'person_123' } },
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Build a simple mock workflow resource
|
|
71
|
+
*/
|
|
72
|
+
static workflow(overrides = {}) {
|
|
73
|
+
return {
|
|
74
|
+
type: 'Workflow',
|
|
75
|
+
id: overrides.id || `workflow_${Date.now()}`,
|
|
76
|
+
attributes: {
|
|
77
|
+
id: overrides.id || `workflow_${Date.now()}`,
|
|
78
|
+
name: overrides.name || 'New Member Workflow',
|
|
79
|
+
description: overrides.description || 'Workflow for new members',
|
|
80
|
+
...overrides,
|
|
81
|
+
},
|
|
82
|
+
relationships: {},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build a simple paginated response
|
|
87
|
+
*/
|
|
88
|
+
static paginated(data, meta = {}) {
|
|
89
|
+
return {
|
|
90
|
+
data,
|
|
91
|
+
meta: {
|
|
92
|
+
total_count: data.length,
|
|
93
|
+
count: data.length,
|
|
94
|
+
...meta,
|
|
95
|
+
},
|
|
96
|
+
links: {
|
|
97
|
+
self: '/api/v2/people?page=1',
|
|
98
|
+
next: null,
|
|
99
|
+
prev: null,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Build a simple single resource response
|
|
105
|
+
*/
|
|
106
|
+
static single(data) {
|
|
107
|
+
return { data };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Build a simple error response
|
|
111
|
+
*/
|
|
112
|
+
static error(status, message, details = {}) {
|
|
113
|
+
return {
|
|
114
|
+
errors: [
|
|
115
|
+
{
|
|
116
|
+
status: status.toString(),
|
|
117
|
+
title: message,
|
|
118
|
+
detail: details,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.SimpleMockResponseBuilder = SimpleMockResponseBuilder;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified Testing Factory Functions
|
|
3
|
+
*/
|
|
4
|
+
import type { PcoClientConfig } from '../types/client';
|
|
5
|
+
export interface SimpleMockClientConfig {
|
|
6
|
+
people?: {
|
|
7
|
+
getAll?: () => Promise<any>;
|
|
8
|
+
getById?: (id: string) => Promise<any>;
|
|
9
|
+
create?: (data: any) => Promise<any>;
|
|
10
|
+
update?: (id: string, data: any) => Promise<any>;
|
|
11
|
+
delete?: (id: string) => Promise<void>;
|
|
12
|
+
findOrCreate?: (options: any) => Promise<any>;
|
|
13
|
+
createWithContacts?: (personData: any, contacts: any) => Promise<any>;
|
|
14
|
+
search?: (criteria: any) => Promise<any>;
|
|
15
|
+
getAllPages?: (options?: any) => Promise<any>;
|
|
16
|
+
addEmail?: (personId: string, data: any) => Promise<any>;
|
|
17
|
+
addPhoneNumber?: (personId: string, data: any) => Promise<any>;
|
|
18
|
+
addAddress?: (personId: string, data: any) => Promise<any>;
|
|
19
|
+
addSocialProfile?: (personId: string, data: any) => Promise<any>;
|
|
20
|
+
};
|
|
21
|
+
fields?: {
|
|
22
|
+
getAllFieldDefinitions?: () => Promise<any[]>;
|
|
23
|
+
getFieldDefinition?: (id: string) => Promise<any>;
|
|
24
|
+
getFieldDefinitionBySlug?: (slug: string) => Promise<any>;
|
|
25
|
+
getFieldDefinitionByName?: (name: string) => Promise<any>;
|
|
26
|
+
setPersonField?: (personId: string, options: any) => Promise<any>;
|
|
27
|
+
setPersonFieldById?: (personId: string, fieldId: string, value: string) => Promise<any>;
|
|
28
|
+
setPersonFieldBySlug?: (personId: string, slug: string, value: string) => Promise<any>;
|
|
29
|
+
setPersonFieldByName?: (personId: string, name: string, value: string) => Promise<any>;
|
|
30
|
+
};
|
|
31
|
+
workflows?: {
|
|
32
|
+
getAll?: (options?: any) => Promise<any>;
|
|
33
|
+
getById?: (id: string) => Promise<any>;
|
|
34
|
+
create?: (data: any) => Promise<any>;
|
|
35
|
+
update?: (id: string, data: any) => Promise<any>;
|
|
36
|
+
delete?: (id: string) => Promise<void>;
|
|
37
|
+
getAllPages?: (options?: any) => Promise<any>;
|
|
38
|
+
addPersonToWorkflow?: (personId: string, workflowId: string, options?: any) => Promise<any>;
|
|
39
|
+
createWorkflowCard?: (workflowId: string, personId: string) => Promise<any>;
|
|
40
|
+
createWorkflowCardNote?: (personId: string, workflowCardId: string, data: any) => Promise<any>;
|
|
41
|
+
};
|
|
42
|
+
batch?: {
|
|
43
|
+
execute?: (operations: any[]) => Promise<any>;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export declare class SimpleMockPcoClient {
|
|
47
|
+
people: any;
|
|
48
|
+
fields: any;
|
|
49
|
+
workflows: any;
|
|
50
|
+
contacts: any;
|
|
51
|
+
households: any;
|
|
52
|
+
notes: any;
|
|
53
|
+
lists: any;
|
|
54
|
+
batch: any;
|
|
55
|
+
private config;
|
|
56
|
+
private mockConfig;
|
|
57
|
+
constructor(config: PcoClientConfig, mockConfig?: SimpleMockClientConfig);
|
|
58
|
+
private createPeopleModule;
|
|
59
|
+
private createFieldsModule;
|
|
60
|
+
private createWorkflowsModule;
|
|
61
|
+
private createContactsModule;
|
|
62
|
+
private createHouseholdsModule;
|
|
63
|
+
private createNotesModule;
|
|
64
|
+
private createListsModule;
|
|
65
|
+
private createBatchModule;
|
|
66
|
+
on(eventType: string, handler: Function): void;
|
|
67
|
+
off(eventType: string, handler: Function): void;
|
|
68
|
+
emit(event: any): void;
|
|
69
|
+
getConfig(): PcoClientConfig;
|
|
70
|
+
getPerformanceMetrics(): any;
|
|
71
|
+
getRateLimitInfo(): any;
|
|
72
|
+
removeAllListeners(eventType?: string): void;
|
|
73
|
+
listenerCount(eventType: string): number;
|
|
74
|
+
eventTypes(): string[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a simple mock client for testing
|
|
78
|
+
*/
|
|
79
|
+
export declare function createSimpleMockClient(config: PcoClientConfig, mockConfig?: SimpleMockClientConfig): SimpleMockPcoClient;
|
|
80
|
+
/**
|
|
81
|
+
* Create a test client with common mock responses
|
|
82
|
+
*/
|
|
83
|
+
export declare function createTestClient(overrides?: SimpleMockClientConfig): SimpleMockPcoClient;
|
|
84
|
+
/**
|
|
85
|
+
* Create a mock client that simulates errors
|
|
86
|
+
*/
|
|
87
|
+
export declare function createErrorMockClient(errorType?: 'network' | 'auth' | 'validation' | 'rate_limit'): SimpleMockPcoClient;
|
|
88
|
+
/**
|
|
89
|
+
* Create a mock client with specific response delays
|
|
90
|
+
*/
|
|
91
|
+
export declare function createSlowMockClient(delayMs?: number): SimpleMockPcoClient;
|