mp-js-api 0.0.8 → 0.0.10
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/api.d.ts +6 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1 -2
- package/dist/index.d.ts +31 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -11
- package/dist/tables/contact-email-addresses.d.ts +18 -0
- package/dist/tables/contact-email-addresses.d.ts.map +1 -0
- package/dist/tables/contact-email-addresses.js +2 -0
- package/dist/utils/strings.d.ts.map +1 -1
- package/dist/utils/strings.js +2 -1
- package/package.json +1 -1
- package/src/api.ts +4 -5
- package/src/index.ts +54 -34
- package/src/utils/strings.ts +2 -1
package/dist/api.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ export type APIGetOneInstance = <T, R>({ id, path, mpOptions, config }: APIGetPa
|
|
|
4
4
|
}) => Promise<R | undefined | {
|
|
5
5
|
error: ErrorDetails;
|
|
6
6
|
}>;
|
|
7
|
-
export type APIGetMultipleInstance = <T, R>({ path, mpOptions, config }: APIGetParameter
|
|
7
|
+
export type APIGetMultipleInstance = <T, R>({ path, mpOptions, config }: APIGetParameter & {
|
|
8
|
+
mpOptions: MPGetOptions;
|
|
9
|
+
}) => Promise<R[] | {
|
|
8
10
|
error: ErrorDetails;
|
|
9
11
|
}>;
|
|
10
12
|
export type APICreateOneInstance = <T, R>({ path, mpOptions, params, config }: APICreateOneParameter<T>) => Promise<R | {
|
|
@@ -29,13 +31,12 @@ export interface MPApiBase {
|
|
|
29
31
|
}
|
|
30
32
|
export interface ErrorDetails {
|
|
31
33
|
message: string;
|
|
32
|
-
name
|
|
34
|
+
name?: string;
|
|
33
35
|
code?: string;
|
|
34
36
|
status?: number;
|
|
35
37
|
method?: string;
|
|
36
38
|
url?: string;
|
|
37
|
-
data
|
|
38
|
-
error: true;
|
|
39
|
+
data?: string;
|
|
39
40
|
}
|
|
40
41
|
export declare const createApiBase: ({ auth }: {
|
|
41
42
|
auth: {
|
|
@@ -80,5 +81,6 @@ interface APIUpdateParameter<T> {
|
|
|
80
81
|
mpOptions?: MPCreateOptions;
|
|
81
82
|
config?: AxiosRequestConfig;
|
|
82
83
|
}
|
|
84
|
+
export type DateTimeIsoString = `${number}-${number}-${number}T${number}:${number}:${number}`;
|
|
83
85
|
export {};
|
|
84
86
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,UAAU,EAAE,aAAa,EAAE,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAK5F,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,eAAe,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;CAAE,KAAK,OAAO,CAAC,CAAC,GAAG,SAAS,GAAG;IAAE,KAAK,EAAE,YAAY,CAAC;CAAE,CAAC,CAAC;AAChK,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,eAAe,KAAK,OAAO,CAAC,CAAC,EAAE,GAAG;IAAE,KAAK,EAAE,YAAY,CAAC;CAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,UAAU,EAAE,aAAa,EAAE,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAK5F,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,eAAe,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;CAA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AAC,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CAAC,CAAC;IACV,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AACD,UAAU,sBAAsB,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAED,UAAU,kBAAkB,CAAC,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,MAAM,iBAAiB,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC"}
|
package/dist/api.js
CHANGED
|
@@ -149,7 +149,6 @@ const createApiBase = ({ auth }) => {
|
|
|
149
149
|
});
|
|
150
150
|
const getError = function (error) {
|
|
151
151
|
return {
|
|
152
|
-
error: true,
|
|
153
152
|
message: error.message,
|
|
154
153
|
name: error.name,
|
|
155
154
|
code: error.code,
|
|
@@ -167,7 +166,7 @@ const createApiBase = ({ auth }) => {
|
|
|
167
166
|
put,
|
|
168
167
|
post,
|
|
169
168
|
getOne,
|
|
170
|
-
getMany
|
|
169
|
+
getMany,
|
|
171
170
|
getError
|
|
172
171
|
};
|
|
173
172
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MPApiBase, ErrorDetails, MPGetOptions, MPCreateOptions, MPUpdateOptions } from './api';
|
|
1
|
+
import { MPApiBase, ErrorDetails, MPGetOptions, MPCreateOptions, MPUpdateOptions, DateTimeIsoString } from './api';
|
|
2
2
|
import { convertToCamelCase, convertToSnakeCase, escapeSql, stringifyURLParams } from './utils/strings';
|
|
3
3
|
import { Contact } from './tables/contacts';
|
|
4
4
|
import { Event } from './tables/events';
|
|
@@ -12,7 +12,11 @@ import { ContactAttribute } from './tables/contact-attributes';
|
|
|
12
12
|
import { FormResponse } from './tables/form-responses';
|
|
13
13
|
import { FormResponseAnswer } from './tables/from-response-answers';
|
|
14
14
|
import { AxiosInstance } from 'axios';
|
|
15
|
-
|
|
15
|
+
import { ContactEmailAddress } from './tables/contact-email-addresses';
|
|
16
|
+
export type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
17
|
+
export type AtLeastOne<T> = {
|
|
18
|
+
[K in keyof T]-?: Required<Pick<T, K>>;
|
|
19
|
+
}[keyof T];
|
|
16
20
|
export type CreateContactParams = WithRequired<Omit<Partial<Contact>, 'contactID'>, 'company' | 'displayName'>;
|
|
17
21
|
export type CreateHouseholdParams = WithRequired<Partial<Household>, 'householdName'>;
|
|
18
22
|
export type CreateAddressParams = WithRequired<Partial<Address>, 'addressLine1'>;
|
|
@@ -22,6 +26,7 @@ export type CreateGroupParticipantParams = WithRequired<Partial<GroupParticipant
|
|
|
22
26
|
export type CreateContactAttributeParams = WithRequired<Partial<ContactAttribute>, 'attributeID' | 'contactID' | 'startDate'>;
|
|
23
27
|
export type CreateFormResponseParams = WithRequired<Omit<Partial<FormResponse>, 'formResponseID'>, 'formID' | 'responseDate'>;
|
|
24
28
|
export type CreateFormResponseAnswerParams = WithRequired<Omit<Partial<FormResponseAnswer>, 'formResponseAnswerID'>, 'formFieldID' | 'formResponseID'>;
|
|
29
|
+
export type CreateContactEmailAddressParams = WithRequired<Omit<Partial<ContactEmailAddress>, 'emailAddressID'>, 'emailAddress' | 'contactID'>;
|
|
25
30
|
export type MPInstance = {
|
|
26
31
|
get: AxiosInstance['get'];
|
|
27
32
|
put: AxiosInstance['put'];
|
|
@@ -34,6 +39,12 @@ export type MPInstance = {
|
|
|
34
39
|
getContact(id: number, options?: MPGetOptions): Promise<Contact | undefined | {
|
|
35
40
|
error: ErrorDetails;
|
|
36
41
|
}>;
|
|
42
|
+
getContactAttribute(id: number, options?: MPGetOptions): Promise<ContactAttribute | undefined | {
|
|
43
|
+
error: ErrorDetails;
|
|
44
|
+
}>;
|
|
45
|
+
getContactEmailAddress(id: number, options?: MPGetOptions): Promise<ContactEmailAddress | undefined | {
|
|
46
|
+
error: ErrorDetails;
|
|
47
|
+
}>;
|
|
37
48
|
getHousehold(id: number, options?: MPGetOptions): Promise<Household | undefined | {
|
|
38
49
|
error: ErrorDetails;
|
|
39
50
|
}>;
|
|
@@ -43,9 +54,6 @@ export type MPInstance = {
|
|
|
43
54
|
getParticipant(id: number, options?: MPGetOptions): Promise<Participant | undefined | {
|
|
44
55
|
error: ErrorDetails;
|
|
45
56
|
}>;
|
|
46
|
-
getContactAttribute(id: number, options?: MPGetOptions): Promise<ContactAttribute | undefined | {
|
|
47
|
-
error: ErrorDetails;
|
|
48
|
-
}>;
|
|
49
57
|
getEvent(id: number, options?: MPGetOptions): Promise<Event | undefined | {
|
|
50
58
|
error: ErrorDetails;
|
|
51
59
|
}>;
|
|
@@ -61,28 +69,34 @@ export type MPInstance = {
|
|
|
61
69
|
getFormResponse(id: number, options?: MPGetOptions): Promise<FormResponse | undefined | {
|
|
62
70
|
error: ErrorDetails;
|
|
63
71
|
}>;
|
|
64
|
-
getContacts(options
|
|
72
|
+
getContacts(options: AtLeastOne<MPGetOptions>): Promise<Contact[] | {
|
|
73
|
+
error: ErrorDetails;
|
|
74
|
+
}>;
|
|
75
|
+
getContactAttributes(options: AtLeastOne<MPGetOptions>): Promise<ContactAttribute[] | {
|
|
65
76
|
error: ErrorDetails;
|
|
66
77
|
}>;
|
|
67
|
-
|
|
78
|
+
getContactEmailAddresses(options: AtLeastOne<MPGetOptions>): Promise<ContactEmailAddress[] | {
|
|
68
79
|
error: ErrorDetails;
|
|
69
80
|
}>;
|
|
70
|
-
|
|
81
|
+
getHouseholds(options: AtLeastOne<MPGetOptions>): Promise<Household[] | {
|
|
71
82
|
error: ErrorDetails;
|
|
72
83
|
}>;
|
|
73
|
-
|
|
84
|
+
getAddresses(options: AtLeastOne<MPGetOptions>): Promise<Address[] | {
|
|
74
85
|
error: ErrorDetails;
|
|
75
86
|
}>;
|
|
76
|
-
|
|
87
|
+
getParticipants(options: AtLeastOne<MPGetOptions>): Promise<Participant[] | {
|
|
77
88
|
error: ErrorDetails;
|
|
78
89
|
}>;
|
|
79
|
-
|
|
90
|
+
getEvents(options: AtLeastOne<MPGetOptions>): Promise<Event[] | {
|
|
80
91
|
error: ErrorDetails;
|
|
81
92
|
}>;
|
|
82
|
-
|
|
93
|
+
getGroups(options: AtLeastOne<MPGetOptions>): Promise<Group[] | {
|
|
83
94
|
error: ErrorDetails;
|
|
84
95
|
}>;
|
|
85
|
-
|
|
96
|
+
getEventParticipants(options: AtLeastOne<MPGetOptions>): Promise<EventParticipant[] | {
|
|
97
|
+
error: ErrorDetails;
|
|
98
|
+
}>;
|
|
99
|
+
getGroupParticipants(options: AtLeastOne<MPGetOptions>): Promise<GroupParticipant[] | {
|
|
86
100
|
error: ErrorDetails;
|
|
87
101
|
}>;
|
|
88
102
|
createContact(params: CreateContactParams, options?: MPCreateOptions): Promise<Contact | {
|
|
@@ -112,6 +126,9 @@ export type MPInstance = {
|
|
|
112
126
|
createFormResponseAnswers(params: CreateFormResponseAnswerParams[], options?: MPCreateOptions): Promise<FormResponseAnswer[] | {
|
|
113
127
|
error: ErrorDetails;
|
|
114
128
|
}>;
|
|
129
|
+
createContactEmailAddress(params: CreateContactEmailAddressParams[], options?: MPCreateOptions): Promise<ContactEmailAddress[] | {
|
|
130
|
+
error: ErrorDetails;
|
|
131
|
+
}>;
|
|
115
132
|
updateContacts(contacts: WithRequired<Partial<Contact>, 'contactID'>[], options?: MPUpdateOptions): Promise<Contact[] | {
|
|
116
133
|
error: ErrorDetails;
|
|
117
134
|
}>;
|
|
@@ -125,5 +142,5 @@ export declare const createMPInstance: ({ auth }: {
|
|
|
125
142
|
password: string;
|
|
126
143
|
};
|
|
127
144
|
}) => MPInstance;
|
|
128
|
-
export { Contact, Participant, Event, Group, EventParticipant, GroupParticipant, ContactAttribute, Household, Address, FormResponse, FormResponseAnswer, ErrorDetails, convertToCamelCase, convertToSnakeCase, stringifyURLParams, escapeSql };
|
|
145
|
+
export { Contact, Participant, Event, Group, EventParticipant, GroupParticipant, ContactAttribute, Household, Address, FormResponse, FormResponseAnswer, ContactEmailAddress, ErrorDetails, DateTimeIsoString, convertToCamelCase, convertToSnakeCase, stringifyURLParams, escapeSql };
|
|
129
146
|
//# sourceMappingURL=index.d.ts.map
|
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,EAAiB,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAClI,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,OAAO,EAAiB,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAe,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAe,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAiB,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAmB,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAqB,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,gBA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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,UAoL/F,CAAC;AAEF,OAAO,EACL,OAAO,EACP,WAAW,EACX,KAAK,EACL,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,EACV,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,12 @@ const createMPInstance = ({ auth }) => {
|
|
|
21
21
|
async getContact(id, mpOptions = {}) {
|
|
22
22
|
return getOne({ path: `/tables/contacts`, id, mpOptions });
|
|
23
23
|
},
|
|
24
|
+
async getContactAttribute(id, mpOptions = {}) {
|
|
25
|
+
return getOne({ path: `/tables/contact_attributes`, id, mpOptions });
|
|
26
|
+
},
|
|
27
|
+
async getContactEmailAddress(id, mpOptions = {}) {
|
|
28
|
+
return getOne({ path: `/tables/contact_email_addresses`, id, mpOptions });
|
|
29
|
+
},
|
|
24
30
|
async getHousehold(id, mpOptions = {}) {
|
|
25
31
|
return getOne({ path: `/tables/households`, id, mpOptions });
|
|
26
32
|
},
|
|
@@ -30,9 +36,6 @@ const createMPInstance = ({ auth }) => {
|
|
|
30
36
|
async getParticipant(id, mpOptions = {}) {
|
|
31
37
|
return getOne({ path: `/tables/participants`, id, mpOptions });
|
|
32
38
|
},
|
|
33
|
-
async getContactAttribute(id, mpOptions = {}) {
|
|
34
|
-
return getOne({ path: `/tables/participants`, id, mpOptions });
|
|
35
|
-
},
|
|
36
39
|
async getEvent(id, mpOptions = {}) {
|
|
37
40
|
return getOne({ path: `/tables/events`, id, mpOptions });
|
|
38
41
|
},
|
|
@@ -48,28 +51,34 @@ const createMPInstance = ({ auth }) => {
|
|
|
48
51
|
async getFormResponse(id, mpOptions = {}) {
|
|
49
52
|
return getOne({ path: `/tables/form_responses`, id, mpOptions });
|
|
50
53
|
},
|
|
51
|
-
async getContacts(mpOptions
|
|
54
|
+
async getContacts(mpOptions) {
|
|
52
55
|
return getMany({ path: `/tables/contacts`, mpOptions });
|
|
53
56
|
},
|
|
54
|
-
async
|
|
57
|
+
async getContactAttributes(mpOptions) {
|
|
58
|
+
return getMany({ path: `/tables/contact_attributes`, mpOptions });
|
|
59
|
+
},
|
|
60
|
+
async getContactEmailAddresses(mpOptions) {
|
|
61
|
+
return getMany({ path: `/tables/contact_email_addresses`, mpOptions });
|
|
62
|
+
},
|
|
63
|
+
async getHouseholds(mpOptions) {
|
|
55
64
|
return getMany({ path: `/tables/households`, mpOptions });
|
|
56
65
|
},
|
|
57
|
-
async getAddresses(mpOptions
|
|
66
|
+
async getAddresses(mpOptions) {
|
|
58
67
|
return getMany({ path: `/tables/addresses`, mpOptions });
|
|
59
68
|
},
|
|
60
|
-
async getParticipants(mpOptions
|
|
69
|
+
async getParticipants(mpOptions) {
|
|
61
70
|
return getMany({ path: `/tables/participants`, mpOptions });
|
|
62
71
|
},
|
|
63
|
-
async getEvents(mpOptions
|
|
72
|
+
async getEvents(mpOptions) {
|
|
64
73
|
return getMany({ path: `/tables/events`, mpOptions });
|
|
65
74
|
},
|
|
66
|
-
async getGroups(mpOptions
|
|
75
|
+
async getGroups(mpOptions) {
|
|
67
76
|
return getMany({ path: `/tables/groups`, mpOptions });
|
|
68
77
|
},
|
|
69
|
-
async getEventParticipants(mpOptions
|
|
78
|
+
async getEventParticipants(mpOptions) {
|
|
70
79
|
return getMany({ path: `/tables/event_participants`, mpOptions });
|
|
71
80
|
},
|
|
72
|
-
async getGroupParticipants(mpOptions
|
|
81
|
+
async getGroupParticipants(mpOptions) {
|
|
73
82
|
return getMany({ path: `/tables/group_participants`, mpOptions });
|
|
74
83
|
},
|
|
75
84
|
async createContact(params, mpOptions = {}) {
|
|
@@ -99,6 +108,9 @@ const createMPInstance = ({ auth }) => {
|
|
|
99
108
|
async createFormResponseAnswers(params, mpOptions) {
|
|
100
109
|
return createMany({ path: `/tables/form_response_answers`, mpOptions, params });
|
|
101
110
|
},
|
|
111
|
+
async createContactEmailAddress(params, mpOptions) {
|
|
112
|
+
return createMany({ path: `/tables/contact_email_addresses`, mpOptions, params });
|
|
113
|
+
},
|
|
102
114
|
async updateContacts(params, mpOptions) {
|
|
103
115
|
return update({ path: `/tables/contacts`, mpOptions, params });
|
|
104
116
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DateTimeIsoString } from "../api";
|
|
2
|
+
export interface ContactEmailAddressRecord {
|
|
3
|
+
Email_Address_ID: number;
|
|
4
|
+
Email_Address: string;
|
|
5
|
+
Contact_ID: number;
|
|
6
|
+
Email_Type_ID?: number;
|
|
7
|
+
End_Date?: DateTimeIsoString | null;
|
|
8
|
+
Notes?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface ContactEmailAddress {
|
|
11
|
+
emailAddressID: number;
|
|
12
|
+
emailAddress: string;
|
|
13
|
+
contactID: number;
|
|
14
|
+
emailTypeID?: number;
|
|
15
|
+
endDate?: DateTimeIsoString | null;
|
|
16
|
+
notes?: string | null;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=contact-email-addresses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contact-email-addresses.d.ts","sourceRoot":"","sources":["../../src/tables/contact-email-addresses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/utils/strings.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAM,UAS5E;AAGD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,UA2BpC;AAID,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,UAAkB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;CAAM,
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/utils/strings.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAM,UAS5E;AAGD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,UA2BpC;AAID,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,UAAkB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;CAAM,UAO7F;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,UAAkB,EAAE,YAAmB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CAAM,UAKjJ;AAGD,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,UAAkB,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAAE,OAkB5H;AAED,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,UAAO,GAAG,CAAC,CAE1F;AAED,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,UAAO,GAAG,CAAC,CAE1F"}
|
package/dist/utils/strings.js
CHANGED
|
@@ -48,7 +48,8 @@ function escapeSql(str) {
|
|
|
48
48
|
}
|
|
49
49
|
function toCamelCase(str, { capitalIds = false } = {}) {
|
|
50
50
|
str = str.replace('-', '');
|
|
51
|
-
str = str.
|
|
51
|
+
str = str.toLowerCase();
|
|
52
|
+
// str = str.replace(/^_?[A-Z]{1,3}/, match => match.toLowerCase()); // Don't convert if start with ID, HS, SMS, etc
|
|
52
53
|
str = str.replace(/(?<=^_|^__)[^\W_]/g, match => match.at(-1)?.toLowerCase() || ''); // keep underscore if first char
|
|
53
54
|
str = str.replace(/(?<!^_|^)_[^\W_]/g, match => match.charAt(1).toUpperCase()); // remove underscore if not first char
|
|
54
55
|
return capitalIds ? str.replace(/id$/i, 'ID') : str;
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { convertToCamelCase, convertToSnakeCase, stringifyURLParams } from './ut
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export type APIGetOneInstance = <T, R>({ id, path, mpOptions, config }: APIGetParameter & { id: number; }) => Promise<R | undefined | { error: ErrorDetails; }>;
|
|
7
|
-
export type APIGetMultipleInstance = <T, R>({ path, mpOptions, config }: APIGetParameter) => Promise<R[] | { error: ErrorDetails; }>;
|
|
7
|
+
export type APIGetMultipleInstance = <T, R>({ path, mpOptions, config }: APIGetParameter & { mpOptions: MPGetOptions; }) => Promise<R[] | { error: ErrorDetails; }>;
|
|
8
8
|
export type APICreateOneInstance = <T, R>({ path, mpOptions, params, config }: APICreateOneParameter<T>) => Promise<R | { error: ErrorDetails; }>;
|
|
9
9
|
export type APICreateManyInstance = <T, R>({ path, mpOptions, params, config }: APICreateManyParameter<T>) => Promise<R[] | { error: ErrorDetails; }>;
|
|
10
10
|
export type APIUpdateInstance = <T, R>({ path, mpOptions, params, config }: APIUpdateParameter<T>) => Promise<R[] | { error: ErrorDetails; }>;
|
|
@@ -93,9 +93,9 @@ export const createApiBase = ({ auth }: { auth: { username: string; password: st
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
const getMany: APIGetMultipleInstance = async <T, R>({
|
|
96
|
+
const getMany: APIGetMultipleInstance = async <T, R>({ path, mpOptions, config }: APIGetParameter) => {
|
|
97
97
|
try {
|
|
98
|
-
const url =
|
|
98
|
+
const url = path + stringifyURLParams(mpOptions);
|
|
99
99
|
const res = await api.get<T[]>(url, {
|
|
100
100
|
...config,
|
|
101
101
|
headers: {
|
|
@@ -229,7 +229,7 @@ export const createApiBase = ({ auth }: { auth: { username: string; password: st
|
|
|
229
229
|
put,
|
|
230
230
|
post,
|
|
231
231
|
getOne,
|
|
232
|
-
getMany
|
|
232
|
+
getMany,
|
|
233
233
|
getError
|
|
234
234
|
};
|
|
235
235
|
};
|
|
@@ -267,7 +267,6 @@ export type MPCreateOptions = {
|
|
|
267
267
|
export type MPUpdateOptions = MPCreateOptions;
|
|
268
268
|
|
|
269
269
|
interface APIGetParameter {
|
|
270
|
-
id?: number;
|
|
271
270
|
path: string;
|
|
272
271
|
mpOptions?: MPGetOptions;
|
|
273
272
|
config?: AxiosRequestConfig;
|
package/src/index.ts
CHANGED
|
@@ -15,8 +15,8 @@ import { AxiosInstance } from 'axios';
|
|
|
15
15
|
import { ContactEmailAddress, ContactEmailAddressRecord } from './tables/contact-email-addresses';
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
19
|
-
|
|
18
|
+
export type WithRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
19
|
+
export type AtLeastOne<T> = { [K in keyof T]-?: Required<Pick<T, K>> }[keyof T];
|
|
20
20
|
|
|
21
21
|
export type CreateContactParams = WithRequired<
|
|
22
22
|
Omit<Partial<Contact>, 'contactID'>,
|
|
@@ -75,6 +75,14 @@ export type MPInstance = {
|
|
|
75
75
|
id: number,
|
|
76
76
|
options?: MPGetOptions
|
|
77
77
|
): Promise<Contact | undefined | { error: ErrorDetails; }>;
|
|
78
|
+
getContactAttribute(
|
|
79
|
+
id: number,
|
|
80
|
+
options?: MPGetOptions
|
|
81
|
+
): Promise<ContactAttribute | undefined | { error: ErrorDetails; }>;
|
|
82
|
+
getContactEmailAddress(
|
|
83
|
+
id: number,
|
|
84
|
+
options?: MPGetOptions
|
|
85
|
+
): Promise<ContactEmailAddress | undefined | { error: ErrorDetails; }>;
|
|
78
86
|
getHousehold(
|
|
79
87
|
id: number,
|
|
80
88
|
options?: MPGetOptions
|
|
@@ -87,10 +95,6 @@ export type MPInstance = {
|
|
|
87
95
|
id: number,
|
|
88
96
|
options?: MPGetOptions
|
|
89
97
|
): Promise<Participant | undefined | { error: ErrorDetails; }>;
|
|
90
|
-
getContactAttribute(
|
|
91
|
-
id: number,
|
|
92
|
-
options?: MPGetOptions
|
|
93
|
-
): Promise<ContactAttribute | undefined | { error: ErrorDetails; }>;
|
|
94
98
|
getEvent(
|
|
95
99
|
id: number,
|
|
96
100
|
options?: MPGetOptions
|
|
@@ -113,28 +117,34 @@ export type MPInstance = {
|
|
|
113
117
|
): Promise<FormResponse | undefined | { error: ErrorDetails; }>;
|
|
114
118
|
|
|
115
119
|
getContacts(
|
|
116
|
-
options
|
|
120
|
+
options: AtLeastOne<MPGetOptions>
|
|
117
121
|
): Promise<Contact[] | { error: ErrorDetails; }>;
|
|
122
|
+
getContactAttributes(
|
|
123
|
+
options: AtLeastOne<MPGetOptions>
|
|
124
|
+
): Promise<ContactAttribute[] | { error: ErrorDetails; }>;
|
|
118
125
|
getContactEmailAddresses(
|
|
119
|
-
|
|
120
|
-
options?: MPGetOptions
|
|
126
|
+
options: AtLeastOne<MPGetOptions>
|
|
121
127
|
): Promise<ContactEmailAddress[] | { error: ErrorDetails; }>;
|
|
122
128
|
getHouseholds(
|
|
123
|
-
options
|
|
129
|
+
options: AtLeastOne<MPGetOptions>
|
|
124
130
|
): Promise<Household[] | { error: ErrorDetails; }>;
|
|
125
131
|
getAddresses(
|
|
126
|
-
options
|
|
132
|
+
options: AtLeastOne<MPGetOptions>
|
|
127
133
|
): Promise<Address[] | { error: ErrorDetails; }>;
|
|
128
134
|
getParticipants(
|
|
129
|
-
options
|
|
135
|
+
options: AtLeastOne<MPGetOptions>
|
|
130
136
|
): Promise<Participant[] | { error: ErrorDetails; }>;
|
|
131
|
-
getEvents(
|
|
132
|
-
|
|
137
|
+
getEvents(
|
|
138
|
+
options: AtLeastOne<MPGetOptions>
|
|
139
|
+
): Promise<Event[] | { error: ErrorDetails; }>;
|
|
140
|
+
getGroups(
|
|
141
|
+
options: AtLeastOne<MPGetOptions>
|
|
142
|
+
): Promise<Group[] | { error: ErrorDetails; }>;
|
|
133
143
|
getEventParticipants(
|
|
134
|
-
options
|
|
144
|
+
options: AtLeastOne<MPGetOptions>
|
|
135
145
|
): Promise<EventParticipant[] | { error: ErrorDetails; }>;
|
|
136
146
|
getGroupParticipants(
|
|
137
|
-
options
|
|
147
|
+
options: AtLeastOne<MPGetOptions>
|
|
138
148
|
): Promise<GroupParticipant[] | { error: ErrorDetails; }>;
|
|
139
149
|
|
|
140
150
|
createContact(
|
|
@@ -207,6 +217,16 @@ export const createMPInstance = ({ auth }: { auth: { username: string; password:
|
|
|
207
217
|
{ path: `/tables/contacts`, id, mpOptions }
|
|
208
218
|
);
|
|
209
219
|
},
|
|
220
|
+
async getContactAttribute(id, mpOptions = {}) {
|
|
221
|
+
return getOne<ContactAttributeRecord, ContactAttribute>(
|
|
222
|
+
{ path: `/tables/contact_attributes`, id, mpOptions }
|
|
223
|
+
);
|
|
224
|
+
},
|
|
225
|
+
async getContactEmailAddress(id, mpOptions = {}) {
|
|
226
|
+
return getOne<ContactEmailAddressRecord, ContactEmailAddress>(
|
|
227
|
+
{ path: `/tables/contact_email_addresses`, id, mpOptions }
|
|
228
|
+
);
|
|
229
|
+
},
|
|
210
230
|
async getHousehold(id, mpOptions = {}) {
|
|
211
231
|
return getOne<HouseholdRecord, Household>(
|
|
212
232
|
{ path: `/tables/households`, id, mpOptions }
|
|
@@ -222,11 +242,6 @@ export const createMPInstance = ({ auth }: { auth: { username: string; password:
|
|
|
222
242
|
{ path: `/tables/participants`, id, mpOptions }
|
|
223
243
|
);
|
|
224
244
|
},
|
|
225
|
-
async getContactAttribute(id, mpOptions = {}) {
|
|
226
|
-
return getOne<ContactAttributeRecord, ContactAttribute>(
|
|
227
|
-
{ path: `/tables/participants`, id, mpOptions }
|
|
228
|
-
);
|
|
229
|
-
},
|
|
230
245
|
async getEvent(id, mpOptions = {}) {
|
|
231
246
|
return getOne<EventRecord, Event>(
|
|
232
247
|
{ path: `/tables/events`, id, mpOptions }
|
|
@@ -252,47 +267,52 @@ export const createMPInstance = ({ auth }: { auth: { username: string; password:
|
|
|
252
267
|
{ path: `/tables/form_responses`, id, mpOptions }
|
|
253
268
|
);
|
|
254
269
|
},
|
|
255
|
-
async getContacts(mpOptions
|
|
270
|
+
async getContacts(mpOptions) {
|
|
256
271
|
return getMany<ContactRecord, Contact>(
|
|
257
272
|
{ path: `/tables/contacts`, mpOptions }
|
|
258
273
|
);
|
|
259
274
|
},
|
|
260
|
-
async
|
|
275
|
+
async getContactAttributes(mpOptions) {
|
|
276
|
+
return getMany<ContactAttributeRecord, ContactAttribute>(
|
|
277
|
+
{ path: `/tables/contact_attributes`, mpOptions }
|
|
278
|
+
);
|
|
279
|
+
},
|
|
280
|
+
async getContactEmailAddresses(mpOptions) {
|
|
281
|
+
return getMany<ContactEmailAddressRecord, ContactEmailAddress>(
|
|
282
|
+
{ path: `/tables/contact_email_addresses`, mpOptions }
|
|
283
|
+
);
|
|
284
|
+
},
|
|
285
|
+
async getHouseholds(mpOptions) {
|
|
261
286
|
return getMany<HouseholdRecord, Household>(
|
|
262
287
|
{ path: `/tables/households`, mpOptions }
|
|
263
288
|
);
|
|
264
289
|
},
|
|
265
|
-
async getAddresses(mpOptions
|
|
290
|
+
async getAddresses(mpOptions) {
|
|
266
291
|
return getMany<AddressRecord, Address>(
|
|
267
292
|
{ path: `/tables/addresses`, mpOptions }
|
|
268
293
|
);
|
|
269
294
|
},
|
|
270
|
-
async
|
|
271
|
-
return getMany<ContactEmailAddressRecord, ContactEmailAddress>(
|
|
272
|
-
{ path: `/tables/contact_email_addresses`, id, mpOptions }
|
|
273
|
-
);
|
|
274
|
-
},
|
|
275
|
-
async getParticipants(mpOptions = {}) {
|
|
295
|
+
async getParticipants(mpOptions) {
|
|
276
296
|
return getMany<ParticipantRecord, Participant>(
|
|
277
297
|
{ path: `/tables/participants`, mpOptions }
|
|
278
298
|
);
|
|
279
299
|
},
|
|
280
|
-
async getEvents(mpOptions
|
|
300
|
+
async getEvents(mpOptions) {
|
|
281
301
|
return getMany<EventRecord, Event>(
|
|
282
302
|
{ path: `/tables/events`, mpOptions }
|
|
283
303
|
);
|
|
284
304
|
},
|
|
285
|
-
async getGroups(mpOptions
|
|
305
|
+
async getGroups(mpOptions) {
|
|
286
306
|
return getMany<GroupRecord, Group>(
|
|
287
307
|
{ path: `/tables/groups`, mpOptions }
|
|
288
308
|
);
|
|
289
309
|
},
|
|
290
|
-
async getEventParticipants(mpOptions
|
|
310
|
+
async getEventParticipants(mpOptions) {
|
|
291
311
|
return getMany<EventParticipantRecord, EventParticipant>(
|
|
292
312
|
{ path: `/tables/event_participants`, mpOptions }
|
|
293
313
|
);
|
|
294
314
|
},
|
|
295
|
-
async getGroupParticipants(mpOptions
|
|
315
|
+
async getGroupParticipants(mpOptions) {
|
|
296
316
|
return getMany<GroupParticipantRecord, GroupParticipant>(
|
|
297
317
|
{ path: `/tables/group_participants`, mpOptions }
|
|
298
318
|
);
|
package/src/utils/strings.ts
CHANGED
|
@@ -43,7 +43,8 @@ export function escapeSql(str: string) {
|
|
|
43
43
|
|
|
44
44
|
export function toCamelCase(str: string, { capitalIds = false }: { capitalIds?: boolean; }= {}) {
|
|
45
45
|
str = str.replace('-', '')
|
|
46
|
-
str = str.
|
|
46
|
+
str = str.toLowerCase();
|
|
47
|
+
// str = str.replace(/^_?[A-Z]{1,3}/, match => match.toLowerCase()); // Don't convert if start with ID, HS, SMS, etc
|
|
47
48
|
str = str.replace(/(?<=^_|^__)[^\W_]/g, match => match.at(-1)?.toLowerCase() || ''); // keep underscore if first char
|
|
48
49
|
str = str.replace(/(?<!^_|^)_[^\W_]/g, match => match.charAt(1).toUpperCase()); // remove underscore if not first char
|
|
49
50
|
return capitalIds ? str.replace(/id$/i, 'ID') : str;
|