mp-js-api 0.0.23 → 0.0.25
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/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/utils/json-sql.d.ts +2 -0
- package/dist/utils/json-sql.d.ts.map +1 -0
- package/dist/utils/json-sql.js +111 -0
- package/package.json +1 -1
- package/src/index.ts +10 -2
- package/src/utils/json-sql.ts +132 -0
package/dist/index.d.ts
CHANGED
|
@@ -115,6 +115,9 @@ export type MPInstance = {
|
|
|
115
115
|
getGroupParticipants(options: AtLeastOne<MPGetOptions>): Promise<GroupParticipant[] | {
|
|
116
116
|
error: ErrorDetails;
|
|
117
117
|
}>;
|
|
118
|
+
getFormResponseAnswers(options: AtLeastOne<MPGetOptions>): Promise<FormResponseAnswer[] | {
|
|
119
|
+
error: ErrorDetails;
|
|
120
|
+
}>;
|
|
118
121
|
createContact(params: CreateContactParams, options?: MPCreateOptions): Promise<Contact | {
|
|
119
122
|
error: ErrorDetails;
|
|
120
123
|
}>;
|
|
@@ -154,7 +157,7 @@ export type MPInstance = {
|
|
|
154
157
|
updateEventParticipants(participants: WithRequired<Partial<EventParticipant>, 'eventParticipantID'>[], options?: MPUpdateOptions): Promise<EventParticipant[] | {
|
|
155
158
|
error: ErrorDetails;
|
|
156
159
|
}>;
|
|
157
|
-
updateGroupParticipants(participants: WithRequired<Partial<GroupParticipant>, '
|
|
160
|
+
updateGroupParticipants(participants: WithRequired<Partial<GroupParticipant>, 'groupParticipantID'>[], options?: MPUpdateOptions): Promise<GroupParticipant[] | {
|
|
158
161
|
error: ErrorDetails;
|
|
159
162
|
}>;
|
|
160
163
|
};
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,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E,EAC7E,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,gBAAgB,EAAE,GAAG;QAAE,KAAK,EAAE,YAAY,CAAC;KAAE,CAAC,CAAC;IAC1D,uBAAuB,CACrB,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,oBAAoB,CAAC,EAAE,EAC7E,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,gBAAgB,EAAE,GAAG;QAAE,KAAK,EAAE,YAAY,CAAC;KAAE,CAAC,CAAC;CAC3D,CAAC;AAGF,eAAO,MAAM,gBAAgB,aAAc;IAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;KAAE,CAAC;CAAE,KAAG,UA0N/F,CAAC;AAEF,OAAO,EACL,OAAO,EACP,WAAW,EACX,KAAK,EACL,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,EACV,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -98,6 +98,9 @@ const createMPInstance = ({ auth }) => {
|
|
|
98
98
|
async getGroupParticipants(mpOptions) {
|
|
99
99
|
return getMany({ path: `/tables/group_participants`, mpOptions });
|
|
100
100
|
},
|
|
101
|
+
async getFormResponseAnswers(mpOptions) {
|
|
102
|
+
return getMany({ path: `/tables/form_response_answers`, mpOptions });
|
|
103
|
+
},
|
|
101
104
|
async createContact(params, mpOptions = {}) {
|
|
102
105
|
return createOne({ path: `/tables/contacts`, mpOptions, params });
|
|
103
106
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-sql.d.ts","sourceRoot":"","sources":["../../src/utils/json-sql.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function jsonToSqlFilter(json) {
|
|
4
|
+
const conditions = [];
|
|
5
|
+
// Loop through each key-value pair in the JSON object
|
|
6
|
+
for (const [key, value] of Object.entries(json)) {
|
|
7
|
+
let condition = '';
|
|
8
|
+
// If the value is a string, wrap it in quotes
|
|
9
|
+
if (typeof value === 'string') {
|
|
10
|
+
condition = `${key} = '${value}'`;
|
|
11
|
+
}
|
|
12
|
+
// If the value is a number or boolean, no quotes are needed
|
|
13
|
+
else if (typeof value === 'number' || typeof value === 'boolean') {
|
|
14
|
+
condition = `${key} = ${value}`;
|
|
15
|
+
}
|
|
16
|
+
// If the value is an array, assume it represents an IN condition
|
|
17
|
+
else if (Array.isArray(value)) {
|
|
18
|
+
const valueList = value.map(val => typeof val === 'string' ? `'${val}'` : val).join(', ');
|
|
19
|
+
condition = `${key} IN (${valueList})`;
|
|
20
|
+
}
|
|
21
|
+
// If the value is an object, we can assume it's a nested condition (e.g., for complex queries)
|
|
22
|
+
else if (typeof value === 'object') {
|
|
23
|
+
const subConditions = Object.entries(value).map(([subKey, subValue]) => {
|
|
24
|
+
if (typeof subValue === 'string') {
|
|
25
|
+
return `${subKey} = '${subValue}'`;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return `${subKey} = ${subValue}`;
|
|
29
|
+
}
|
|
30
|
+
}).join(' AND ');
|
|
31
|
+
condition = `${key} (${subConditions})`;
|
|
32
|
+
}
|
|
33
|
+
conditions.push(condition);
|
|
34
|
+
}
|
|
35
|
+
// Join the conditions with 'AND'
|
|
36
|
+
return conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
37
|
+
}
|
|
38
|
+
// Example Usage
|
|
39
|
+
const json1 = {
|
|
40
|
+
name: "John",
|
|
41
|
+
age: 30,
|
|
42
|
+
active: true,
|
|
43
|
+
hobbies: ["reading", "gaming"],
|
|
44
|
+
address: {
|
|
45
|
+
city: "New York",
|
|
46
|
+
zip: "10001"
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const query1 = jsonToSqlFilter(json1);
|
|
50
|
+
console.log(query1);
|
|
51
|
+
function jsonToSqlQuery(json) {
|
|
52
|
+
const conditions = [];
|
|
53
|
+
// Loop through each key-value pair in the JSON object
|
|
54
|
+
for (const [key, value] of Object.entries(json)) {
|
|
55
|
+
let condition = '';
|
|
56
|
+
// If the value is an object (operator condition)
|
|
57
|
+
if (typeof value === 'object' && value !== null) {
|
|
58
|
+
const operatorConditions = [];
|
|
59
|
+
let [operator, operatorValue] = [null, null];
|
|
60
|
+
for ([operator, operatorValue] of Object.entries(value)) {
|
|
61
|
+
switch (operator) {
|
|
62
|
+
case "$eq":
|
|
63
|
+
operatorConditions.push(`${key} = '${operatorValue}'`);
|
|
64
|
+
break;
|
|
65
|
+
case "$gt":
|
|
66
|
+
operatorConditions.push(`${key} > ${operatorValue}`);
|
|
67
|
+
break;
|
|
68
|
+
case "$lt":
|
|
69
|
+
operatorConditions.push(`${key} < ${operatorValue}`);
|
|
70
|
+
break;
|
|
71
|
+
case "$gte":
|
|
72
|
+
operatorConditions.push(`${key} >= ${operatorValue}`);
|
|
73
|
+
break;
|
|
74
|
+
case "$lte":
|
|
75
|
+
operatorConditions.push(`${key} <= ${operatorValue}`);
|
|
76
|
+
break;
|
|
77
|
+
case "$ne":
|
|
78
|
+
operatorConditions.push(`${key} != '${operatorValue}'`);
|
|
79
|
+
break;
|
|
80
|
+
case "$in":
|
|
81
|
+
const inValues = operatorValue.map((val) => typeof val === 'string' ? `'${val}'` : val).join(', ');
|
|
82
|
+
operatorConditions.push(`${key} IN (${inValues})`);
|
|
83
|
+
break;
|
|
84
|
+
case "$like":
|
|
85
|
+
operatorConditions.push(`${key} LIKE '%${operatorValue}%'`);
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
throw new Error(`Unsupported operator: ${operator}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Join all conditions for a field with AND
|
|
92
|
+
condition = operatorConditions.join(' AND ');
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
// For simple equality condition
|
|
96
|
+
condition = `${key} = '${value}'`;
|
|
97
|
+
}
|
|
98
|
+
conditions.push(condition);
|
|
99
|
+
}
|
|
100
|
+
// Join the conditions with AND
|
|
101
|
+
return conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
102
|
+
}
|
|
103
|
+
// Example Usage
|
|
104
|
+
const json = {
|
|
105
|
+
"age": { "$gt": 30 },
|
|
106
|
+
"name": { "$eq": "John" },
|
|
107
|
+
"status": { "$in": ["active", "pending"] },
|
|
108
|
+
"address.city": { "$eq": "New York" }
|
|
109
|
+
};
|
|
110
|
+
const query = jsonToSqlQuery(json);
|
|
111
|
+
console.log(query);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { EventParticipant, EventParticipantRecord } from './tables/event-partici
|
|
|
11
11
|
import { GroupParticipant, GroupParticipantRecord } from './tables/group-participants';
|
|
12
12
|
import { ContactAttribute, ContactAttributeRecord, ContactWithAttribute } from './tables/contact-attributes';
|
|
13
13
|
import { FormResponse, FormResponseRecord } from './tables/form-responses';
|
|
14
|
-
import { FormResponseAnswer } from './tables/from-response-answers';
|
|
14
|
+
import { FormResponseAnswer, FormResponseAnswerRecord } from './tables/from-response-answers';
|
|
15
15
|
import { ContactEmailAddress, ContactEmailAddressRecord, ContactWithEmailAddress, ContactWithEmailAddresses } from './tables/contact-email-addresses';
|
|
16
16
|
|
|
17
17
|
|
|
@@ -166,6 +166,9 @@ export type MPInstance = {
|
|
|
166
166
|
getGroupParticipants(
|
|
167
167
|
options: AtLeastOne<MPGetOptions>
|
|
168
168
|
): Promise<GroupParticipant[] | { error: ErrorDetails; }>;
|
|
169
|
+
getFormResponseAnswers(
|
|
170
|
+
options: AtLeastOne<MPGetOptions>
|
|
171
|
+
): Promise<FormResponseAnswer[] | { error: ErrorDetails; }>;
|
|
169
172
|
|
|
170
173
|
createContact(
|
|
171
174
|
params: CreateContactParams,
|
|
@@ -221,7 +224,7 @@ export type MPInstance = {
|
|
|
221
224
|
options?: MPUpdateOptions
|
|
222
225
|
): Promise<EventParticipant[] | { error: ErrorDetails; }>;
|
|
223
226
|
updateGroupParticipants(
|
|
224
|
-
participants: WithRequired<Partial<GroupParticipant>, '
|
|
227
|
+
participants: WithRequired<Partial<GroupParticipant>, 'groupParticipantID'>[],
|
|
225
228
|
options?: MPUpdateOptions
|
|
226
229
|
): Promise<GroupParticipant[] | { error: ErrorDetails; }>;
|
|
227
230
|
};
|
|
@@ -368,6 +371,11 @@ export const createMPInstance = ({ auth }: { auth: { username: string; password:
|
|
|
368
371
|
{ path: `/tables/group_participants`, mpOptions }
|
|
369
372
|
);
|
|
370
373
|
},
|
|
374
|
+
async getFormResponseAnswers(mpOptions) {
|
|
375
|
+
return getMany<FormResponseAnswerRecord, FormResponseAnswer>(
|
|
376
|
+
{ path: `/tables/form_response_answers`, mpOptions }
|
|
377
|
+
);
|
|
378
|
+
},
|
|
371
379
|
|
|
372
380
|
async createContact(params, mpOptions = {}) {
|
|
373
381
|
return createOne<CreateContactParams, Contact>(
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
function jsonToSqlFilter(json: Record<string, any>): string {
|
|
2
|
+
const conditions: string[] = [];
|
|
3
|
+
|
|
4
|
+
// Loop through each key-value pair in the JSON object
|
|
5
|
+
for (const [key, value] of Object.entries(json)) {
|
|
6
|
+
let condition = '';
|
|
7
|
+
|
|
8
|
+
// If the value is a string, wrap it in quotes
|
|
9
|
+
if (typeof value === 'string') {
|
|
10
|
+
condition = `${key} = '${value}'`;
|
|
11
|
+
}
|
|
12
|
+
// If the value is a number or boolean, no quotes are needed
|
|
13
|
+
else if (typeof value === 'number' || typeof value === 'boolean') {
|
|
14
|
+
condition = `${key} = ${value}`;
|
|
15
|
+
}
|
|
16
|
+
// If the value is an array, assume it represents an IN condition
|
|
17
|
+
else if (Array.isArray(value)) {
|
|
18
|
+
const valueList = value.map(val =>
|
|
19
|
+
typeof val === 'string' ? `'${val}'` : val
|
|
20
|
+
).join(', ');
|
|
21
|
+
condition = `${key} IN (${valueList})`;
|
|
22
|
+
}
|
|
23
|
+
// If the value is an object, we can assume it's a nested condition (e.g., for complex queries)
|
|
24
|
+
else if (typeof value === 'object') {
|
|
25
|
+
const subConditions = Object.entries(value).map(([subKey, subValue]) => {
|
|
26
|
+
if (typeof subValue === 'string') {
|
|
27
|
+
return `${subKey} = '${subValue}'`;
|
|
28
|
+
} else {
|
|
29
|
+
return `${subKey} = ${subValue}`;
|
|
30
|
+
}
|
|
31
|
+
}).join(' AND ');
|
|
32
|
+
condition = `${key} (${subConditions})`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
conditions.push(condition);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Join the conditions with 'AND'
|
|
39
|
+
return conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Example Usage
|
|
43
|
+
const json1 = {
|
|
44
|
+
name: "John",
|
|
45
|
+
age: 30,
|
|
46
|
+
active: true,
|
|
47
|
+
hobbies: ["reading", "gaming"],
|
|
48
|
+
address: {
|
|
49
|
+
city: "New York",
|
|
50
|
+
zip: "10001"
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const query1 = jsonToSqlFilter(json1);
|
|
55
|
+
console.log(query1);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
type QueryCondition = {
|
|
64
|
+
[key: string]: any; // key is field, value is condition or value
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function jsonToSqlQuery(json: QueryCondition): string {
|
|
68
|
+
const conditions: string[] = [];
|
|
69
|
+
|
|
70
|
+
// Loop through each key-value pair in the JSON object
|
|
71
|
+
for (const [key, value] of Object.entries(json)) {
|
|
72
|
+
let condition = '';
|
|
73
|
+
|
|
74
|
+
// If the value is an object (operator condition)
|
|
75
|
+
if (typeof value === 'object' && value !== null) {
|
|
76
|
+
const operatorConditions: string[] = [];
|
|
77
|
+
let [operator, operatorValue]: any[] = [null, null];
|
|
78
|
+
for ([operator, operatorValue] of Object.entries(value)) {
|
|
79
|
+
switch (operator) {
|
|
80
|
+
case "$eq":
|
|
81
|
+
operatorConditions.push(`${key} = '${operatorValue}'`);
|
|
82
|
+
break;
|
|
83
|
+
case "$gt":
|
|
84
|
+
operatorConditions.push(`${key} > ${operatorValue}`);
|
|
85
|
+
break;
|
|
86
|
+
case "$lt":
|
|
87
|
+
operatorConditions.push(`${key} < ${operatorValue}`);
|
|
88
|
+
break;
|
|
89
|
+
case "$gte":
|
|
90
|
+
operatorConditions.push(`${key} >= ${operatorValue}`);
|
|
91
|
+
break;
|
|
92
|
+
case "$lte":
|
|
93
|
+
operatorConditions.push(`${key} <= ${operatorValue}`);
|
|
94
|
+
break;
|
|
95
|
+
case "$ne":
|
|
96
|
+
operatorConditions.push(`${key} != '${operatorValue}'`);
|
|
97
|
+
break;
|
|
98
|
+
case "$in":
|
|
99
|
+
const inValues = operatorValue.map((val: any) => typeof val === 'string' ? `'${val}'` : val).join(', ');
|
|
100
|
+
operatorConditions.push(`${key} IN (${inValues})`);
|
|
101
|
+
break;
|
|
102
|
+
case "$like":
|
|
103
|
+
operatorConditions.push(`${key} LIKE '%${operatorValue}%'`);
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
throw new Error(`Unsupported operator: ${operator}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Join all conditions for a field with AND
|
|
110
|
+
condition = operatorConditions.join(' AND ');
|
|
111
|
+
} else {
|
|
112
|
+
// For simple equality condition
|
|
113
|
+
condition = `${key} = '${value}'`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
conditions.push(condition);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Join the conditions with AND
|
|
120
|
+
return conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Example Usage
|
|
124
|
+
const json = {
|
|
125
|
+
"age": { "$gt": 30 },
|
|
126
|
+
"name": { "$eq": "John" },
|
|
127
|
+
"status": { "$in": ["active", "pending"] },
|
|
128
|
+
"address.city": { "$eq": "New York" }
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const query = jsonToSqlQuery(json);
|
|
132
|
+
console.log(query);
|