@agentforge-io/sdk-server 4.62.0 → 4.64.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/errors.d.ts CHANGED
@@ -23,6 +23,18 @@ export declare class AgentForgeAuthError extends AgentForgeError {
23
23
  export declare class AgentForgeNotFoundError extends AgentForgeError {
24
24
  constructor(message: string, body?: string);
25
25
  }
26
+ /**
27
+ * PDK-CONTACTS — 409 `contact_duplicate` from `contacts.create` / `update`:
28
+ * a contact of the business already has that phone or document. Open
29
+ * `existingId` instead of creating another one.
30
+ */
31
+ export declare class AgentForgeDuplicateContactError extends AgentForgeError {
32
+ /** The business contact that already owns the phone / document. */
33
+ readonly existingId: string;
34
+ /** Which field collided. */
35
+ readonly matchedBy: 'phone' | 'document';
36
+ constructor(message: string, existingId: string, matchedBy: 'phone' | 'document', body?: string);
37
+ }
26
38
  export declare class AgentForgeNetworkError extends Error {
27
39
  readonly cause: Error;
28
40
  constructor(message: string, cause: Error);
package/dist/errors.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Errores tipados que el SDK lanza. Las apps cliente pueden hacer
3
3
  // `instanceof AgentForgeAuthError` para distinguir 401/403 de otros fallos.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.AgentForgeNetworkError = exports.AgentForgeNotFoundError = exports.AgentForgeAuthError = exports.AgentForgeError = void 0;
5
+ exports.AgentForgeNetworkError = exports.AgentForgeDuplicateContactError = exports.AgentForgeNotFoundError = exports.AgentForgeAuthError = exports.AgentForgeError = void 0;
6
6
  class AgentForgeError extends Error {
7
7
  constructor(status, message, body, code) {
8
8
  super(message);
@@ -71,6 +71,20 @@ class AgentForgeNotFoundError extends AgentForgeError {
71
71
  }
72
72
  }
73
73
  exports.AgentForgeNotFoundError = AgentForgeNotFoundError;
74
+ /**
75
+ * PDK-CONTACTS — 409 `contact_duplicate` from `contacts.create` / `update`:
76
+ * a contact of the business already has that phone or document. Open
77
+ * `existingId` instead of creating another one.
78
+ */
79
+ class AgentForgeDuplicateContactError extends AgentForgeError {
80
+ constructor(message, existingId, matchedBy, body) {
81
+ super(409, message, body, 'contact_duplicate');
82
+ this.name = 'AgentForgeDuplicateContactError';
83
+ this.existingId = existingId;
84
+ this.matchedBy = matchedBy;
85
+ }
86
+ }
87
+ exports.AgentForgeDuplicateContactError = AgentForgeDuplicateContactError;
74
88
  class AgentForgeNetworkError extends Error {
75
89
  constructor(message, cause) {
76
90
  super(message);
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { AgentForgeClient, INSTALLED_TENANT_HEADER } from './client';
2
2
  export type { AgentForgeClientOptions, RequestOptions } from './client';
3
- export { AgentForgeError, AgentForgeAuthError, AgentForgeNotFoundError, AgentForgeNetworkError, } from './errors';
3
+ export { AgentForgeError, AgentForgeAuthError, AgentForgeNotFoundError, AgentForgeNetworkError, AgentForgeDuplicateContactError, } from './errors';
4
4
  export { APP_WEBHOOK_HEADERS, TOOL_CALLBACK_HEADERS, ToolCallbackSignatureError, signToolCallbackPayload, verifyAppWebhook, verifyToolCallbackSignature, } from './webhooks';
5
5
  export { WebhookResource, type SetAppWebhookInput } from './resources/webhook';
6
6
  export type { AppWebhook, AppWebhookEvent, AppWebhookEventName, AppCaseWebhookEvent, AppCaseWebhookEventName, AppConversationMessageWebhookEvent, AppChannelStatusWebhookEvent, AgentMe, AgentSummary, AppUserConnectorStatus, ApprovalCopyBundle, ChannelContext, ChatStreamChunk, ChatStreamEvent, ChatTokenRecord, ConnectorDefaultsResult, ConnectorDefaultsSource, ConnectorResourceItem, ConnectorStatus, ConnectorToolInfo, ConversationHistory, ConversationStatus, CreateAgentInput, CreateClickupTaskInput, CreateClickupTaskResult, ExternalToolSummary, IssueChatTokenInput, ListAgentsResult, ListConnectorResourcesResult, McpServerConfig, MessageRecord, MessageRole, PublicAppBranding, PublicProfileBlock, PublicProfileTemplate, PublicTeamLanding, CreateTeamInput, UpdateTeamInput, TeamSummary, TeamDetail, TeamTheme, TeamBusinessHours, TeamWeekday, TeamProfileBlock, AppInstallation, TemplateConfigField, TemplateSummary, TemplateDetail, TemplateInstallStats, TemplatePublisher, TemplateAuthor, AppTemplatePolicy, TemplateCategoryRef, MarketplaceCategory, MarketplaceCategoryGroup, MarketplaceLocale, TemplateInstallResult, UpsertSystemTemplateInput, UpsertSystemTemplateResult, TemplateReview, TemplateRatingSummary, TemplateReviewsPage, BusinessReview, BusinessReviewsPage, ListTemplateReviewsInput, SaveTemplateReviewInput, TemplateReportKind, CreateTemplateReportInput, TenantConfigEntry, Place, PlaceSuggestion, SearchPlacesInput, AutocompletePlacesInput, PlacesScope, CaseField, CaseBusinessState, CaseType, CaseState, CaseStateType, CasePayment, CasePaymentAccount, CasePaymentStatus, CaseReceiptPayment, CaseDestination, CaseView, CaseStateStep, CreateDirectOrderInput, CreateDirectBookingInput, MoveCaseSlotInput, CaseSlot, CatalogAttendedAt, CatalogBookingRule, CaseOrigin, CaseOriginChannel, DirectOrderForm, DirectPaymentOption, CaseClosingMethod, CaseClosingOrder, CaseClosingReport, CaseReportPage, CaseReceipt, CaseReceiptLine, CaseProposal, CaseProposalAnswer, CaseProposalChange, CaseProposalInput, ListCasesInput, AddressValue, DeliveryLocalPricing, DeliverySettings, PaymentMethodKind, PaymentSettings, PaymentSettingsInput, PaymentAccount, PaymentCountry, PaymentFieldDef, PaymentMethodDef, StructuredConfigInput, StructuredConfigEntry, DeliveryQuoteStatus, DeliveryQuoteInput, DeliveryRoute, DeliveryRouteInput, DeliveryQuote, AppSelf, AppOwner, AppSelfConnector, AppSelfConnectors, AppSelfConnectorTools, AppSelfConnectorToolsResponse, RegisterToolInput, RegisterToolsInput, BusinessRoleEntry, Catalog, CatalogCheckoutCta, CatalogCategory, CatalogProduct, CatalogProductPhoto, CatalogProductKind, CatalogProductStatus, CatalogPriceKind, CatalogAvailability, CatalogLockableField, CatalogProductPage, UpsertCatalogInput, CreateCatalogCategoryInput, UpdateCatalogCategoryInput, CreateCatalogProductInput, UpdateCatalogProductInput, ListCatalogProductsInput, CatalogPhotoUploadTarget, SignCatalogPhotoUploadInput, AttachCatalogPhotoInput, CatalogImportItem, CatalogImportPreview, CatalogImportApplyResult, CatalogFileMapping, CatalogFilePlan, CatalogFilePreview, CatalogFileApplyResult, CatalogFileInput, CatalogFilePreviewInput, CatalogMenuItem, CatalogMenuRead, CatalogMenuReadInput, CatalogMenuAttachInput, CatalogMenuChatFile, CatalogMenuKeepInSyncInput, CatalogMenuKeepInSyncResult, CatalogOption, CatalogOptionGroup, SaveCatalogOptionGroupInput, CatalogOptionChoice, CatalogOptionChange, CatalogOptionChangesPlan, CatalogUnit, SaveCatalogUnitInput, CatalogSaleRule, CatalogFileApplyInput, CatalogFileErrorCode, CatalogImportSourceStatus, CatalogImportColumnMapping, CatalogImportRunResult, CatalogImportSource, CreateCatalogImportSourceInput, UpdateCatalogImportSourceInput, PreviewCatalogImportSourceInput, CatalogImportSourcePreview, CatalogSheetTab, CatalogTemplateSheet, CreateCatalogTemplateSheetInput, GoogleSheetsPickerInput, GoogleSheetsPickerSession, GoogleSheetsPickerErrorCode, GoogleSheetsPickerResult, RegisterToolsResult, ToolCallbackPayload, ToolCallRecord, ToolPermission, ToolPermissionMode, TokenUsage, TenantSecretEntry, UpdateAgentInput, InboxThreadMode, InboxMessageDirection, InboxMessageSource, InboxMessageType, InboxThreadCustomerProfileView, InboxThreadView, InboxMessageView, SupportKpiTotals, SupportKpiResponse, AgentAttentionLogRow, } from './types';
@@ -21,8 +21,8 @@ export { MarketplaceResource } from './resources/marketplace';
21
21
  export type { ListMarketplaceCategoriesInput } from './resources/marketplace';
22
22
  export { TenantConfigResource } from './resources/config';
23
23
  export { PlacesResource } from './resources/places';
24
- export { ContactsResource, ContactVerificationResource } from './resources/contacts';
25
- export type { ContactVerificationChannel, LinkContactInput, LinkContactResult, AppContact, ContactAvatarUploadTarget, ClaimContactInput, ClaimContactResult, StartVerificationInput, StartVerificationResult, ConfirmVerificationInput, ConfirmVerificationResult, } from './resources/contacts';
24
+ export { ContactsResource, ContactVerificationResource, ContactAddressesResource, ContactTagsResource, ContactListsResource, } from './resources/contacts';
25
+ export type { ContactVerificationChannel, LinkContactInput, LinkContactResult, AppContact, ContactAvatarUploadTarget, ClaimContactInput, ClaimContactResult, StartVerificationInput, StartVerificationResult, ConfirmVerificationInput, ConfirmVerificationResult, ContactDocumentType, ContactDocumentInput, ContactDocument, ContactMatchedBy, ContactSummary, BusinessContact, ContactPage, SearchContactsInput, CreateBusinessContactInput, UpdateBusinessContactInput, ContactAddress, ContactAddressInput, ContactTag, ContactList, } from './resources/contacts';
26
26
  export { FilesResource } from './resources/files';
27
27
  export type { AppFileKind, SignAppFileInput, AppFileUploadTarget } from './resources/files';
28
28
  export { DeliveryResource } from './resources/delivery';
package/dist/index.js CHANGED
@@ -28,7 +28,8 @@
28
28
  // const payload = af.tools.verifyCallback({ rawBody, signatureHeader, secretPlaintext });
29
29
  // await af.tools.respondToCallback({ resultUrl: payload.resultUrl, tenantId: payload.tenantId, secret, result });
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.ToolsResource = exports.TeamsResource = exports.SecretsResource = exports.ProvisioningResource = exports.CATALOG_IMPORT_MAX_ITEMS = exports.AgentForgeCatalogImportLimitError = exports.CatalogSourcesResource = exports.CatalogUnitsResource = exports.CatalogOptionGroupsResource = exports.CatalogMenuImportResource = exports.CatalogFileImportResource = exports.CatalogImportResource = exports.CatalogPhotosResource = exports.CatalogProductsResource = exports.CatalogCategoriesResource = exports.CatalogResource = exports.BusinessRolesResource = exports.CasesResource = exports.DeliveryResource = exports.FilesResource = exports.ContactVerificationResource = exports.ContactsResource = exports.PlacesResource = exports.TenantConfigResource = exports.MarketplaceResource = exports.TemplateReportsResource = exports.TemplateReviewsResource = exports.TemplatesResource = exports.InstallationsResource = exports.InboxResource = exports.parseGoogleSheetsPickerResult = exports.ConnectorsResource = exports.ChatResource = exports.AppsResource = exports.AnalyticsResource = exports.AgentsResource = exports.WebhookResource = exports.verifyToolCallbackSignature = exports.verifyAppWebhook = exports.signToolCallbackPayload = exports.ToolCallbackSignatureError = exports.TOOL_CALLBACK_HEADERS = exports.APP_WEBHOOK_HEADERS = exports.AgentForgeNetworkError = exports.AgentForgeNotFoundError = exports.AgentForgeAuthError = exports.AgentForgeError = exports.INSTALLED_TENANT_HEADER = exports.AgentForgeClient = void 0;
31
+ exports.ProvisioningResource = exports.CATALOG_IMPORT_MAX_ITEMS = exports.AgentForgeCatalogImportLimitError = exports.CatalogSourcesResource = exports.CatalogUnitsResource = exports.CatalogOptionGroupsResource = exports.CatalogMenuImportResource = exports.CatalogFileImportResource = exports.CatalogImportResource = exports.CatalogPhotosResource = exports.CatalogProductsResource = exports.CatalogCategoriesResource = exports.CatalogResource = exports.BusinessRolesResource = exports.CasesResource = exports.DeliveryResource = exports.FilesResource = exports.ContactListsResource = exports.ContactTagsResource = exports.ContactAddressesResource = exports.ContactVerificationResource = exports.ContactsResource = exports.PlacesResource = exports.TenantConfigResource = exports.MarketplaceResource = exports.TemplateReportsResource = exports.TemplateReviewsResource = exports.TemplatesResource = exports.InstallationsResource = exports.InboxResource = exports.parseGoogleSheetsPickerResult = exports.ConnectorsResource = exports.ChatResource = exports.AppsResource = exports.AnalyticsResource = exports.AgentsResource = exports.WebhookResource = exports.verifyToolCallbackSignature = exports.verifyAppWebhook = exports.signToolCallbackPayload = exports.ToolCallbackSignatureError = exports.TOOL_CALLBACK_HEADERS = exports.APP_WEBHOOK_HEADERS = exports.AgentForgeDuplicateContactError = exports.AgentForgeNetworkError = exports.AgentForgeNotFoundError = exports.AgentForgeAuthError = exports.AgentForgeError = exports.INSTALLED_TENANT_HEADER = exports.AgentForgeClient = void 0;
32
+ exports.ToolsResource = exports.TeamsResource = exports.SecretsResource = void 0;
32
33
  var client_1 = require("./client");
33
34
  Object.defineProperty(exports, "AgentForgeClient", { enumerable: true, get: function () { return client_1.AgentForgeClient; } });
34
35
  Object.defineProperty(exports, "INSTALLED_TENANT_HEADER", { enumerable: true, get: function () { return client_1.INSTALLED_TENANT_HEADER; } });
@@ -37,6 +38,7 @@ Object.defineProperty(exports, "AgentForgeError", { enumerable: true, get: funct
37
38
  Object.defineProperty(exports, "AgentForgeAuthError", { enumerable: true, get: function () { return errors_1.AgentForgeAuthError; } });
38
39
  Object.defineProperty(exports, "AgentForgeNotFoundError", { enumerable: true, get: function () { return errors_1.AgentForgeNotFoundError; } });
39
40
  Object.defineProperty(exports, "AgentForgeNetworkError", { enumerable: true, get: function () { return errors_1.AgentForgeNetworkError; } });
41
+ Object.defineProperty(exports, "AgentForgeDuplicateContactError", { enumerable: true, get: function () { return errors_1.AgentForgeDuplicateContactError; } });
40
42
  var webhooks_1 = require("./webhooks");
41
43
  Object.defineProperty(exports, "APP_WEBHOOK_HEADERS", { enumerable: true, get: function () { return webhooks_1.APP_WEBHOOK_HEADERS; } });
42
44
  Object.defineProperty(exports, "TOOL_CALLBACK_HEADERS", { enumerable: true, get: function () { return webhooks_1.TOOL_CALLBACK_HEADERS; } });
@@ -74,6 +76,9 @@ Object.defineProperty(exports, "PlacesResource", { enumerable: true, get: functi
74
76
  var contacts_1 = require("./resources/contacts");
75
77
  Object.defineProperty(exports, "ContactsResource", { enumerable: true, get: function () { return contacts_1.ContactsResource; } });
76
78
  Object.defineProperty(exports, "ContactVerificationResource", { enumerable: true, get: function () { return contacts_1.ContactVerificationResource; } });
79
+ Object.defineProperty(exports, "ContactAddressesResource", { enumerable: true, get: function () { return contacts_1.ContactAddressesResource; } });
80
+ Object.defineProperty(exports, "ContactTagsResource", { enumerable: true, get: function () { return contacts_1.ContactTagsResource; } });
81
+ Object.defineProperty(exports, "ContactListsResource", { enumerable: true, get: function () { return contacts_1.ContactListsResource; } });
77
82
  var files_1 = require("./resources/files");
78
83
  Object.defineProperty(exports, "FilesResource", { enumerable: true, get: function () { return files_1.FilesResource; } });
79
84
  var delivery_1 = require("./resources/delivery");
@@ -34,6 +34,20 @@ export declare class CasesResource {
34
34
  * then says it was weighed.
35
35
  */
36
36
  weighLine(caseId: string, line: string, weight: number): Promise<CaseView>;
37
+ /**
38
+ * `POST /api/v1/cases/:id/lines/takeaway` — PDK-BUG-006: while dispatching, the team marks ONE
39
+ * line of a sent order «para llevar» (`takeaway: true`) or back to eaten here (`false`);
40
+ * `key` is the receipt line's `key`. Internal packing info: it is not a proposal, the customer
41
+ * is not told, the receipt keeps its revision and the price does not change. The same value
42
+ * is a no-op. The line takes another `key` (read the receipt again); a line of the same
43
+ * product and choice already in the other state absorbs it (one line, quantities added).
44
+ * Returns the updated case (`receipt.allTakeaway` follows). 400 closed or still-edited order,
45
+ * 404 unknown line, 409 a proposal is waiting (withdraw it first).
46
+ */
47
+ setLineTakeaway(caseId: string, input: {
48
+ key: string;
49
+ takeaway: boolean;
50
+ }): Promise<CaseView>;
37
51
  /**
38
52
  * `POST /api/v1/cases/:id/proposal` — AGF-PDK-DISPATCH-PROPOSAL: the business proposes
39
53
  * changes while picking (a line out of stock, another product in its place; lines by
@@ -69,6 +69,19 @@ class CasesResource {
69
69
  async weighLine(caseId, line, weight) {
70
70
  return this.client.request('POST', `/api/v1/cases/${encodeURIComponent(caseId)}/weigh`, { line, weight });
71
71
  }
72
+ /**
73
+ * `POST /api/v1/cases/:id/lines/takeaway` — PDK-BUG-006: while dispatching, the team marks ONE
74
+ * line of a sent order «para llevar» (`takeaway: true`) or back to eaten here (`false`);
75
+ * `key` is the receipt line's `key`. Internal packing info: it is not a proposal, the customer
76
+ * is not told, the receipt keeps its revision and the price does not change. The same value
77
+ * is a no-op. The line takes another `key` (read the receipt again); a line of the same
78
+ * product and choice already in the other state absorbs it (one line, quantities added).
79
+ * Returns the updated case (`receipt.allTakeaway` follows). 400 closed or still-edited order,
80
+ * 404 unknown line, 409 a proposal is waiting (withdraw it first).
81
+ */
82
+ async setLineTakeaway(caseId, input) {
83
+ return this.client.request('POST', `/api/v1/cases/${encodeURIComponent(caseId)}/lines/takeaway`, { key: input.key, takeaway: input.takeaway });
84
+ }
72
85
  /**
73
86
  * `POST /api/v1/cases/:id/proposal` — AGF-PDK-DISPATCH-PROPOSAL: the business proposes
74
87
  * changes while picking (a line out of stock, another product in its place; lines by
@@ -121,10 +121,226 @@ export declare class ContactVerificationResource {
121
121
  */
122
122
  confirm(input: ConfirmVerificationInput): Promise<ConfirmVerificationResult>;
123
123
  }
124
+ /** Colombia: CC, CE, NIT, PP, TI, PEP, PPT. Other countries: any short code. */
125
+ export type ContactDocumentType = 'CC' | 'CE' | 'NIT' | 'PP' | 'TI' | 'PEP' | 'PPT' | (string & {});
126
+ export interface ContactDocumentInput {
127
+ type: ContactDocumentType;
128
+ /** Free-typed; the platform normalises it (digits for CC/CE/NIT/TI, uppercase alnum otherwise). */
129
+ number: string;
130
+ /** ISO-3166 alpha-2, default `CO`. */
131
+ country?: string;
132
+ }
133
+ export interface ContactDocument {
134
+ type: string;
135
+ /** Normalised. */
136
+ number: string;
137
+ country: string;
138
+ }
139
+ export type ContactMatchedBy = 'name' | 'phone' | 'document' | 'email';
140
+ /** Compact row of search / list results. */
141
+ export interface ContactSummary {
142
+ id: string;
143
+ displayName: string | null;
144
+ /** E.164. */
145
+ phone: string | null;
146
+ email: string | null;
147
+ document: ContactDocument | null;
148
+ tags: string[];
149
+ avatarUrl: string | null;
150
+ lastSeenAt: string | null;
151
+ /** Why it matched `q`; `null` without a query. */
152
+ matchedBy: ContactMatchedBy | null;
153
+ }
154
+ export interface BusinessContact extends ContactSummary {
155
+ marketingConsent: boolean;
156
+ marketingConsentAt: string | null;
157
+ notes: string | null;
158
+ /** Ids of the lists the contact belongs to. */
159
+ lists: string[];
160
+ createdAt: string;
161
+ }
162
+ export interface ContactPage {
163
+ items: ContactSummary[];
164
+ /** Pass it back as `cursor` for the next page; `null` at the end. */
165
+ nextCursor: string | null;
166
+ }
167
+ export interface SearchContactsInput {
168
+ /** Name (accent/case-insensitive), phone (E.164 or last ≥ 4 digits), document number or email. */
169
+ q?: string;
170
+ /** Tag name (case-insensitive). */
171
+ tag?: string;
172
+ /** List id. */
173
+ list?: string;
174
+ cursor?: string;
175
+ /** 1-100, default 25. */
176
+ limit?: number;
177
+ }
178
+ export interface CreateBusinessContactInput {
179
+ displayName?: string;
180
+ /** E.164 or a Colombian mobile (`300 123 4567`). */
181
+ phone?: string;
182
+ email?: string;
183
+ document?: ContactDocumentInput;
184
+ tags?: string[];
185
+ /** «Acepta recibir promociones» (Ley 1581). Default `false`. */
186
+ marketingConsent?: boolean;
187
+ }
188
+ export interface UpdateBusinessContactInput {
189
+ /** The business contact to change (`ContactSummary.id`). */
190
+ contactId: string;
191
+ displayName?: string | null;
192
+ phone?: string | null;
193
+ email?: string | null;
194
+ /** `null` clears it. */
195
+ document?: ContactDocumentInput | null;
196
+ /** Replaces all tags. */
197
+ tags?: string[];
198
+ addTags?: string[];
199
+ removeTags?: string[];
200
+ marketingConsent?: boolean;
201
+ }
202
+ export interface ContactAddress {
203
+ id: string;
204
+ contactId: string;
205
+ label: string | null;
206
+ formatted: string;
207
+ extra: string | null;
208
+ placeId: string | null;
209
+ lat: number | null;
210
+ lng: number | null;
211
+ lastUsedAt: string | null;
212
+ createdAt: string;
213
+ }
214
+ export interface ContactAddressInput {
215
+ label?: string | null;
216
+ formatted: string;
217
+ /** Apartment, tower, delivery notes. */
218
+ extra?: string | null;
219
+ placeId?: string | null;
220
+ lat?: number | null;
221
+ lng?: number | null;
222
+ }
223
+ export interface ContactTag {
224
+ id: string;
225
+ name: string;
226
+ color: string | null;
227
+ /** Contacts carrying it. */
228
+ count: number;
229
+ }
230
+ export interface ContactList {
231
+ id: string;
232
+ name: string;
233
+ description: string | null;
234
+ memberCount: number;
235
+ createdAt: string;
236
+ }
237
+ /** `update` for an App end user's contact (CA-1). */
238
+ export interface UpdateAppContactInput {
239
+ externalUserId: string;
240
+ name?: string;
241
+ phone?: {
242
+ e164: string;
243
+ verificationToken?: string;
244
+ };
245
+ avatarUrl?: string;
246
+ }
247
+ /** `contacts.addresses` — the business's own record of a contact's delivery addresses. */
248
+ export declare class ContactAddressesResource {
249
+ private readonly client;
250
+ constructor(client: AgentForgeClient);
251
+ /** `GET /api/v1/contacts/:id/addresses` — most recently used first. */
252
+ list(contactId: string): Promise<ContactAddress[]>;
253
+ /**
254
+ * `POST …/addresses`. The same `placeId` or the same normalised `formatted`
255
+ * is reused (`created: false`, `lastUsedAt` touched) instead of duplicated.
256
+ */
257
+ add(contactId: string, input: ContactAddressInput): Promise<{
258
+ address: ContactAddress;
259
+ created: boolean;
260
+ }>;
261
+ /** `PATCH …/addresses/:addressId`. */
262
+ update(contactId: string, addressId: string, patch: Partial<ContactAddressInput>): Promise<ContactAddress>;
263
+ /** `POST …/addresses/:addressId/touch` — a sale just delivered there. */
264
+ touch(contactId: string, addressId: string): Promise<ContactAddress>;
265
+ /** `DELETE …/addresses/:addressId`. */
266
+ remove(contactId: string, addressId: string): Promise<void>;
267
+ }
268
+ /** `contacts.tags` — the business's tag catalog (contacts keep the tag names). */
269
+ export declare class ContactTagsResource {
270
+ private readonly client;
271
+ constructor(client: AgentForgeClient);
272
+ /** `GET /api/v1/contact-tags` — with the number of contacts per tag. */
273
+ list(): Promise<ContactTag[]>;
274
+ /** `POST`. 409 `tag_exists` when the name is taken (case-insensitive). */
275
+ create(input: {
276
+ name: string;
277
+ color?: string | null;
278
+ }): Promise<ContactTag>;
279
+ /** `PATCH /:tagId` — rename (rewritten on every contact) and/or recolour. */
280
+ update(tagId: string, patch: {
281
+ name?: string;
282
+ color?: string | null;
283
+ }): Promise<ContactTag>;
284
+ /** `DELETE /:tagId` — removed from the catalog and from every contact. */
285
+ remove(tagId: string): Promise<{
286
+ removedFromContacts: number;
287
+ }>;
288
+ }
289
+ /** `contacts.lists` — static contact lists (campaigns later read them). */
290
+ export declare class ContactListsResource {
291
+ private readonly client;
292
+ constructor(client: AgentForgeClient);
293
+ list(): Promise<ContactList[]>;
294
+ /** 409 `list_exists` when the name is taken. */
295
+ create(input: {
296
+ name: string;
297
+ description?: string | null;
298
+ }): Promise<ContactList>;
299
+ get(listId: string): Promise<ContactList>;
300
+ update(listId: string, patch: {
301
+ name?: string;
302
+ description?: string | null;
303
+ }): Promise<ContactList>;
304
+ /** Deletes the list and its memberships (never the contacts). */
305
+ remove(listId: string): Promise<void>;
306
+ /** `GET /:listId/members` — newest first, paginated. */
307
+ members(listId: string, opts?: {
308
+ cursor?: string;
309
+ limit?: number;
310
+ }): Promise<ContactPage>;
311
+ /** Idempotent (≤ 500 ids). Ids that are not contacts of the business count as `unknown`. */
312
+ addMembers(listId: string, contactIds: string[], opts?: {
313
+ addedBy?: string;
314
+ }): Promise<{
315
+ added: number;
316
+ alreadyMembers: number;
317
+ unknown: number;
318
+ }>;
319
+ removeMember(listId: string, contactId: string): Promise<boolean>;
320
+ }
124
321
  export declare class ContactsResource {
125
322
  private readonly client;
126
323
  readonly verification: ContactVerificationResource;
324
+ readonly addresses: ContactAddressesResource;
325
+ readonly tags: ContactTagsResource;
326
+ readonly lists: ContactListsResource;
127
327
  constructor(client: AgentForgeClient);
328
+ /**
329
+ * `GET /api/v1/contacts?q&tag&list&cursor&limit` — search the business's
330
+ * contacts (excludes merged and deleted ones). With `q`: best match first
331
+ * (exact phone/document, then name prefix, …); without: most recent first.
332
+ */
333
+ search(input?: SearchContactsInput): Promise<ContactPage>;
334
+ /** Alias of `search` without `q` (the Contactos tab). */
335
+ list(input?: Omit<SearchContactsInput, 'q'>): Promise<ContactPage>;
336
+ /**
337
+ * `POST /api/v1/contacts`. Needs a name, a phone or a document. A phone or
338
+ * document the business already has throws `AgentForgeDuplicateContactError`
339
+ * (`existingId`, `matchedBy`) — open that contact instead.
340
+ */
341
+ create(input: CreateBusinessContactInput): Promise<BusinessContact>;
342
+ /** `GET /api/v1/contacts/:id` — `null` when it is not a contact of this business. */
343
+ getById(contactId: string): Promise<BusinessContact | null>;
128
344
  /**
129
345
  * `POST /api/v1/contacts/avatar/sign-upload` — where to PUT an end user's
130
346
  * photo (jpeg/png/webp/gif, 2 MB at most). App-wide: the same URL serves
@@ -141,16 +357,16 @@ export declare class ContactsResource {
141
357
  claim(input: ClaimContactInput): Promise<ClaimContactResult>;
142
358
  /** `GET /api/v1/contacts?externalUserId=` — `null` when there is no contact. */
143
359
  get(externalUserId: string): Promise<AppContact | null>;
144
- /** `PATCH /api/v1/contacts` — name / phone (phone verified only with a token) / photo. 404 when unknown. */
145
- update(input: {
146
- externalUserId: string;
147
- name?: string;
148
- phone?: {
149
- e164: string;
150
- verificationToken?: string;
151
- };
152
- avatarUrl?: string;
153
- }): Promise<AppContact>;
360
+ /**
361
+ * Two shapes:
362
+ * - `{ externalUserId, name?, phone?, avatarUrl? }` — `PATCH /api/v1/contacts`,
363
+ * an App end user's contact (phone verified only with a token). 404 when unknown.
364
+ * - `{ contactId, displayName?, phone?, email?, document?, tags?, marketingConsent? }` —
365
+ * `PATCH /api/v1/contacts/:id`, a contact of the business book. Throws
366
+ * `AgentForgeDuplicateContactError` when the new phone/document is taken.
367
+ */
368
+ update(input: UpdateBusinessContactInput): Promise<BusinessContact>;
369
+ update(input: UpdateAppContactInput): Promise<AppContact>;
154
370
  /**
155
371
  * `DELETE /api/v1/contacts?externalUserId=` — the person stops sharing
156
372
  * their data with this business: personal fields and identifiers are
@@ -17,8 +17,17 @@
17
17
  // the platform) or email code; `confirm` returns the `verificationToken`
18
18
  // the App keeps with its customer account (180 days) and sends on every
19
19
  // `link`, in any business.
20
+ //
21
+ // PDK-CONTACTS — the business's own contact book (business = tenant), by
22
+ // contact id rather than by App end user:
23
+ // - `search({ q, tag, list, cursor, limit })` / `list` — accent-insensitive
24
+ // name, phone (E.164 or last ≥ 4 digits), document number, email.
25
+ // - `create(...)` — needs a name, a phone or a document; a phone/document that
26
+ // already exists throws `AgentForgeDuplicateContactError` (`existingId`).
27
+ // - `getById(id)` · `update({ contactId, ... })` (documents, tags, consent).
28
+ // - `addresses.*` · `tags.*` (per-business catalog) · `lists.*` (static lists).
20
29
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.ContactsResource = exports.ContactVerificationResource = void 0;
30
+ exports.ContactsResource = exports.ContactListsResource = exports.ContactTagsResource = exports.ContactAddressesResource = exports.ContactVerificationResource = void 0;
22
31
  const errors_1 = require("../errors");
23
32
  class ContactVerificationResource {
24
33
  constructor(client) {
@@ -45,10 +54,161 @@ class ContactVerificationResource {
45
54
  }
46
55
  }
47
56
  exports.ContactVerificationResource = ContactVerificationResource;
57
+ const q = encodeURIComponent;
58
+ /** 409 `contact_duplicate` → the typed error; anything else is rethrown as is. */
59
+ function asDuplicate(err) {
60
+ if (err instanceof errors_1.AgentForgeError && err.status === 409 && err.code === 'contact_duplicate' && err.body) {
61
+ try {
62
+ const b = JSON.parse(err.body);
63
+ if (typeof b.existingId === 'string') {
64
+ return new errors_1.AgentForgeDuplicateContactError(typeof b.message === 'string' ? b.message : 'contact already exists', b.existingId, b.matchedBy === 'document' ? 'document' : 'phone', err.body);
65
+ }
66
+ }
67
+ catch {
68
+ /* fall through */
69
+ }
70
+ }
71
+ return err;
72
+ }
73
+ function query(params) {
74
+ const parts = Object.entries(params)
75
+ .filter(([, v]) => v !== undefined && v !== '')
76
+ .map(([k, v]) => `${k}=${q(String(v))}`);
77
+ return parts.length ? `?${parts.join('&')}` : '';
78
+ }
79
+ /** `contacts.addresses` — the business's own record of a contact's delivery addresses. */
80
+ class ContactAddressesResource {
81
+ constructor(client) {
82
+ this.client = client;
83
+ }
84
+ /** `GET /api/v1/contacts/:id/addresses` — most recently used first. */
85
+ async list(contactId) {
86
+ const r = await this.client.request('GET', `/api/v1/contacts/${q(contactId)}/addresses`);
87
+ return r.items;
88
+ }
89
+ /**
90
+ * `POST …/addresses`. The same `placeId` or the same normalised `formatted`
91
+ * is reused (`created: false`, `lastUsedAt` touched) instead of duplicated.
92
+ */
93
+ async add(contactId, input) {
94
+ return this.client.request('POST', `/api/v1/contacts/${q(contactId)}/addresses`, input);
95
+ }
96
+ /** `PATCH …/addresses/:addressId`. */
97
+ async update(contactId, addressId, patch) {
98
+ return this.client.request('PATCH', `/api/v1/contacts/${q(contactId)}/addresses/${q(addressId)}`, patch);
99
+ }
100
+ /** `POST …/addresses/:addressId/touch` — a sale just delivered there. */
101
+ async touch(contactId, addressId) {
102
+ return this.client.request('POST', `/api/v1/contacts/${q(contactId)}/addresses/${q(addressId)}/touch`, {});
103
+ }
104
+ /** `DELETE …/addresses/:addressId`. */
105
+ async remove(contactId, addressId) {
106
+ await this.client.request('DELETE', `/api/v1/contacts/${q(contactId)}/addresses/${q(addressId)}`);
107
+ }
108
+ }
109
+ exports.ContactAddressesResource = ContactAddressesResource;
110
+ /** `contacts.tags` — the business's tag catalog (contacts keep the tag names). */
111
+ class ContactTagsResource {
112
+ constructor(client) {
113
+ this.client = client;
114
+ }
115
+ /** `GET /api/v1/contact-tags` — with the number of contacts per tag. */
116
+ async list() {
117
+ return (await this.client.request('GET', '/api/v1/contact-tags')).items;
118
+ }
119
+ /** `POST`. 409 `tag_exists` when the name is taken (case-insensitive). */
120
+ async create(input) {
121
+ return this.client.request('POST', '/api/v1/contact-tags', input);
122
+ }
123
+ /** `PATCH /:tagId` — rename (rewritten on every contact) and/or recolour. */
124
+ async update(tagId, patch) {
125
+ return this.client.request('PATCH', `/api/v1/contact-tags/${q(tagId)}`, patch);
126
+ }
127
+ /** `DELETE /:tagId` — removed from the catalog and from every contact. */
128
+ async remove(tagId) {
129
+ return this.client.request('DELETE', `/api/v1/contact-tags/${q(tagId)}`);
130
+ }
131
+ }
132
+ exports.ContactTagsResource = ContactTagsResource;
133
+ /** `contacts.lists` — static contact lists (campaigns later read them). */
134
+ class ContactListsResource {
135
+ constructor(client) {
136
+ this.client = client;
137
+ }
138
+ async list() {
139
+ return (await this.client.request('GET', '/api/v1/contact-lists')).items;
140
+ }
141
+ /** 409 `list_exists` when the name is taken. */
142
+ async create(input) {
143
+ return this.client.request('POST', '/api/v1/contact-lists', input);
144
+ }
145
+ async get(listId) {
146
+ return this.client.request('GET', `/api/v1/contact-lists/${q(listId)}`);
147
+ }
148
+ async update(listId, patch) {
149
+ return this.client.request('PATCH', `/api/v1/contact-lists/${q(listId)}`, patch);
150
+ }
151
+ /** Deletes the list and its memberships (never the contacts). */
152
+ async remove(listId) {
153
+ await this.client.request('DELETE', `/api/v1/contact-lists/${q(listId)}`);
154
+ }
155
+ /** `GET /:listId/members` — newest first, paginated. */
156
+ async members(listId, opts = {}) {
157
+ return this.client.request('GET', `/api/v1/contact-lists/${q(listId)}/members${query(opts)}`);
158
+ }
159
+ /** Idempotent (≤ 500 ids). Ids that are not contacts of the business count as `unknown`. */
160
+ async addMembers(listId, contactIds, opts = {}) {
161
+ return this.client.request('POST', `/api/v1/contact-lists/${q(listId)}/members`, { contactIds, ...opts });
162
+ }
163
+ async removeMember(listId, contactId) {
164
+ const r = await this.client.request('DELETE', `/api/v1/contact-lists/${q(listId)}/members/${q(contactId)}`);
165
+ return r.removed;
166
+ }
167
+ }
168
+ exports.ContactListsResource = ContactListsResource;
48
169
  class ContactsResource {
49
170
  constructor(client) {
50
171
  this.client = client;
51
172
  this.verification = new ContactVerificationResource(client);
173
+ this.addresses = new ContactAddressesResource(client);
174
+ this.tags = new ContactTagsResource(client);
175
+ this.lists = new ContactListsResource(client);
176
+ }
177
+ /**
178
+ * `GET /api/v1/contacts?q&tag&list&cursor&limit` — search the business's
179
+ * contacts (excludes merged and deleted ones). With `q`: best match first
180
+ * (exact phone/document, then name prefix, …); without: most recent first.
181
+ */
182
+ async search(input = {}) {
183
+ return this.client.request('GET', `/api/v1/contacts${query({ ...input })}`);
184
+ }
185
+ /** Alias of `search` without `q` (the Contactos tab). */
186
+ async list(input = {}) {
187
+ return this.search(input);
188
+ }
189
+ /**
190
+ * `POST /api/v1/contacts`. Needs a name, a phone or a document. A phone or
191
+ * document the business already has throws `AgentForgeDuplicateContactError`
192
+ * (`existingId`, `matchedBy`) — open that contact instead.
193
+ */
194
+ async create(input) {
195
+ try {
196
+ return await this.client.request('POST', '/api/v1/contacts', input);
197
+ }
198
+ catch (err) {
199
+ throw asDuplicate(err);
200
+ }
201
+ }
202
+ /** `GET /api/v1/contacts/:id` — `null` when it is not a contact of this business. */
203
+ async getById(contactId) {
204
+ try {
205
+ return await this.client.request('GET', `/api/v1/contacts/${q(contactId)}`);
206
+ }
207
+ catch (err) {
208
+ if (err instanceof errors_1.AgentForgeNotFoundError)
209
+ return null;
210
+ throw err;
211
+ }
52
212
  }
53
213
  /**
54
214
  * `POST /api/v1/contacts/avatar/sign-upload` — where to PUT an end user's
@@ -78,8 +238,16 @@ class ContactsResource {
78
238
  throw err;
79
239
  }
80
240
  }
81
- /** `PATCH /api/v1/contacts` — name / phone (phone verified only with a token) / photo. 404 when unknown. */
82
241
  async update(input) {
242
+ if ('contactId' in input) {
243
+ const { contactId, ...patch } = input;
244
+ try {
245
+ return await this.client.request('PATCH', `/api/v1/contacts/${q(contactId)}`, patch);
246
+ }
247
+ catch (err) {
248
+ throw asDuplicate(err);
249
+ }
250
+ }
83
251
  return this.client.request('PATCH', '/api/v1/contacts', input);
84
252
  }
85
253
  /**
package/dist/types.d.ts CHANGED
@@ -2269,6 +2269,8 @@ export interface CaseView {
2269
2269
  token: string;
2270
2270
  issuedAt: string;
2271
2271
  revision: number;
2272
+ /** PDK-BUG-006 — every product line of the receipt is to go (`takeaway`). Absent/false on mixed or eat-here orders, older receipts and older platforms. */
2273
+ allTakeaway?: boolean;
2272
2274
  } | null;
2273
2275
  /** What the customer asked after the business took the case (change, cancel), until the business moves it. */
2274
2276
  customerRequest: {
@@ -2411,6 +2413,9 @@ export interface CaseReceiptLine {
2411
2413
  name: string;
2412
2414
  deltaCents: number;
2413
2415
  }>;
2416
+ /** PDK-BUG-006 — the line is to go (packed for takeaway). Present only when `true`; absent means
2417
+ * eaten here, and also on receipts issued before this flag or by an older platform. */
2418
+ takeaway?: true;
2414
2419
  /** AGF-PDK-DISPATCH-PROPOSAL — the line's identity (product + choice): what `cases.propose` names.
2415
2420
  * Absent on an older platform. */
2416
2421
  key?: string;
@@ -2606,6 +2611,9 @@ export interface CreateDirectOrderInput {
2606
2611
  /** AGF-UNITS U3 — sold by value («$3.000 de queso»): the amount in cents instead of a quantity; its own line. */
2607
2612
  amountCents?: number;
2608
2613
  options?: CatalogOptionChoice[];
2614
+ /** PDK-BUG-006 — this line is to go (packed for takeaway). Boolean only; `false`/absent = eaten here.
2615
+ * The same product + options with another `takeaway` is a separate line. No packaging charge. */
2616
+ takeaway?: boolean;
2609
2617
  }>;
2610
2618
  /** The order type's other fields (entrega, direccion, notas…), by key. */
2611
2619
  fields?: Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge-io/sdk-server",
3
- "version": "4.62.0",
3
+ "version": "4.64.0",
4
4
  "description": "Server-side SDK for backend apps integrating with AgentForge platform. Auth via ChatToken, ak_live_ API key or App secret (sk_live_), with App installations across tenants.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",