@agentforge-io/sdk-server 4.34.0 → 4.36.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/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export type { AgentForgeClientOptions, RequestOptions } from './client';
3
3
  export { AgentForgeError, AgentForgeAuthError, AgentForgeNotFoundError, AgentForgeNetworkError, } 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, 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, TemplateCategoryRef, MarketplaceCategory, MarketplaceCategoryGroup, MarketplaceLocale, TemplateInstallResult, TenantConfigEntry, Place, PlaceSuggestion, SearchPlacesInput, AutocompletePlacesInput, PlacesScope, CaseField, CaseBusinessState, CaseType, CaseState, CasePayment, CasePaymentAccount, CasePaymentStatus, CaseReceiptPayment, CaseView, CreateDirectOrderInput, DirectOrderForm, CaseReceipt, CaseReceiptLine, ListCasesInput, AddressValue, DeliveryLocalPricing, DeliverySettings, PaymentMethodKind, PaymentSettings, PaymentSettingsInput, PaymentAccount, PaymentCountry, PaymentFieldDef, PaymentMethodDef, StructuredConfigInput, StructuredConfigEntry, DeliveryQuoteStatus, DeliveryQuoteInput, DeliveryQuote, AppSelf, 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, 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, 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, TemplateCategoryRef, MarketplaceCategory, MarketplaceCategoryGroup, MarketplaceLocale, TemplateInstallResult, TenantConfigEntry, Place, PlaceSuggestion, SearchPlacesInput, AutocompletePlacesInput, PlacesScope, CaseField, CaseBusinessState, CaseType, CaseState, CasePayment, CasePaymentAccount, CasePaymentStatus, CaseReceiptPayment, CaseView, CreateDirectOrderInput, DirectOrderForm, CaseReceipt, CaseReceiptLine, ListCasesInput, AddressValue, DeliveryLocalPricing, DeliverySettings, PaymentMethodKind, PaymentSettings, PaymentSettingsInput, PaymentAccount, PaymentCountry, PaymentFieldDef, PaymentMethodDef, StructuredConfigInput, StructuredConfigEntry, DeliveryQuoteStatus, DeliveryQuoteInput, DeliveryQuote, AppSelf, 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, 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';
@@ -26,7 +26,7 @@ export type { ContactVerificationChannel, LinkContactInput, LinkContactResult, A
26
26
  export { DeliveryResource } from './resources/delivery';
27
27
  export { CasesResource } from './resources/cases';
28
28
  export { BusinessRolesResource } from './resources/business-roles';
29
- export { CatalogResource, CatalogCategoriesResource, CatalogProductsResource, CatalogPhotosResource, CatalogImportResource, CatalogFileImportResource, CatalogSourcesResource, AgentForgeCatalogImportLimitError, CATALOG_IMPORT_MAX_ITEMS, } from './resources/catalog';
29
+ export { CatalogResource, CatalogCategoriesResource, CatalogProductsResource, CatalogPhotosResource, CatalogImportResource, CatalogFileImportResource, CatalogMenuImportResource, CatalogOptionGroupsResource, CatalogUnitsResource, CatalogSourcesResource, AgentForgeCatalogImportLimitError, CATALOG_IMPORT_MAX_ITEMS, } from './resources/catalog';
30
30
  export type { ListThreadsOptions, SendMessageInput, AssignThreadInput, UnassignThreadInput, SetThreadModeInput, CloseThreadInput, } from './resources/inbox';
31
31
  export { ProvisioningResource } from './resources/provisioning';
32
32
  export type { ProvisionedTenant, ProvisionedApp, ProvisionedTeam, } from './resources/provisioning';
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@
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.CatalogFileImportResource = exports.CatalogImportResource = exports.CatalogPhotosResource = exports.CatalogProductsResource = exports.CatalogCategoriesResource = exports.CatalogResource = exports.BusinessRolesResource = exports.CasesResource = exports.DeliveryResource = exports.ContactVerificationResource = exports.ContactsResource = exports.PlacesResource = exports.TenantConfigResource = exports.MarketplaceResource = 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.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.ContactVerificationResource = exports.ContactsResource = exports.PlacesResource = exports.TenantConfigResource = exports.MarketplaceResource = 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;
32
32
  var client_1 = require("./client");
33
33
  Object.defineProperty(exports, "AgentForgeClient", { enumerable: true, get: function () { return client_1.AgentForgeClient; } });
34
34
  Object.defineProperty(exports, "INSTALLED_TENANT_HEADER", { enumerable: true, get: function () { return client_1.INSTALLED_TENANT_HEADER; } });
@@ -85,6 +85,9 @@ Object.defineProperty(exports, "CatalogProductsResource", { enumerable: true, ge
85
85
  Object.defineProperty(exports, "CatalogPhotosResource", { enumerable: true, get: function () { return catalog_1.CatalogPhotosResource; } });
86
86
  Object.defineProperty(exports, "CatalogImportResource", { enumerable: true, get: function () { return catalog_1.CatalogImportResource; } });
87
87
  Object.defineProperty(exports, "CatalogFileImportResource", { enumerable: true, get: function () { return catalog_1.CatalogFileImportResource; } });
88
+ Object.defineProperty(exports, "CatalogMenuImportResource", { enumerable: true, get: function () { return catalog_1.CatalogMenuImportResource; } });
89
+ Object.defineProperty(exports, "CatalogOptionGroupsResource", { enumerable: true, get: function () { return catalog_1.CatalogOptionGroupsResource; } });
90
+ Object.defineProperty(exports, "CatalogUnitsResource", { enumerable: true, get: function () { return catalog_1.CatalogUnitsResource; } });
88
91
  Object.defineProperty(exports, "CatalogSourcesResource", { enumerable: true, get: function () { return catalog_1.CatalogSourcesResource; } });
89
92
  Object.defineProperty(exports, "AgentForgeCatalogImportLimitError", { enumerable: true, get: function () { return catalog_1.AgentForgeCatalogImportLimitError; } });
90
93
  Object.defineProperty(exports, "CATALOG_IMPORT_MAX_ITEMS", { enumerable: true, get: function () { return catalog_1.CATALOG_IMPORT_MAX_ITEMS; } });
@@ -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, 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 { AttachCatalogPhotoInput, Catalog, CatalogCategory, CatalogFileApplyInput, CatalogFileApplyResult, CatalogOptionChange, CatalogOptionChangesPlan, CatalogOptionGroup, CatalogUnit, SaveCatalogUnitInput, SaveCatalogOptionGroupInput, CatalogMenuItem, CatalogMenuRead, CatalogMenuReadInput, 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';
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. */
@@ -38,6 +38,45 @@ export declare class CatalogPhotosResource {
38
38
  /** `PATCH …/photos/cover` */
39
39
  setCover(productId: string, url: string): Promise<CatalogProduct>;
40
40
  }
41
+ /** AGF-UNITS U1 — units of measure: the standard ones and the business's own. */
42
+ export declare class CatalogUnitsResource {
43
+ private readonly client;
44
+ constructor(client: AgentForgeClient);
45
+ /** `GET /units` */
46
+ list(): Promise<{
47
+ standard: CatalogUnit[];
48
+ custom: CatalogUnit[];
49
+ }>;
50
+ /** `POST /units` — create (or replace, same key). 400 `INVALID_UNIT`. */
51
+ save(input: SaveCatalogUnitInput): Promise<CatalogUnit>;
52
+ /** `DELETE /units/:key` — 409 `UNIT_IN_USE` while a product is measured in it. */
53
+ delete(key: string): Promise<{
54
+ removed: boolean;
55
+ }>;
56
+ }
57
+ /**
58
+ * AGF-MENU-OPTIONS M2 — the catalog's option groups library (sauces, sizes,
59
+ * sides, «sin cebolla»), reused by products through `optionGroupIds`.
60
+ */
61
+ export declare class CatalogOptionGroupsResource {
62
+ private readonly client;
63
+ constructor(client: AgentForgeClient);
64
+ /** `GET /option-groups` */
65
+ list(): Promise<CatalogOptionGroup[]>;
66
+ /** `POST /option-groups` — create, or replace the group with the same `id`. 400 `INVALID_OPTION_GROUP`. */
67
+ save(input: SaveCatalogOptionGroupInput): Promise<CatalogOptionGroup>;
68
+ /** `DELETE /option-groups/:id` — also takes it off every product. */
69
+ delete(groupId: string): Promise<{
70
+ removed: boolean;
71
+ products: number;
72
+ }>;
73
+ /** `POST /option-groups/changes/preview` — plan of changes (writes nothing). 400 with the reason. */
74
+ previewChanges(changes: CatalogOptionChange[]): Promise<CatalogOptionChangesPlan>;
75
+ /** `POST /option-groups/changes/apply` — applies the changes the owner confirmed. */
76
+ applyChanges(changes: CatalogOptionChange[]): Promise<CatalogOptionChangesPlan>;
77
+ /** `PATCH /option-groups/:id/availability` — one option on or off («hoy no hay BBQ»). */
78
+ setAvailability(groupId: string, option: string, isAvailable: boolean): Promise<CatalogOptionGroup>;
79
+ }
41
80
  export declare class CatalogProductsResource {
42
81
  private readonly client;
43
82
  readonly photos: CatalogPhotosResource;
@@ -72,9 +111,26 @@ export declare class CatalogFileImportResource {
72
111
  * (field → exact header). Needs a catalog. */
73
112
  apply(input: CatalogFileApplyInput): Promise<CatalogFileApplyResult>;
74
113
  }
114
+ /**
115
+ * AGF-MENU-OPTIONS M1 — a catalog read by AI from what the business has: pasted
116
+ * text, a photo of the menu, a PDF, a Word (.docx), an Excel/CSV. `read` writes
117
+ * nothing (items + what importing them would do); the owner confirms (maybe
118
+ * edits) and `apply` imports them — same name = update. Never quantities.
119
+ */
120
+ export declare class CatalogMenuImportResource {
121
+ private readonly client;
122
+ constructor(client: AgentForgeClient);
123
+ /** `POST /import/menu/read` (multipart) — `text` and/or a `file` (≤10 MB). Can take a minute. */
124
+ read(input: CatalogMenuReadInput): Promise<CatalogMenuRead>;
125
+ /** `POST /import/menu/apply` — the confirmed items (max 200). */
126
+ apply(items: CatalogMenuItem[], opts?: {
127
+ kind?: 'product' | 'service';
128
+ }): Promise<CatalogFileApplyResult>;
129
+ }
75
130
  export declare class CatalogImportResource {
76
131
  private readonly client;
77
132
  readonly file: CatalogFileImportResource;
133
+ readonly menu: CatalogMenuImportResource;
78
134
  constructor(client: AgentForgeClient);
79
135
  /** `POST /import/preview` — validate structured items WITHOUT writing. Max 200
80
136
  * (throws `AgentForgeCatalogImportLimitError` above that, before any request). */
@@ -134,6 +190,8 @@ export declare class CatalogResource {
134
190
  readonly products: CatalogProductsResource;
135
191
  readonly import: CatalogImportResource;
136
192
  readonly sources: CatalogSourcesResource;
193
+ readonly optionGroups: CatalogOptionGroupsResource;
194
+ readonly units: CatalogUnitsResource;
137
195
  constructor(client: AgentForgeClient);
138
196
  /** `GET /api/v1/catalog` — the tenant's catalog, or `null` when it has none yet
139
197
  * (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.CatalogFileImportResource = exports.CatalogProductsResource = 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.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 };
@@ -110,6 +110,59 @@ class CatalogPhotosResource {
110
110
  }
111
111
  }
112
112
  exports.CatalogPhotosResource = CatalogPhotosResource;
113
+ /** AGF-UNITS U1 — units of measure: the standard ones and the business's own. */
114
+ class CatalogUnitsResource {
115
+ constructor(client) {
116
+ this.client = client;
117
+ }
118
+ /** `GET /units` */
119
+ async list() {
120
+ return this.client.request('GET', `${BASE}/units`, undefined, TENANT_AUTH);
121
+ }
122
+ /** `POST /units` — create (or replace, same key). 400 `INVALID_UNIT`. */
123
+ async save(input) {
124
+ return this.client.request('POST', `${BASE}/units`, input, TENANT_AUTH);
125
+ }
126
+ /** `DELETE /units/:key` — 409 `UNIT_IN_USE` while a product is measured in it. */
127
+ async delete(key) {
128
+ return this.client.request('DELETE', `${BASE}/units/${seg(key)}`, undefined, TENANT_AUTH);
129
+ }
130
+ }
131
+ exports.CatalogUnitsResource = CatalogUnitsResource;
132
+ /**
133
+ * AGF-MENU-OPTIONS M2 — the catalog's option groups library (sauces, sizes,
134
+ * sides, «sin cebolla»), reused by products through `optionGroupIds`.
135
+ */
136
+ class CatalogOptionGroupsResource {
137
+ constructor(client) {
138
+ this.client = client;
139
+ }
140
+ /** `GET /option-groups` */
141
+ async list() {
142
+ return (await this.client.request('GET', `${BASE}/option-groups`, undefined, TENANT_AUTH)).items;
143
+ }
144
+ /** `POST /option-groups` — create, or replace the group with the same `id`. 400 `INVALID_OPTION_GROUP`. */
145
+ async save(input) {
146
+ return this.client.request('POST', `${BASE}/option-groups`, input, TENANT_AUTH);
147
+ }
148
+ /** `DELETE /option-groups/:id` — also takes it off every product. */
149
+ async delete(groupId) {
150
+ return this.client.request('DELETE', `${BASE}/option-groups/${seg(groupId)}`, undefined, TENANT_AUTH);
151
+ }
152
+ /** `POST /option-groups/changes/preview` — plan of changes (writes nothing). 400 with the reason. */
153
+ async previewChanges(changes) {
154
+ return this.client.request('POST', `${BASE}/option-groups/changes/preview`, { changes }, TENANT_AUTH);
155
+ }
156
+ /** `POST /option-groups/changes/apply` — applies the changes the owner confirmed. */
157
+ async applyChanges(changes) {
158
+ return this.client.request('POST', `${BASE}/option-groups/changes/apply`, { changes }, TENANT_AUTH);
159
+ }
160
+ /** `PATCH /option-groups/:id/availability` — one option on or off («hoy no hay BBQ»). */
161
+ async setAvailability(groupId, option, isAvailable) {
162
+ return this.client.request('PATCH', `${BASE}/option-groups/${seg(groupId)}/availability`, { option, isAvailable }, TENANT_AUTH);
163
+ }
164
+ }
165
+ exports.CatalogOptionGroupsResource = CatalogOptionGroupsResource;
113
166
  class CatalogProductsResource {
114
167
  constructor(client) {
115
168
  this.client = client;
@@ -179,10 +232,40 @@ class CatalogFileImportResource {
179
232
  }
180
233
  }
181
234
  exports.CatalogFileImportResource = CatalogFileImportResource;
235
+ /**
236
+ * AGF-MENU-OPTIONS M1 — a catalog read by AI from what the business has: pasted
237
+ * text, a photo of the menu, a PDF, a Word (.docx), an Excel/CSV. `read` writes
238
+ * nothing (items + what importing them would do); the owner confirms (maybe
239
+ * edits) and `apply` imports them — same name = update. Never quantities.
240
+ */
241
+ class CatalogMenuImportResource {
242
+ constructor(client) {
243
+ this.client = client;
244
+ }
245
+ /** `POST /import/menu/read` (multipart) — `text` and/or a `file` (≤10 MB). Can take a minute. */
246
+ async read(input) {
247
+ const form = new FormData();
248
+ if (input.text !== undefined)
249
+ form.append('text', input.text);
250
+ if (input.file !== undefined) {
251
+ const raw = toBlob(input.file);
252
+ const blob = input.mimeType && !raw.type ? new Blob([raw], { type: input.mimeType }) : raw;
253
+ form.append('file', blob, input.filename ?? 'menu');
254
+ }
255
+ const res = await this.client.requestRaw('POST', `${BASE}/import/menu/read`, { ...TENANT_AUTH, formData: form, timeoutMs: 180000 });
256
+ return (await res.json());
257
+ }
258
+ /** `POST /import/menu/apply` — the confirmed items (max 200). */
259
+ async apply(items, opts = {}) {
260
+ return this.client.request('POST', `${BASE}/import/menu/apply`, { items, ...opts }, { ...TENANT_AUTH, timeoutMs: 120000 });
261
+ }
262
+ }
263
+ exports.CatalogMenuImportResource = CatalogMenuImportResource;
182
264
  class CatalogImportResource {
183
265
  constructor(client) {
184
266
  this.client = client;
185
267
  this.file = new CatalogFileImportResource(client);
268
+ this.menu = new CatalogMenuImportResource(client);
186
269
  }
187
270
  /** `POST /import/preview` — validate structured items WITHOUT writing. Max 200
188
271
  * (throws `AgentForgeCatalogImportLimitError` above that, before any request). */
@@ -269,6 +352,8 @@ class CatalogResource {
269
352
  this.categories = new CatalogCategoriesResource(client);
270
353
  this.products = new CatalogProductsResource(client);
271
354
  this.import = new CatalogImportResource(client);
355
+ this.optionGroups = new CatalogOptionGroupsResource(client);
356
+ this.units = new CatalogUnitsResource(client);
272
357
  this.sources = new CatalogSourcesResource(client);
273
358
  }
274
359
  /** `GET /api/v1/catalog` — the tenant's catalog, or `null` when it has none yet
package/dist/types.d.ts CHANGED
@@ -1045,6 +1045,11 @@ export interface CatalogProduct {
1045
1045
  at: string;
1046
1046
  }>;
1047
1047
  lockedFields: CatalogLockableField[];
1048
+ /** AGF-MENU-OPTIONS M2 — the catalog's option groups this product offers, in order. */
1049
+ optionGroupIds?: string[];
1050
+ /** AGF-UNITS U2 — how it is sold; null = by unit. Sold by measure, `stock` counts the unit
1051
+ * kind's base (g, ml, cm): divide by the unit's `base` to read it in the product's unit. */
1052
+ saleRule?: CatalogSaleRule | null;
1048
1053
  lastSoldAt?: string | null;
1049
1054
  demandCount: number;
1050
1055
  createdAt: string;
@@ -1073,6 +1078,129 @@ export interface CreateCatalogProductInput {
1073
1078
  }
1074
1079
  export interface UpdateCatalogProductInput extends Partial<CreateCatalogProductInput> {
1075
1080
  sortOrder?: number;
1081
+ /** AGF-MENU-OPTIONS M2 — ids from `catalog.optionGroups.list()`, in order ([] removes them). */
1082
+ optionGroupIds?: string[];
1083
+ /** AGF-UNITS U2 — `{ by: 'measure', step?, min? }` (in the product's unit) or `{ by: 'unit' }`.
1084
+ * Switching converts the stock; a measure needs a weight/volume/length/area/time unit. */
1085
+ saleRule?: CatalogSaleRule;
1086
+ }
1087
+ /** AGF-UNITS U2 — how a product is sold. */
1088
+ export interface CatalogSaleRule {
1089
+ by: 'unit' | 'measure';
1090
+ /** Units of the product's unit per step (0.25 lb). */
1091
+ step?: number;
1092
+ /** Fewest units of the product's unit per line. */
1093
+ min?: number;
1094
+ }
1095
+ /** AGF-UNITS U1 — a unit of measure: standard (unidad, kg, libra, litro, metro, caja…) or the business's own. */
1096
+ export interface CatalogUnit {
1097
+ /** What a product stores in `unit` (absent = unidad). */
1098
+ key: string;
1099
+ name: string;
1100
+ plural: string;
1101
+ /** Short label after a number or a price («kg», «lb»). */
1102
+ short?: string;
1103
+ kind: 'count' | 'weight' | 'volume' | 'length' | 'area' | 'time';
1104
+ /** Decimals a quantity of it may have (count units: 0). */
1105
+ decimals: number;
1106
+ /** Size in the kind's base unit (g, ml, cm, cm², min). */
1107
+ base?: number;
1108
+ aliases?: string[];
1109
+ }
1110
+ /** Create (or replace, same key) one of the business's units. */
1111
+ export interface SaveCatalogUnitInput {
1112
+ key?: string;
1113
+ name: string;
1114
+ plural?: string;
1115
+ kind?: CatalogUnit['kind'];
1116
+ decimals?: number;
1117
+ }
1118
+ /** AGF-MENU-OPTIONS M2 — one option of a group («BBQ», +1.000). */
1119
+ export interface CatalogOption {
1120
+ id: string;
1121
+ name: string;
1122
+ /** Added to the product's price per unit, in cents (0 = included). */
1123
+ priceDeltaCents: number;
1124
+ /** false: «hoy no hay», hidden from customers. */
1125
+ isAvailable: boolean;
1126
+ }
1127
+ /** AGF-MENU-OPTIONS M2 — a group of the catalog's library («Salsa», «Tamaño»), reused by products. */
1128
+ export interface CatalogOptionGroup {
1129
+ id: string;
1130
+ name: string;
1131
+ /** `single`: one option (a size); `multi`: several. */
1132
+ selection: 'single' | 'multi';
1133
+ required: boolean;
1134
+ min: number;
1135
+ max: number;
1136
+ options: CatalogOption[];
1137
+ }
1138
+ /** Create (no id) or replace (same id) a group. Ids of options kept when given. */
1139
+ export interface SaveCatalogOptionGroupInput {
1140
+ id?: string;
1141
+ name: string;
1142
+ selection: 'single' | 'multi';
1143
+ required?: boolean;
1144
+ min?: number;
1145
+ max?: number;
1146
+ options: Array<{
1147
+ id?: string;
1148
+ name: string;
1149
+ priceDeltaCents?: number;
1150
+ isAvailable?: boolean;
1151
+ }>;
1152
+ }
1153
+ /** AGF-MENU-OPTIONS M3 — one change to the option groups (the owner's chat proposes them). */
1154
+ export type CatalogOptionChange = {
1155
+ op: 'save_group';
1156
+ group: {
1157
+ name: string;
1158
+ selection?: 'single' | 'multi';
1159
+ required?: boolean;
1160
+ max?: number;
1161
+ options: Array<{
1162
+ name: string;
1163
+ priceDeltaCents?: number;
1164
+ isAvailable?: boolean;
1165
+ }>;
1166
+ };
1167
+ } | {
1168
+ op: 'attach' | 'detach';
1169
+ group: string;
1170
+ products: string[];
1171
+ } | {
1172
+ op: 'delete_group';
1173
+ group: string;
1174
+ };
1175
+ /** A plan of option changes as the confirmation card shows it. */
1176
+ export interface CatalogOptionChangesPlan {
1177
+ changes: CatalogOptionChange[];
1178
+ summary: Array<{
1179
+ kind: 'group_created' | 'group_updated';
1180
+ group: string;
1181
+ selection: 'single' | 'multi';
1182
+ required: boolean;
1183
+ max: number;
1184
+ options: Array<{
1185
+ name: string;
1186
+ priceDeltaCents: number;
1187
+ isAvailable: boolean;
1188
+ }>;
1189
+ } | {
1190
+ kind: 'attached' | 'detached';
1191
+ group: string;
1192
+ products: string[];
1193
+ } | {
1194
+ kind: 'group_deleted';
1195
+ group: string;
1196
+ products: number;
1197
+ }>;
1198
+ productsChanged: number;
1199
+ }
1200
+ /** A customer's choice for one group: its name or id and the options' names or ids. */
1201
+ export interface CatalogOptionChoice {
1202
+ group: string;
1203
+ options: string[];
1076
1204
  }
1077
1205
  export interface ListCatalogProductsInput {
1078
1206
  /** Free-text search. */
@@ -1189,6 +1317,60 @@ export interface CatalogFileApplyResult {
1189
1317
  photosImported: number;
1190
1318
  warnings: string[];
1191
1319
  }
1320
+ /** AGF-MENU-OPTIONS M1 — one item of a menu read (never a quantity). */
1321
+ export interface CatalogMenuItem {
1322
+ category?: string;
1323
+ title: string;
1324
+ description?: string;
1325
+ /** Integer cents; null = no price («a consultar»). */
1326
+ priceCents: number | null;
1327
+ /** The price as the menu wrote it. */
1328
+ priceText?: string;
1329
+ /** Look before importing: a price not found in the pasted text, no price, a repeated name. */
1330
+ flags?: Array<'price_not_in_source' | 'no_price' | 'duplicate'>;
1331
+ /** AGF-MENU-OPTIONS M3 — options the menu lists for it; created as library groups on import. */
1332
+ optionGroups?: Array<{
1333
+ name: string;
1334
+ selection: 'single' | 'multi';
1335
+ required: boolean;
1336
+ options: Array<{
1337
+ name: string;
1338
+ priceDeltaCents: number;
1339
+ }>;
1340
+ }>;
1341
+ }
1342
+ export interface CatalogMenuReadInput {
1343
+ /** The pasted menu, or a note to go with the file. */
1344
+ text?: string;
1345
+ /** A photo (JPG/PNG/WebP), PDF, .docx, .xlsx, .csv or .txt (≤10 MB). */
1346
+ file?: CatalogFileInput;
1347
+ filename?: string;
1348
+ mimeType?: string;
1349
+ }
1350
+ export interface CatalogMenuRead {
1351
+ items: CatalogMenuItem[];
1352
+ source: 'text' | 'image' | 'pdf' | 'document' | 'sheet';
1353
+ /** A photo / PDF: prices could not be checked against a text. */
1354
+ pricesUnchecked: boolean;
1355
+ dropped: number;
1356
+ truncated: boolean;
1357
+ note?: string;
1358
+ plan: {
1359
+ willCreate: number;
1360
+ willUpdate: number;
1361
+ unchanged: number;
1362
+ skipped: number;
1363
+ categoriesToCreate: string[];
1364
+ };
1365
+ /** Per item, in order: what importing does. */
1366
+ rows: Array<{
1367
+ title: string;
1368
+ action: 'create' | 'update' | 'unchanged';
1369
+ changes?: string[];
1370
+ }>;
1371
+ warnings: string[];
1372
+ currency: string;
1373
+ }
1192
1374
  /** Binary file accepted by the file-import calls. */
1193
1375
  export type CatalogFileInput = Blob | ArrayBuffer | Uint8Array;
1194
1376
  export interface CatalogFilePreviewInput {
@@ -1847,6 +2029,14 @@ export interface CaseReceiptLine {
1847
2029
  currency: string;
1848
2030
  priceKind: 'fixed' | 'from' | 'per_unit' | 'on_request';
1849
2031
  unit?: string;
2032
+ /** AGF-UNITS U2 — sold by measure: `qty` is in `unit` (0.75 lb), not a count of items. */
2033
+ measured?: boolean;
2034
+ /** AGF-MENU-OPTIONS M2 — the options chosen; `unitCents` already includes them. */
2035
+ options?: Array<{
2036
+ group: string;
2037
+ name: string;
2038
+ deltaCents: number;
2039
+ }>;
1850
2040
  }
1851
2041
  /**
1852
2042
  * AGF-CASE-RECEIPT — a case's receipt as its public link shows it: what the
@@ -1916,10 +2106,13 @@ export interface CreateDirectOrderInput {
1916
2106
  name: string;
1917
2107
  phone: string;
1918
2108
  };
1919
- /** Products of the business's catalog and how many of each. */
2109
+ /** Products of the business's catalog and how many of each. `options`: the choice for a
2110
+ * product with option groups (AGF-MENU-OPTIONS M2; a required group left out → 400). */
1920
2111
  lines: Array<{
1921
2112
  productId: string;
2113
+ /** In the product's unit: whole for products sold by unit, a measure on the product's step (0.5 lb) otherwise. */
1922
2114
  quantity: number;
2115
+ options?: CatalogOptionChoice[];
1923
2116
  }>;
1924
2117
  /** The order type's other fields (entrega, direccion, notas…), by key. */
1925
2118
  fields?: Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge-io/sdk-server",
3
- "version": "4.34.0",
3
+ "version": "4.36.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",