@agentforge-io/sdk-server 4.63.0 → 4.65.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 +12 -0
- package/dist/errors.js +15 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +9 -1
- package/dist/resources/cases.d.ts +15 -1
- package/dist/resources/cases.js +18 -0
- package/dist/resources/catalog.d.ts +53 -1
- package/dist/resources/catalog.js +90 -1
- package/dist/resources/contacts.d.ts +226 -10
- package/dist/resources/contacts.js +170 -2
- package/dist/types.d.ts +126 -0
- package/package.json +1 -1
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,9 +1,9 @@
|
|
|
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
|
-
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';
|
|
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, ProductRatingSummary, ProductReview, ProductReviewOwner, ProductReviewsPage, ProductReviewsOwnerPage, ListProductReviewsInput, ListProductReviewsForOwnerInput, HideProductReviewInput, ProductLikeResult, ReceiptReviewable, ReceiptReviewables, SaveReceiptReviewInput, 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, AttachCatalogCategoryImageInput, 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';
|
|
7
7
|
export { AgentsResource } from './resources/agents';
|
|
8
8
|
export { AnalyticsResource } from './resources/analytics';
|
|
9
9
|
export type { GetSupportKpisInput, GetAgentAttentionLogInput, } from './resources/analytics';
|
|
@@ -21,14 +21,14 @@ 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';
|
|
29
29
|
export { CasesResource } from './resources/cases';
|
|
30
30
|
export { BusinessRolesResource } from './resources/business-roles';
|
|
31
|
-
export { CatalogResource, CatalogCategoriesResource, CatalogProductsResource, CatalogPhotosResource, CatalogImportResource, CatalogFileImportResource, CatalogMenuImportResource, CatalogOptionGroupsResource, CatalogUnitsResource, CatalogSourcesResource, AgentForgeCatalogImportLimitError, CATALOG_IMPORT_MAX_ITEMS, } from './resources/catalog';
|
|
31
|
+
export { CatalogResource, CatalogCategoriesResource, CatalogProductsResource, CatalogProductReviewsResource, CatalogProductLikesResource, CatalogReviewsResource, CatalogPhotosResource, CatalogImportResource, CatalogFileImportResource, CatalogMenuImportResource, CatalogOptionGroupsResource, CatalogUnitsResource, CatalogSourcesResource, AgentForgeCatalogImportLimitError, CATALOG_IMPORT_MAX_ITEMS, } from './resources/catalog';
|
|
32
32
|
export type { ListThreadsOptions, ListNewestMessagesOptions, NewestMessagesPage, SendMessageInput, AssignThreadInput, UnassignThreadInput, SetThreadModeInput, CloseThreadInput, } from './resources/inbox';
|
|
33
33
|
export { ProvisioningResource } from './resources/provisioning';
|
|
34
34
|
export type { ProvisionedTenant, ProvisionedApp, ProvisionedTeam, } from './resources/provisioning';
|
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.
|
|
31
|
+
exports.CatalogSourcesResource = exports.CatalogUnitsResource = exports.CatalogOptionGroupsResource = exports.CatalogMenuImportResource = exports.CatalogFileImportResource = exports.CatalogImportResource = exports.CatalogPhotosResource = exports.CatalogReviewsResource = exports.CatalogProductLikesResource = exports.CatalogProductReviewsResource = 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 = exports.ProvisioningResource = exports.CATALOG_IMPORT_MAX_ITEMS = exports.AgentForgeCatalogImportLimitError = 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");
|
|
@@ -86,6 +91,9 @@ var catalog_1 = require("./resources/catalog");
|
|
|
86
91
|
Object.defineProperty(exports, "CatalogResource", { enumerable: true, get: function () { return catalog_1.CatalogResource; } });
|
|
87
92
|
Object.defineProperty(exports, "CatalogCategoriesResource", { enumerable: true, get: function () { return catalog_1.CatalogCategoriesResource; } });
|
|
88
93
|
Object.defineProperty(exports, "CatalogProductsResource", { enumerable: true, get: function () { return catalog_1.CatalogProductsResource; } });
|
|
94
|
+
Object.defineProperty(exports, "CatalogProductReviewsResource", { enumerable: true, get: function () { return catalog_1.CatalogProductReviewsResource; } });
|
|
95
|
+
Object.defineProperty(exports, "CatalogProductLikesResource", { enumerable: true, get: function () { return catalog_1.CatalogProductLikesResource; } });
|
|
96
|
+
Object.defineProperty(exports, "CatalogReviewsResource", { enumerable: true, get: function () { return catalog_1.CatalogReviewsResource; } });
|
|
89
97
|
Object.defineProperty(exports, "CatalogPhotosResource", { enumerable: true, get: function () { return catalog_1.CatalogPhotosResource; } });
|
|
90
98
|
Object.defineProperty(exports, "CatalogImportResource", { enumerable: true, get: function () { return catalog_1.CatalogImportResource; } });
|
|
91
99
|
Object.defineProperty(exports, "CatalogFileImportResource", { enumerable: true, get: function () { return catalog_1.CatalogFileImportResource; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentForgeClient } from '../client';
|
|
2
|
-
import type { CaseClosingReport, CaseProposalAnswer, CaseProposalInput, CaseReportPage, CasePaymentStatus, CaseReceipt, CaseState, CaseView, CreateDirectBookingInput, CreateDirectOrderInput, DirectOrderForm, ListCasesInput, MoveCaseSlotInput } from '../types';
|
|
2
|
+
import type { CaseClosingReport, CaseProposalAnswer, CaseProposalInput, CaseReportPage, CasePaymentStatus, CaseReceipt, CaseState, CaseView, CreateDirectBookingInput, CreateDirectOrderInput, DirectOrderForm, ListCasesInput, MoveCaseSlotInput, ProductReview, ReceiptReviewables, SaveReceiptReviewInput } from '../types';
|
|
3
3
|
export declare class CasesResource {
|
|
4
4
|
private readonly client;
|
|
5
5
|
constructor(client: AgentForgeClient);
|
|
@@ -108,6 +108,20 @@ export declare class CasesResource {
|
|
|
108
108
|
* it was accepted or once closed. Returns the receipt as it is now.
|
|
109
109
|
*/
|
|
110
110
|
receiptReceived(token: string): Promise<CaseReceipt>;
|
|
111
|
+
/**
|
|
112
|
+
* `GET /api/v1/cases/receipts/:token/reviewables` — AGF-PDK-PRODUCT-REVIEWS: the order's
|
|
113
|
+
* products the buyer can review (catalog products of a COMPLETED order; free-text lines are
|
|
114
|
+
* not), each with their existing review (also when the business hid it). `eligible: false`
|
|
115
|
+
* with no items until the order is completed.
|
|
116
|
+
*/
|
|
117
|
+
receiptReviewables(token: string): Promise<ReceiptReviewables>;
|
|
118
|
+
/**
|
|
119
|
+
* `PUT /api/v1/cases/receipts/:token/review` — create or edit (upsert) the buyer's verified
|
|
120
|
+
* review of one product of the order. Sending it again from the same receipt edits it.
|
|
121
|
+
* 403 `not_eligible` before the order is completed, 400 `product_not_in_order` / `invalid_rating`
|
|
122
|
+
* / `body_too_long`. The reviewer's name comes from the order, never from the caller.
|
|
123
|
+
*/
|
|
124
|
+
receiptReview(token: string, input: SaveReceiptReviewInput): Promise<ProductReview>;
|
|
111
125
|
/**
|
|
112
126
|
* `GET /api/v1/cases/direct/form` — what a checkout asks besides the cart, the name
|
|
113
127
|
* and the phone: the order type and its other fields (chips for a closed choice).
|
package/dist/resources/cases.js
CHANGED
|
@@ -163,6 +163,24 @@ class CasesResource {
|
|
|
163
163
|
async receiptReceived(token) {
|
|
164
164
|
return this.client.request('POST', `/api/v1/cases/receipts/${encodeURIComponent(token)}/received`, {});
|
|
165
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* `GET /api/v1/cases/receipts/:token/reviewables` — AGF-PDK-PRODUCT-REVIEWS: the order's
|
|
168
|
+
* products the buyer can review (catalog products of a COMPLETED order; free-text lines are
|
|
169
|
+
* not), each with their existing review (also when the business hid it). `eligible: false`
|
|
170
|
+
* with no items until the order is completed.
|
|
171
|
+
*/
|
|
172
|
+
async receiptReviewables(token) {
|
|
173
|
+
return this.client.request('GET', `/api/v1/cases/receipts/${encodeURIComponent(token)}/reviewables`);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* `PUT /api/v1/cases/receipts/:token/review` — create or edit (upsert) the buyer's verified
|
|
177
|
+
* review of one product of the order. Sending it again from the same receipt edits it.
|
|
178
|
+
* 403 `not_eligible` before the order is completed, 400 `product_not_in_order` / `invalid_rating`
|
|
179
|
+
* / `body_too_long`. The reviewer's name comes from the order, never from the caller.
|
|
180
|
+
*/
|
|
181
|
+
async receiptReview(token, input) {
|
|
182
|
+
return this.client.request('PUT', `/api/v1/cases/receipts/${encodeURIComponent(token)}/review`, input);
|
|
183
|
+
}
|
|
166
184
|
/**
|
|
167
185
|
* `GET /api/v1/cases/direct/form` — what a checkout asks besides the cart, the name
|
|
168
186
|
* and the phone: the order type and its other fields (chips for a closed choice).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentForgeClient } from '../client';
|
|
2
2
|
import { AgentForgeError } from '../errors';
|
|
3
|
-
import type { AttachCatalogPhotoInput, Catalog, CatalogCategory, CatalogFileApplyInput, CatalogFileApplyResult, CatalogOptionChange, CatalogOptionChangesPlan, CatalogOptionGroup, CatalogUnit, SaveCatalogUnitInput, SaveCatalogOptionGroupInput, CatalogMenuItem, CatalogMenuRead, CatalogMenuReadInput, CatalogMenuAttachInput, CatalogMenuChatFile, CatalogMenuKeepInSyncInput, CatalogMenuKeepInSyncResult, CatalogFilePreview, CatalogFilePreviewInput, CatalogImportApplyResult, CatalogImportItem, CatalogImportPreview, CatalogImportSource, CatalogImportSourcePreview, CatalogImportRunResult, CatalogPhotoUploadTarget, CatalogProduct, CatalogProductPage, CatalogSheetTab, CatalogTemplateSheet, CreateCatalogTemplateSheetInput, CreateCatalogCategoryInput, CreateCatalogImportSourceInput, CreateCatalogProductInput, ListCatalogProductsInput, PreviewCatalogImportSourceInput, SignCatalogPhotoUploadInput, UpdateCatalogCategoryInput, UpdateCatalogImportSourceInput, UpdateCatalogProductInput, UpsertCatalogInput } from '../types';
|
|
3
|
+
import type { AttachCatalogCategoryImageInput, AttachCatalogPhotoInput, Catalog, CatalogCategory, CatalogFileApplyInput, CatalogFileApplyResult, CatalogOptionChange, CatalogOptionChangesPlan, CatalogOptionGroup, CatalogUnit, SaveCatalogUnitInput, SaveCatalogOptionGroupInput, CatalogMenuItem, CatalogMenuRead, CatalogMenuReadInput, CatalogMenuAttachInput, CatalogMenuChatFile, CatalogMenuKeepInSyncInput, CatalogMenuKeepInSyncResult, CatalogFilePreview, CatalogFilePreviewInput, CatalogImportApplyResult, CatalogImportItem, CatalogImportPreview, CatalogImportSource, CatalogImportSourcePreview, CatalogImportRunResult, CatalogPhotoUploadTarget, CatalogProduct, CatalogProductPage, HideProductReviewInput, ListProductReviewsForOwnerInput, ListProductReviewsInput, ProductLikeResult, ProductReviewOwner, ProductReviewsOwnerPage, ProductReviewsPage, CatalogSheetTab, CatalogTemplateSheet, CreateCatalogTemplateSheetInput, CreateCatalogCategoryInput, CreateCatalogImportSourceInput, CreateCatalogProductInput, ListCatalogProductsInput, PreviewCatalogImportSourceInput, SignCatalogPhotoUploadInput, UpdateCatalogCategoryInput, UpdateCatalogImportSourceInput, UpdateCatalogProductInput, UpsertCatalogInput } from '../types';
|
|
4
4
|
/** Max structured items per `import.preview/apply` call (platform cap). */
|
|
5
5
|
export declare const CATALOG_IMPORT_MAX_ITEMS = 200;
|
|
6
6
|
/** Thrown client-side, before any request, when `items` exceeds the cap. */
|
|
@@ -21,6 +21,18 @@ export declare class CatalogCategoriesResource {
|
|
|
21
21
|
delete(categoryId: string): Promise<void>;
|
|
22
22
|
/** `PATCH /categories/reorder` — `orderedIds` must be exactly the current set. */
|
|
23
23
|
reorder(orderedIds: string[]): Promise<CatalogCategory[]>;
|
|
24
|
+
/** `POST /categories/:id/image/sign-upload` — signed direct-upload target
|
|
25
|
+
* for the category photo (same storage, types and 8 MB cap as product
|
|
26
|
+
* photos). PUT the bytes to `uploadUrl`, then `attachImage(id, { url: publicUrl, key })`.
|
|
27
|
+
* 404 when the category is not this tenant's; nothing is signed. */
|
|
28
|
+
signImageUpload(categoryId: string, input: SignCatalogPhotoUploadInput): Promise<CatalogPhotoUploadTarget>;
|
|
29
|
+
/** `POST /categories/:id/image` — persist the uploaded photo; returns the
|
|
30
|
+
* category with `imageUrl` set. Replaces (and reclaims) a previous photo.
|
|
31
|
+
* 400 when `url`/`key` are not the signed object of this category. */
|
|
32
|
+
attachImage(categoryId: string, input: AttachCatalogCategoryImageInput): Promise<CatalogCategory>;
|
|
33
|
+
/** `DELETE /categories/:id/image` — clear the photo (`imageUrl: null`) and
|
|
34
|
+
* delete the stored object (best-effort). Idempotent. Returns the category. */
|
|
35
|
+
removeImage(categoryId: string): Promise<CatalogCategory>;
|
|
24
36
|
}
|
|
25
37
|
export declare class CatalogPhotosResource {
|
|
26
38
|
private readonly client;
|
|
@@ -77,9 +89,47 @@ export declare class CatalogOptionGroupsResource {
|
|
|
77
89
|
/** `PATCH /option-groups/:id/availability` — one option on or off («hoy no hay BBQ»). */
|
|
78
90
|
setAvailability(groupId: string, option: string, isAvailable: boolean): Promise<CatalogOptionGroup>;
|
|
79
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* A product's reviews (AGF-PDK-PRODUCT-REVIEWS). Writing one happens from the order's receipt
|
|
94
|
+
* (`cases.receiptReview`); here the public list and summary.
|
|
95
|
+
*/
|
|
96
|
+
export declare class CatalogProductReviewsResource {
|
|
97
|
+
private readonly client;
|
|
98
|
+
constructor(client: AgentForgeClient);
|
|
99
|
+
/** `GET /products/:id/reviews` — visible reviews newest first, the rating summary and the like count. 404 for another business's product. */
|
|
100
|
+
list(productId: string, input?: ListProductReviewsInput): Promise<ProductReviewsPage>;
|
|
101
|
+
}
|
|
102
|
+
/** Likes of signed-in customers (AGF-PDK-PRODUCT-REVIEWS): one per customer and product, removable. Needs an App secret (sk_live_). */
|
|
103
|
+
export declare class CatalogProductLikesResource {
|
|
104
|
+
private readonly client;
|
|
105
|
+
constructor(client: AgentForgeClient);
|
|
106
|
+
/** `PUT /products/:id/like` — like or unlike; idempotent. `externalUserId` is the App's stable customer id. */
|
|
107
|
+
set(productId: string, externalUserId: string, liked: boolean): Promise<ProductLikeResult>;
|
|
108
|
+
/** `POST /likes/mine` — which of these products (≤ 100) the customer liked. */
|
|
109
|
+
mine(externalUserId: string, productIds: string[]): Promise<string[]>;
|
|
110
|
+
}
|
|
111
|
+
/** The business's review inbox and moderation (AGF-PDK-PRODUCT-REVIEWS). The owner can reply, hide and unhide — never edit or delete. */
|
|
112
|
+
export declare class CatalogReviewsResource {
|
|
113
|
+
private readonly client;
|
|
114
|
+
constructor(client: AgentForgeClient);
|
|
115
|
+
/** `GET /reviews` — every review of the business, hidden ones too, newest first. */
|
|
116
|
+
listForOwner(input?: ListProductReviewsForOwnerInput): Promise<ProductReviewsOwnerPage>;
|
|
117
|
+
/** `PUT /reviews/:id/reply` — the business's public reply (≤ 1,000 characters, plain text); `body: null` removes it. */
|
|
118
|
+
reply(reviewId: string, input: {
|
|
119
|
+
body: string | null;
|
|
120
|
+
}): Promise<ProductReviewOwner>;
|
|
121
|
+
/** `POST /reviews/:id/hide` — takes an abusive review off the public list and the rating; the reason is required and kept. */
|
|
122
|
+
hide(reviewId: string, input: HideProductReviewInput): Promise<ProductReviewOwner>;
|
|
123
|
+
/** `POST /reviews/:id/unhide` — shows it again. */
|
|
124
|
+
unhide(reviewId: string): Promise<ProductReviewOwner>;
|
|
125
|
+
}
|
|
80
126
|
export declare class CatalogProductsResource {
|
|
81
127
|
private readonly client;
|
|
82
128
|
readonly photos: CatalogPhotosResource;
|
|
129
|
+
/** AGF-PDK-PRODUCT-REVIEWS — a product's public reviews and rating. */
|
|
130
|
+
readonly reviews: CatalogProductReviewsResource;
|
|
131
|
+
/** AGF-PDK-PRODUCT-REVIEWS — likes of signed-in customers. */
|
|
132
|
+
readonly likes: CatalogProductLikesResource;
|
|
83
133
|
constructor(client: AgentForgeClient);
|
|
84
134
|
/** `GET /products` — includes drafts/archived (owner view). Paginated. */
|
|
85
135
|
list(input?: ListCatalogProductsInput): Promise<CatalogProductPage>;
|
|
@@ -207,6 +257,8 @@ export declare class CatalogResource {
|
|
|
207
257
|
readonly sources: CatalogSourcesResource;
|
|
208
258
|
readonly optionGroups: CatalogOptionGroupsResource;
|
|
209
259
|
readonly units: CatalogUnitsResource;
|
|
260
|
+
/** AGF-PDK-PRODUCT-REVIEWS — the business's review inbox and moderation. */
|
|
261
|
+
readonly reviews: CatalogReviewsResource;
|
|
210
262
|
constructor(client: AgentForgeClient);
|
|
211
263
|
/** `GET /api/v1/catalog` — the tenant's catalog, or `null` when it has none yet
|
|
212
264
|
* (404 `CATALOG_NOT_FOUND`). Other 404s still throw. */
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// machine-readable code (`CATALOG_NOT_FOUND`, `FILE_EMPTY_FILE`,
|
|
17
17
|
// `INVALID_MAPPING`, `TOO_MANY_ITEMS`, …).
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.CatalogResource = exports.CatalogSourcesResource = exports.CatalogImportResource = exports.CatalogMenuImportResource = exports.CatalogFileImportResource = exports.CatalogProductsResource = exports.CatalogOptionGroupsResource = exports.CatalogUnitsResource = exports.CatalogPhotosResource = exports.CatalogCategoriesResource = exports.AgentForgeCatalogImportLimitError = exports.CATALOG_IMPORT_MAX_ITEMS = void 0;
|
|
19
|
+
exports.CatalogResource = exports.CatalogSourcesResource = exports.CatalogImportResource = exports.CatalogMenuImportResource = exports.CatalogFileImportResource = exports.CatalogProductsResource = exports.CatalogReviewsResource = exports.CatalogProductLikesResource = exports.CatalogProductReviewsResource = exports.CatalogOptionGroupsResource = exports.CatalogUnitsResource = exports.CatalogPhotosResource = exports.CatalogCategoriesResource = exports.AgentForgeCatalogImportLimitError = exports.CATALOG_IMPORT_MAX_ITEMS = void 0;
|
|
20
20
|
const errors_1 = require("../errors");
|
|
21
21
|
const BASE = '/api/v1/catalog';
|
|
22
22
|
const TENANT_AUTH = { forceApiKey: true };
|
|
@@ -78,6 +78,24 @@ class CatalogCategoriesResource {
|
|
|
78
78
|
async reorder(orderedIds) {
|
|
79
79
|
return this.client.request('PATCH', `${BASE}/categories/reorder`, { orderedIds }, TENANT_AUTH);
|
|
80
80
|
}
|
|
81
|
+
/** `POST /categories/:id/image/sign-upload` — signed direct-upload target
|
|
82
|
+
* for the category photo (same storage, types and 8 MB cap as product
|
|
83
|
+
* photos). PUT the bytes to `uploadUrl`, then `attachImage(id, { url: publicUrl, key })`.
|
|
84
|
+
* 404 when the category is not this tenant's; nothing is signed. */
|
|
85
|
+
async signImageUpload(categoryId, input) {
|
|
86
|
+
return this.client.request('POST', `${BASE}/categories/${seg(categoryId)}/image/sign-upload`, input, TENANT_AUTH);
|
|
87
|
+
}
|
|
88
|
+
/** `POST /categories/:id/image` — persist the uploaded photo; returns the
|
|
89
|
+
* category with `imageUrl` set. Replaces (and reclaims) a previous photo.
|
|
90
|
+
* 400 when `url`/`key` are not the signed object of this category. */
|
|
91
|
+
async attachImage(categoryId, input) {
|
|
92
|
+
return this.client.request('POST', `${BASE}/categories/${seg(categoryId)}/image`, input, TENANT_AUTH);
|
|
93
|
+
}
|
|
94
|
+
/** `DELETE /categories/:id/image` — clear the photo (`imageUrl: null`) and
|
|
95
|
+
* delete the stored object (best-effort). Idempotent. Returns the category. */
|
|
96
|
+
async removeImage(categoryId) {
|
|
97
|
+
return this.client.request('DELETE', `${BASE}/categories/${seg(categoryId)}/image`, undefined, TENANT_AUTH);
|
|
98
|
+
}
|
|
81
99
|
}
|
|
82
100
|
exports.CatalogCategoriesResource = CatalogCategoriesResource;
|
|
83
101
|
class CatalogPhotosResource {
|
|
@@ -163,10 +181,80 @@ class CatalogOptionGroupsResource {
|
|
|
163
181
|
}
|
|
164
182
|
}
|
|
165
183
|
exports.CatalogOptionGroupsResource = CatalogOptionGroupsResource;
|
|
184
|
+
/**
|
|
185
|
+
* A product's reviews (AGF-PDK-PRODUCT-REVIEWS). Writing one happens from the order's receipt
|
|
186
|
+
* (`cases.receiptReview`); here the public list and summary.
|
|
187
|
+
*/
|
|
188
|
+
class CatalogProductReviewsResource {
|
|
189
|
+
constructor(client) {
|
|
190
|
+
this.client = client;
|
|
191
|
+
}
|
|
192
|
+
/** `GET /products/:id/reviews` — visible reviews newest first, the rating summary and the like count. 404 for another business's product. */
|
|
193
|
+
async list(productId, input = {}) {
|
|
194
|
+
const qs = new URLSearchParams();
|
|
195
|
+
if (input.cursor)
|
|
196
|
+
qs.set('cursor', input.cursor);
|
|
197
|
+
if (input.limit !== undefined)
|
|
198
|
+
qs.set('limit', String(input.limit));
|
|
199
|
+
const q = qs.toString();
|
|
200
|
+
return this.client.request('GET', `${BASE}/products/${seg(productId)}/reviews${q ? `?${q}` : ''}`, undefined, TENANT_AUTH);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.CatalogProductReviewsResource = CatalogProductReviewsResource;
|
|
204
|
+
/** Likes of signed-in customers (AGF-PDK-PRODUCT-REVIEWS): one per customer and product, removable. Needs an App secret (sk_live_). */
|
|
205
|
+
class CatalogProductLikesResource {
|
|
206
|
+
constructor(client) {
|
|
207
|
+
this.client = client;
|
|
208
|
+
}
|
|
209
|
+
/** `PUT /products/:id/like` — like or unlike; idempotent. `externalUserId` is the App's stable customer id. */
|
|
210
|
+
async set(productId, externalUserId, liked) {
|
|
211
|
+
return this.client.request('PUT', `${BASE}/products/${seg(productId)}/like`, { externalUserId, liked }, TENANT_AUTH);
|
|
212
|
+
}
|
|
213
|
+
/** `POST /likes/mine` — which of these products (≤ 100) the customer liked. */
|
|
214
|
+
async mine(externalUserId, productIds) {
|
|
215
|
+
return (await this.client.request('POST', `${BASE}/likes/mine`, { externalUserId, productIds }, TENANT_AUTH)).productIds;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
exports.CatalogProductLikesResource = CatalogProductLikesResource;
|
|
219
|
+
/** The business's review inbox and moderation (AGF-PDK-PRODUCT-REVIEWS). The owner can reply, hide and unhide — never edit or delete. */
|
|
220
|
+
class CatalogReviewsResource {
|
|
221
|
+
constructor(client) {
|
|
222
|
+
this.client = client;
|
|
223
|
+
}
|
|
224
|
+
/** `GET /reviews` — every review of the business, hidden ones too, newest first. */
|
|
225
|
+
async listForOwner(input = {}) {
|
|
226
|
+
const qs = new URLSearchParams();
|
|
227
|
+
if (input.status)
|
|
228
|
+
qs.set('status', input.status);
|
|
229
|
+
if (input.productId)
|
|
230
|
+
qs.set('productId', input.productId);
|
|
231
|
+
if (input.cursor)
|
|
232
|
+
qs.set('cursor', input.cursor);
|
|
233
|
+
if (input.limit !== undefined)
|
|
234
|
+
qs.set('limit', String(input.limit));
|
|
235
|
+
const q = qs.toString();
|
|
236
|
+
return this.client.request('GET', `${BASE}/reviews${q ? `?${q}` : ''}`, undefined, TENANT_AUTH);
|
|
237
|
+
}
|
|
238
|
+
/** `PUT /reviews/:id/reply` — the business's public reply (≤ 1,000 characters, plain text); `body: null` removes it. */
|
|
239
|
+
async reply(reviewId, input) {
|
|
240
|
+
return this.client.request('PUT', `${BASE}/reviews/${seg(reviewId)}/reply`, input, TENANT_AUTH);
|
|
241
|
+
}
|
|
242
|
+
/** `POST /reviews/:id/hide` — takes an abusive review off the public list and the rating; the reason is required and kept. */
|
|
243
|
+
async hide(reviewId, input) {
|
|
244
|
+
return this.client.request('POST', `${BASE}/reviews/${seg(reviewId)}/hide`, input, TENANT_AUTH);
|
|
245
|
+
}
|
|
246
|
+
/** `POST /reviews/:id/unhide` — shows it again. */
|
|
247
|
+
async unhide(reviewId) {
|
|
248
|
+
return this.client.request('POST', `${BASE}/reviews/${seg(reviewId)}/unhide`, {}, TENANT_AUTH);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.CatalogReviewsResource = CatalogReviewsResource;
|
|
166
252
|
class CatalogProductsResource {
|
|
167
253
|
constructor(client) {
|
|
168
254
|
this.client = client;
|
|
169
255
|
this.photos = new CatalogPhotosResource(client);
|
|
256
|
+
this.reviews = new CatalogProductReviewsResource(client);
|
|
257
|
+
this.likes = new CatalogProductLikesResource(client);
|
|
170
258
|
}
|
|
171
259
|
/** `GET /products` — includes drafts/archived (owner view). Paginated. */
|
|
172
260
|
async list(input = {}) {
|
|
@@ -373,6 +461,7 @@ exports.CatalogSourcesResource = CatalogSourcesResource;
|
|
|
373
461
|
class CatalogResource {
|
|
374
462
|
constructor(client) {
|
|
375
463
|
this.client = client;
|
|
464
|
+
this.reviews = new CatalogReviewsResource(client);
|
|
376
465
|
this.categories = new CatalogCategoriesResource(client);
|
|
377
466
|
this.products = new CatalogProductsResource(client);
|
|
378
467
|
this.import = new CatalogImportResource(client);
|
|
@@ -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
|
-
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
@@ -1189,6 +1189,12 @@ export interface CatalogCategory {
|
|
|
1189
1189
|
name: string;
|
|
1190
1190
|
slug: string;
|
|
1191
1191
|
sortOrder: number;
|
|
1192
|
+
/** Public URL of the category photo, or `null` when it has none. Set via
|
|
1193
|
+
* `catalog.categories.signImageUpload` -> PUT -> `attachImage`. */
|
|
1194
|
+
imageUrl: string | null;
|
|
1195
|
+
/** Storage key backing `imageUrl` (`null` when none). Informational —
|
|
1196
|
+
* the platform uses it to reclaim the object on replace/remove/delete. */
|
|
1197
|
+
imageKey: string | null;
|
|
1192
1198
|
createdAt: string;
|
|
1193
1199
|
updatedAt: string;
|
|
1194
1200
|
}
|
|
@@ -1255,6 +1261,10 @@ export interface CatalogProduct {
|
|
|
1255
1261
|
booking?: CatalogBookingRule | null;
|
|
1256
1262
|
lastSoldAt?: string | null;
|
|
1257
1263
|
demandCount: number;
|
|
1264
|
+
/** AGF-PDK-PRODUCT-REVIEWS — over the visible reviews (absent on an older platform). */
|
|
1265
|
+
rating?: ProductRatingSummary;
|
|
1266
|
+
/** AGF-PDK-PRODUCT-REVIEWS — customers who liked it (absent on an older platform). */
|
|
1267
|
+
likeCount?: number;
|
|
1258
1268
|
createdAt: string;
|
|
1259
1269
|
updatedAt: string;
|
|
1260
1270
|
}
|
|
@@ -1458,6 +1468,13 @@ export interface SignCatalogPhotoUploadInput {
|
|
|
1458
1468
|
contentType: string;
|
|
1459
1469
|
contentLength?: number;
|
|
1460
1470
|
}
|
|
1471
|
+
/** `POST /categories/:id/image` — the `publicUrl` + `key` that
|
|
1472
|
+
* `categories.signImageUpload` returned (both required; the platform refuses
|
|
1473
|
+
* a url/key that is not the object it signed for this category). */
|
|
1474
|
+
export interface AttachCatalogCategoryImageInput {
|
|
1475
|
+
url: string;
|
|
1476
|
+
key: string;
|
|
1477
|
+
}
|
|
1461
1478
|
export interface AttachCatalogPhotoInput {
|
|
1462
1479
|
url: string;
|
|
1463
1480
|
isCover?: boolean;
|
|
@@ -2934,4 +2951,113 @@ export interface AppCaseWebhookEvent extends AppWebhookEventBase {
|
|
|
2934
2951
|
origin?: CaseOrigin;
|
|
2935
2952
|
};
|
|
2936
2953
|
}
|
|
2954
|
+
/** A product's rating over its VISIBLE reviews (hidden ones never count). */
|
|
2955
|
+
export interface ProductRatingSummary {
|
|
2956
|
+
/** One decimal; null with no reviews. */
|
|
2957
|
+
average: number | null;
|
|
2958
|
+
count: number;
|
|
2959
|
+
/** Reviews per star. */
|
|
2960
|
+
distribution: {
|
|
2961
|
+
1: number;
|
|
2962
|
+
2: number;
|
|
2963
|
+
3: number;
|
|
2964
|
+
4: number;
|
|
2965
|
+
5: number;
|
|
2966
|
+
};
|
|
2967
|
+
}
|
|
2968
|
+
/**
|
|
2969
|
+
* A buyer's review of a product, written from the receipt of a completed order
|
|
2970
|
+
* (so every one is a verified purchase). Never carries the reviewer's ids or contact data.
|
|
2971
|
+
*/
|
|
2972
|
+
export interface ProductReview {
|
|
2973
|
+
id: string;
|
|
2974
|
+
productId: string;
|
|
2975
|
+
/** Whole number 1–5. */
|
|
2976
|
+
rating: number;
|
|
2977
|
+
/** Plain text, or null for stars only. */
|
|
2978
|
+
body: string | null;
|
|
2979
|
+
/** The customer's first name + last initial («Laura G.»). */
|
|
2980
|
+
reviewerName: string;
|
|
2981
|
+
reviewerAvatarUrl: string | null;
|
|
2982
|
+
/** Always true: «Compra verificada». */
|
|
2983
|
+
verifiedPurchase: true;
|
|
2984
|
+
/** Public lists only carry `visible`; a buyer's own review (receipt) can be `hidden`. */
|
|
2985
|
+
status: 'visible' | 'hidden';
|
|
2986
|
+
/** The business's public reply under the review. */
|
|
2987
|
+
reply: {
|
|
2988
|
+
body: string;
|
|
2989
|
+
at: string;
|
|
2990
|
+
} | null;
|
|
2991
|
+
createdAt: string;
|
|
2992
|
+
updatedAt: string;
|
|
2993
|
+
}
|
|
2994
|
+
/** A review as the business reads it in its inbox: moderation details and the order. */
|
|
2995
|
+
export interface ProductReviewOwner extends ProductReview {
|
|
2996
|
+
productTitle: string | null;
|
|
2997
|
+
productSlug: string | null;
|
|
2998
|
+
/** The order it was written from. */
|
|
2999
|
+
caseId: string;
|
|
3000
|
+
hiddenReason: string | null;
|
|
3001
|
+
hiddenAt: string | null;
|
|
3002
|
+
/** Who of the business hid it (what the App sent as `hiddenBy`). */
|
|
3003
|
+
hiddenBy: string | null;
|
|
3004
|
+
}
|
|
3005
|
+
/** `GET /api/v1/catalog/products/:id/reviews`. */
|
|
3006
|
+
export interface ProductReviewsPage {
|
|
3007
|
+
/** Visible reviews, newest first. */
|
|
3008
|
+
items: ProductReview[];
|
|
3009
|
+
summary: ProductRatingSummary;
|
|
3010
|
+
likeCount: number;
|
|
3011
|
+
nextCursor: string | null;
|
|
3012
|
+
}
|
|
3013
|
+
export interface ListProductReviewsInput {
|
|
3014
|
+
cursor?: string;
|
|
3015
|
+
/** 1–50, default 20. */
|
|
3016
|
+
limit?: number;
|
|
3017
|
+
}
|
|
3018
|
+
/** `GET /api/v1/catalog/reviews` (the business's inbox). */
|
|
3019
|
+
export interface ProductReviewsOwnerPage {
|
|
3020
|
+
items: ProductReviewOwner[];
|
|
3021
|
+
nextCursor: string | null;
|
|
3022
|
+
}
|
|
3023
|
+
export interface ListProductReviewsForOwnerInput {
|
|
3024
|
+
/** Absent = both. */
|
|
3025
|
+
status?: 'visible' | 'hidden';
|
|
3026
|
+
productId?: string;
|
|
3027
|
+
cursor?: string;
|
|
3028
|
+
/** 1–50, default 20. */
|
|
3029
|
+
limit?: number;
|
|
3030
|
+
}
|
|
3031
|
+
export interface HideProductReviewInput {
|
|
3032
|
+
/** Required, ≤ 500 characters; kept with the review. */
|
|
3033
|
+
reason: string;
|
|
3034
|
+
/** Who of the business hides it (e.g. `member:<id>`), for the audit trail. */
|
|
3035
|
+
hiddenBy?: string;
|
|
3036
|
+
}
|
|
3037
|
+
/** `PUT /api/v1/catalog/products/:id/like`. */
|
|
3038
|
+
export interface ProductLikeResult {
|
|
3039
|
+
liked: boolean;
|
|
3040
|
+
likeCount: number;
|
|
3041
|
+
}
|
|
3042
|
+
/** One product of a completed order the buyer can review, with their review of it (also when hidden). */
|
|
3043
|
+
export interface ReceiptReviewable {
|
|
3044
|
+
productId: string;
|
|
3045
|
+
title: string;
|
|
3046
|
+
coverUrl: string | null;
|
|
3047
|
+
review: ProductReview | null;
|
|
3048
|
+
}
|
|
3049
|
+
/** `GET /api/v1/cases/receipts/:token/reviewables`. */
|
|
3050
|
+
export interface ReceiptReviewables {
|
|
3051
|
+
/** The order is completed. When false, `items` is empty (cancelled, rejected or still open orders are never reviewable). */
|
|
3052
|
+
eligible: boolean;
|
|
3053
|
+
items: ReceiptReviewable[];
|
|
3054
|
+
}
|
|
3055
|
+
/** `PUT /api/v1/cases/receipts/:token/review`. 403 `not_eligible` until the order is completed; 400 `product_not_in_order`. */
|
|
3056
|
+
export interface SaveReceiptReviewInput {
|
|
3057
|
+
productId: string;
|
|
3058
|
+
/** Whole number 1–5. */
|
|
3059
|
+
rating: number;
|
|
3060
|
+
/** Plain text ≤ 2,000 characters (HTML is stripped); empty or null = stars only. */
|
|
3061
|
+
body?: string | null;
|
|
3062
|
+
}
|
|
2937
3063
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentforge-io/sdk-server",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.65.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",
|