@withloops.ai/contracts 0.3.0 → 0.4.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/dist/api.d.ts +153 -0
- package/dist/api.js +86 -0
- package/dist/fields.d.ts +6 -0
- package/dist/fields.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/manifest.d.ts +519 -3
- package/dist/manifest.js +163 -3
- package/dist/registry.d.ts +152 -1
- package/dist/sync.d.ts +338 -0
- package/dist/sync.js +123 -0
- package/dist/trust.d.ts +31 -0
- package/dist/trust.js +20 -0
- package/examples/attio-sync.manifest.json +146 -0
- package/package.json +1 -1
- package/src/api.ts +110 -0
- package/src/fields.ts +11 -0
- package/src/index.ts +2 -0
- package/src/manifest.ts +163 -3
- package/src/sync.ts +229 -0
- package/src/trust.ts +25 -0
package/dist/api.d.ts
CHANGED
|
@@ -112,6 +112,14 @@ export declare const ListQuery: z.ZodObject<{
|
|
|
112
112
|
updatedSince: z.ZodOptional<z.ZodISODateTime>;
|
|
113
113
|
}, z.core.$strip>;
|
|
114
114
|
export type ListQuery = z.infer<typeof ListQuery>;
|
|
115
|
+
/** Where the record also lives (`ExternalRef` in sync.ts), shown so a developer can find their own id. Added in 0.4.0. */
|
|
116
|
+
export declare const RecordRef: z.ZodObject<{
|
|
117
|
+
appId: z.ZodString;
|
|
118
|
+
object: z.ZodString;
|
|
119
|
+
externalId: z.ZodString;
|
|
120
|
+
lockedFields: z.ZodArray<z.ZodString>;
|
|
121
|
+
}, z.core.$strip>;
|
|
122
|
+
export type RecordRef = z.infer<typeof RecordRef>;
|
|
115
123
|
/** A Loops contact as the public API shows it. camelCase, ids as strings, dates ISO. */
|
|
116
124
|
export declare const Contact: z.ZodObject<{
|
|
117
125
|
id: z.ZodString;
|
|
@@ -122,6 +130,12 @@ export declare const Contact: z.ZodObject<{
|
|
|
122
130
|
jobTitle: z.ZodNullable<z.ZodString>;
|
|
123
131
|
companyId: z.ZodNullable<z.ZodString>;
|
|
124
132
|
ownerId: z.ZodNullable<z.ZodString>;
|
|
133
|
+
refs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
134
|
+
appId: z.ZodString;
|
|
135
|
+
object: z.ZodString;
|
|
136
|
+
externalId: z.ZodString;
|
|
137
|
+
lockedFields: z.ZodArray<z.ZodString>;
|
|
138
|
+
}, z.core.$strip>>>;
|
|
125
139
|
createdAt: z.ZodISODateTime;
|
|
126
140
|
updatedAt: z.ZodISODateTime;
|
|
127
141
|
}, z.core.$strip>;
|
|
@@ -146,3 +160,142 @@ export declare const ContactUpdate: z.ZodObject<{
|
|
|
146
160
|
ownerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
147
161
|
}, z.core.$strip>;
|
|
148
162
|
export type ContactUpdate = z.infer<typeof ContactUpdate>;
|
|
163
|
+
export declare const Company: z.ZodObject<{
|
|
164
|
+
id: z.ZodString;
|
|
165
|
+
name: z.ZodNullable<z.ZodString>;
|
|
166
|
+
website: z.ZodNullable<z.ZodString>;
|
|
167
|
+
domain: z.ZodNullable<z.ZodString>;
|
|
168
|
+
phone: z.ZodNullable<z.ZodString>;
|
|
169
|
+
industry: z.ZodNullable<z.ZodString>;
|
|
170
|
+
ownerId: z.ZodNullable<z.ZodString>;
|
|
171
|
+
refs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
172
|
+
appId: z.ZodString;
|
|
173
|
+
object: z.ZodString;
|
|
174
|
+
externalId: z.ZodString;
|
|
175
|
+
lockedFields: z.ZodArray<z.ZodString>;
|
|
176
|
+
}, z.core.$strip>>>;
|
|
177
|
+
createdAt: z.ZodISODateTime;
|
|
178
|
+
updatedAt: z.ZodISODateTime;
|
|
179
|
+
}, z.core.$strip>;
|
|
180
|
+
export type Company = z.infer<typeof Company>;
|
|
181
|
+
export declare const CompanyCreate: z.ZodObject<{
|
|
182
|
+
name: z.ZodString;
|
|
183
|
+
website: z.ZodOptional<z.ZodString>;
|
|
184
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
185
|
+
industry: z.ZodOptional<z.ZodString>;
|
|
186
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
export type CompanyCreate = z.infer<typeof CompanyCreate>;
|
|
189
|
+
export declare const CompanyUpdate: z.ZodObject<{
|
|
190
|
+
name: z.ZodOptional<z.ZodString>;
|
|
191
|
+
website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
192
|
+
phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
193
|
+
industry: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
194
|
+
ownerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
195
|
+
}, z.core.$strip>;
|
|
196
|
+
export type CompanyUpdate = z.infer<typeof CompanyUpdate>;
|
|
197
|
+
export declare const Deal: z.ZodObject<{
|
|
198
|
+
id: z.ZodString;
|
|
199
|
+
name: z.ZodNullable<z.ZodString>;
|
|
200
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
201
|
+
currency: z.ZodNullable<z.ZodString>;
|
|
202
|
+
stage: z.ZodNullable<z.ZodString>;
|
|
203
|
+
closeDate: z.ZodNullable<z.ZodString>;
|
|
204
|
+
companyId: z.ZodNullable<z.ZodString>;
|
|
205
|
+
ownerId: z.ZodNullable<z.ZodString>;
|
|
206
|
+
refs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
207
|
+
appId: z.ZodString;
|
|
208
|
+
object: z.ZodString;
|
|
209
|
+
externalId: z.ZodString;
|
|
210
|
+
lockedFields: z.ZodArray<z.ZodString>;
|
|
211
|
+
}, z.core.$strip>>>;
|
|
212
|
+
createdAt: z.ZodISODateTime;
|
|
213
|
+
updatedAt: z.ZodISODateTime;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
export type Deal = z.infer<typeof Deal>;
|
|
216
|
+
export declare const DealCreate: z.ZodObject<{
|
|
217
|
+
name: z.ZodString;
|
|
218
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
219
|
+
currency: z.ZodOptional<z.ZodString>;
|
|
220
|
+
stage: z.ZodOptional<z.ZodString>;
|
|
221
|
+
closeDate: z.ZodOptional<z.ZodString>;
|
|
222
|
+
companyId: z.ZodOptional<z.ZodString>;
|
|
223
|
+
ownerId: z.ZodOptional<z.ZodString>;
|
|
224
|
+
}, z.core.$strip>;
|
|
225
|
+
export type DealCreate = z.infer<typeof DealCreate>;
|
|
226
|
+
export declare const DealUpdate: z.ZodObject<{
|
|
227
|
+
name: z.ZodOptional<z.ZodString>;
|
|
228
|
+
value: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
229
|
+
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
230
|
+
stage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
231
|
+
closeDate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
232
|
+
companyId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
233
|
+
ownerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
234
|
+
}, z.core.$strip>;
|
|
235
|
+
export type DealUpdate = z.infer<typeof DealUpdate>;
|
|
236
|
+
/** Loops record kinds as the API names them in links. */
|
|
237
|
+
export declare const LinkKind: z.ZodEnum<{
|
|
238
|
+
contact: "contact";
|
|
239
|
+
company: "company";
|
|
240
|
+
lead: "lead";
|
|
241
|
+
deal: "deal";
|
|
242
|
+
}>;
|
|
243
|
+
export type LinkKind = z.infer<typeof LinkKind>;
|
|
244
|
+
/** A link between two records (`recordLinks` in Vista): a deal holds many people, each with a role. */
|
|
245
|
+
export declare const RecordLink: z.ZodObject<{
|
|
246
|
+
id: z.ZodString;
|
|
247
|
+
from: z.ZodObject<{
|
|
248
|
+
kind: z.ZodEnum<{
|
|
249
|
+
contact: "contact";
|
|
250
|
+
company: "company";
|
|
251
|
+
lead: "lead";
|
|
252
|
+
deal: "deal";
|
|
253
|
+
}>;
|
|
254
|
+
id: z.ZodString;
|
|
255
|
+
}, z.core.$strip>;
|
|
256
|
+
to: z.ZodObject<{
|
|
257
|
+
kind: z.ZodEnum<{
|
|
258
|
+
contact: "contact";
|
|
259
|
+
company: "company";
|
|
260
|
+
lead: "lead";
|
|
261
|
+
deal: "deal";
|
|
262
|
+
}>;
|
|
263
|
+
id: z.ZodString;
|
|
264
|
+
}, z.core.$strip>;
|
|
265
|
+
role: z.ZodNullable<z.ZodString>;
|
|
266
|
+
createdAt: z.ZodISODateTime;
|
|
267
|
+
}, z.core.$strip>;
|
|
268
|
+
export type RecordLink = z.infer<typeof RecordLink>;
|
|
269
|
+
export declare const RecordLinkCreate: z.ZodObject<{
|
|
270
|
+
from: z.ZodObject<{
|
|
271
|
+
kind: z.ZodEnum<{
|
|
272
|
+
contact: "contact";
|
|
273
|
+
company: "company";
|
|
274
|
+
lead: "lead";
|
|
275
|
+
deal: "deal";
|
|
276
|
+
}>;
|
|
277
|
+
id: z.ZodString;
|
|
278
|
+
}, z.core.$strip>;
|
|
279
|
+
to: z.ZodObject<{
|
|
280
|
+
kind: z.ZodEnum<{
|
|
281
|
+
contact: "contact";
|
|
282
|
+
company: "company";
|
|
283
|
+
lead: "lead";
|
|
284
|
+
deal: "deal";
|
|
285
|
+
}>;
|
|
286
|
+
id: z.ZodString;
|
|
287
|
+
}, z.core.$strip>;
|
|
288
|
+
role: z.ZodOptional<z.ZodString>;
|
|
289
|
+
}, z.core.$strip>;
|
|
290
|
+
export type RecordLinkCreate = z.infer<typeof RecordLinkCreate>;
|
|
291
|
+
/** `GET /v1/links?kind=deal&id=…`: the links of one record, either end. */
|
|
292
|
+
export declare const RecordLinkQuery: z.ZodObject<{
|
|
293
|
+
kind: z.ZodEnum<{
|
|
294
|
+
contact: "contact";
|
|
295
|
+
company: "company";
|
|
296
|
+
lead: "lead";
|
|
297
|
+
deal: "deal";
|
|
298
|
+
}>;
|
|
299
|
+
id: z.ZodString;
|
|
300
|
+
}, z.core.$strip>;
|
|
301
|
+
export type RecordLinkQuery = z.infer<typeof RecordLinkQuery>;
|
package/dist/api.js
CHANGED
|
@@ -60,6 +60,14 @@ export const ListQuery = z.object({
|
|
|
60
60
|
updatedSince: Timestamp.optional(),
|
|
61
61
|
});
|
|
62
62
|
// ── Resources (L0: contacts) ────────────────────────────────────────────────────
|
|
63
|
+
/** Where the record also lives (`ExternalRef` in sync.ts), shown so a developer can find their own id. Added in 0.4.0. */
|
|
64
|
+
export const RecordRef = z.object({
|
|
65
|
+
appId: z.string(),
|
|
66
|
+
object: z.string(),
|
|
67
|
+
externalId: z.string(),
|
|
68
|
+
/** Fields that CRM owns on this record; a PATCH to one answers `conflict`. */
|
|
69
|
+
lockedFields: z.array(z.string()),
|
|
70
|
+
});
|
|
63
71
|
/** A Loops contact as the public API shows it. camelCase, ids as strings, dates ISO. */
|
|
64
72
|
export const Contact = z.object({
|
|
65
73
|
id: z.string(),
|
|
@@ -70,6 +78,8 @@ export const Contact = z.object({
|
|
|
70
78
|
jobTitle: z.string().nullable(),
|
|
71
79
|
companyId: z.string().nullable(),
|
|
72
80
|
ownerId: z.string().nullable(),
|
|
81
|
+
/** Added in 0.4.0. Where this contact also lives (a connected CRM). */
|
|
82
|
+
refs: z.array(RecordRef).optional(),
|
|
73
83
|
createdAt: Timestamp,
|
|
74
84
|
updatedAt: Timestamp,
|
|
75
85
|
});
|
|
@@ -93,3 +103,79 @@ export const ContactUpdate = z.object({
|
|
|
93
103
|
companyId: z.string().nullable().optional(),
|
|
94
104
|
ownerId: z.string().nullable().optional(),
|
|
95
105
|
});
|
|
106
|
+
// ── Resources added in 0.4.0 (L2): companies, deals, record links ───────────────
|
|
107
|
+
export const Company = z.object({
|
|
108
|
+
id: z.string(),
|
|
109
|
+
name: z.string().nullable(),
|
|
110
|
+
website: z.string().nullable(),
|
|
111
|
+
domain: z.string().nullable(),
|
|
112
|
+
phone: z.string().nullable(),
|
|
113
|
+
industry: z.string().nullable(),
|
|
114
|
+
ownerId: z.string().nullable(),
|
|
115
|
+
refs: z.array(RecordRef).optional(),
|
|
116
|
+
createdAt: Timestamp,
|
|
117
|
+
updatedAt: Timestamp,
|
|
118
|
+
});
|
|
119
|
+
export const CompanyCreate = z.object({
|
|
120
|
+
name: z.string().min(1).max(200),
|
|
121
|
+
website: z.string().max(500).optional(),
|
|
122
|
+
phone: z.string().max(40).optional(),
|
|
123
|
+
industry: z.string().max(120).optional(),
|
|
124
|
+
ownerId: z.string().optional(),
|
|
125
|
+
});
|
|
126
|
+
export const CompanyUpdate = z.object({
|
|
127
|
+
name: z.string().min(1).max(200).optional(),
|
|
128
|
+
website: z.string().max(500).nullable().optional(),
|
|
129
|
+
phone: z.string().max(40).nullable().optional(),
|
|
130
|
+
industry: z.string().max(120).nullable().optional(),
|
|
131
|
+
ownerId: z.string().nullable().optional(),
|
|
132
|
+
});
|
|
133
|
+
export const Deal = z.object({
|
|
134
|
+
id: z.string(),
|
|
135
|
+
name: z.string().nullable(),
|
|
136
|
+
/** Amount in the currency's units (12500.5). */
|
|
137
|
+
value: z.number().nullable(),
|
|
138
|
+
currency: z.string().nullable(),
|
|
139
|
+
stage: z.string().nullable(),
|
|
140
|
+
closeDate: z.string().nullable(),
|
|
141
|
+
companyId: z.string().nullable(),
|
|
142
|
+
ownerId: z.string().nullable(),
|
|
143
|
+
refs: z.array(RecordRef).optional(),
|
|
144
|
+
createdAt: Timestamp,
|
|
145
|
+
updatedAt: Timestamp,
|
|
146
|
+
});
|
|
147
|
+
export const DealCreate = z.object({
|
|
148
|
+
name: z.string().min(1).max(200),
|
|
149
|
+
value: z.number().min(0).optional(),
|
|
150
|
+
currency: z.string().length(3).optional(),
|
|
151
|
+
stage: z.string().max(120).optional(),
|
|
152
|
+
closeDate: z.string().optional(),
|
|
153
|
+
companyId: z.string().optional(),
|
|
154
|
+
ownerId: z.string().optional(),
|
|
155
|
+
});
|
|
156
|
+
export const DealUpdate = z.object({
|
|
157
|
+
name: z.string().min(1).max(200).optional(),
|
|
158
|
+
value: z.number().min(0).nullable().optional(),
|
|
159
|
+
currency: z.string().length(3).nullable().optional(),
|
|
160
|
+
stage: z.string().max(120).nullable().optional(),
|
|
161
|
+
closeDate: z.string().nullable().optional(),
|
|
162
|
+
companyId: z.string().nullable().optional(),
|
|
163
|
+
ownerId: z.string().nullable().optional(),
|
|
164
|
+
});
|
|
165
|
+
/** Loops record kinds as the API names them in links. */
|
|
166
|
+
export const LinkKind = z.enum(['contact', 'company', 'lead', 'deal']);
|
|
167
|
+
/** A link between two records (`recordLinks` in Vista): a deal holds many people, each with a role. */
|
|
168
|
+
export const RecordLink = z.object({
|
|
169
|
+
id: z.string(),
|
|
170
|
+
from: z.object({ kind: LinkKind, id: z.string() }),
|
|
171
|
+
to: z.object({ kind: LinkKind, id: z.string() }),
|
|
172
|
+
role: z.string().nullable(),
|
|
173
|
+
createdAt: Timestamp,
|
|
174
|
+
});
|
|
175
|
+
export const RecordLinkCreate = z.object({
|
|
176
|
+
from: z.object({ kind: LinkKind, id: z.string().min(1) }),
|
|
177
|
+
to: z.object({ kind: LinkKind, id: z.string().min(1) }),
|
|
178
|
+
role: z.string().max(80).optional(),
|
|
179
|
+
});
|
|
180
|
+
/** `GET /v1/links?kind=deal&id=…`: the links of one record, either end. */
|
|
181
|
+
export const RecordLinkQuery = z.object({ kind: LinkKind, id: z.string().min(1) });
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Added in 0.4.0 (L2). The Loops fields a connector maps into, per record kind. `custom.<key>` reaches a custom field.
|
|
3
|
+
* Link ids (companyId on a contact, people on a deal) are NOT fields: they come from `sync.links` and become `recordLinks`.
|
|
4
|
+
* Only ever ADD names here.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LOOPS_FIELD_NAMES: Record<'CONTACT' | 'COMPANY' | 'LEAD' | 'DEAL', readonly string[]>;
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Added in 0.4.0 (L2). The Loops fields a connector maps into, per record kind. `custom.<key>` reaches a custom field.
|
|
3
|
+
* Link ids (companyId on a contact, people on a deal) are NOT fields: they come from `sync.links` and become `recordLinks`.
|
|
4
|
+
* Only ever ADD names here.
|
|
5
|
+
*/
|
|
6
|
+
export const LOOPS_FIELD_NAMES = {
|
|
7
|
+
CONTACT: ['firstName', 'lastName', 'email', 'phone', 'mobile', 'jobTitle', 'linkedinUrl', 'city', 'country', 'ownerEmail'],
|
|
8
|
+
COMPANY: ['name', 'website', 'domain', 'phone', 'industry', 'city', 'country', 'linkedinUrl', 'ownerEmail'],
|
|
9
|
+
LEAD: ['firstName', 'lastName', 'email', 'phone', 'jobTitle', 'companyName', 'website', 'status', 'source', 'ownerEmail'],
|
|
10
|
+
DEAL: ['name', 'value', 'currency', 'stage', 'closeDate', 'probability', 'ownerEmail'],
|
|
11
|
+
};
|
package/dist/index.d.ts
CHANGED