@agentforge-io/sdk-server 4.16.0 → 4.17.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 +2 -2
- package/dist/index.js +2 -1
- package/dist/resources/catalog.d.ts +26 -3
- package/dist/resources/catalog.js +30 -2
- package/dist/resources/connectors.d.ts +36 -1
- package/dist/resources/connectors.js +69 -0
- package/dist/types.d.ts +95 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ export { AgentForgeClient, INSTALLED_TENANT_HEADER } from './client';
|
|
|
2
2
|
export type { AgentForgeClientOptions, RequestOptions } from './client';
|
|
3
3
|
export { AgentForgeError, AgentForgeAuthError, AgentForgeNotFoundError, AgentForgeNetworkError, } from './errors';
|
|
4
4
|
export { TOOL_CALLBACK_HEADERS, ToolCallbackSignatureError, signToolCallbackPayload, verifyToolCallbackSignature, } from './webhooks';
|
|
5
|
-
export type { 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, TemplateInstallResult, TenantConfigEntry, 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, RegisterToolsResult, ToolCallbackPayload, ToolCallRecord, ToolPermission, ToolPermissionMode, TokenUsage, TenantSecretEntry, UpdateAgentInput, InboxThreadMode, InboxMessageDirection, InboxMessageSource, InboxMessageType, InboxThreadCustomerProfileView, InboxThreadView, InboxMessageView, SupportKpiTotals, SupportKpiResponse, AgentAttentionLogRow, } from './types';
|
|
5
|
+
export type { 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, TemplateInstallResult, TenantConfigEntry, 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
6
|
export { AgentsResource } from './resources/agents';
|
|
7
7
|
export { AnalyticsResource } from './resources/analytics';
|
|
8
8
|
export type { GetSupportKpisInput, GetAgentAttentionLogInput, } from './resources/analytics';
|
|
9
9
|
export { AppsResource } from './resources/apps';
|
|
10
10
|
export { ChatResource } from './resources/chat';
|
|
11
11
|
export type { AnthropicClientOptions, AppCallerClaims, StreamMessageInput, StreamMessageForAppUserInput, } from './resources/chat';
|
|
12
|
-
export { ConnectorsResource } from './resources/connectors';
|
|
12
|
+
export { ConnectorsResource, parseGoogleSheetsPickerResult } from './resources/connectors';
|
|
13
13
|
export type { InboxChannelView } from './resources/connectors';
|
|
14
14
|
export { InboxResource } from './resources/inbox';
|
|
15
15
|
export { InstallationsResource } from './resources/installations';
|
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.TenantConfigResource = exports.TemplatesResource = exports.InstallationsResource = exports.InboxResource = exports.ConnectorsResource = exports.ChatResource = exports.AppsResource = exports.AnalyticsResource = exports.AgentsResource = exports.verifyToolCallbackSignature = exports.signToolCallbackPayload = exports.ToolCallbackSignatureError = exports.TOOL_CALLBACK_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.CatalogFileImportResource = exports.CatalogImportResource = exports.CatalogPhotosResource = exports.CatalogProductsResource = exports.CatalogCategoriesResource = exports.CatalogResource = exports.BusinessRolesResource = exports.TenantConfigResource = exports.TemplatesResource = exports.InstallationsResource = exports.InboxResource = exports.parseGoogleSheetsPickerResult = exports.ConnectorsResource = exports.ChatResource = exports.AppsResource = exports.AnalyticsResource = exports.AgentsResource = exports.verifyToolCallbackSignature = exports.signToolCallbackPayload = exports.ToolCallbackSignatureError = exports.TOOL_CALLBACK_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; } });
|
|
@@ -52,6 +52,7 @@ var chat_1 = require("./resources/chat");
|
|
|
52
52
|
Object.defineProperty(exports, "ChatResource", { enumerable: true, get: function () { return chat_1.ChatResource; } });
|
|
53
53
|
var connectors_1 = require("./resources/connectors");
|
|
54
54
|
Object.defineProperty(exports, "ConnectorsResource", { enumerable: true, get: function () { return connectors_1.ConnectorsResource; } });
|
|
55
|
+
Object.defineProperty(exports, "parseGoogleSheetsPickerResult", { enumerable: true, get: function () { return connectors_1.parseGoogleSheetsPickerResult; } });
|
|
55
56
|
var inbox_1 = require("./resources/inbox");
|
|
56
57
|
Object.defineProperty(exports, "InboxResource", { enumerable: true, get: function () { return inbox_1.InboxResource; } });
|
|
57
58
|
var installations_1 = require("./resources/installations");
|
|
@@ -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, CreateCatalogCategoryInput, CreateCatalogImportSourceInput, CreateCatalogProductInput, ListCatalogProductsInput, PreviewCatalogImportSourceInput, SignCatalogPhotoUploadInput, UpdateCatalogCategoryInput, UpdateCatalogImportSourceInput, UpdateCatalogProductInput, UpsertCatalogInput } from '../types';
|
|
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';
|
|
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. */
|
|
@@ -81,7 +81,9 @@ export declare class CatalogImportResource {
|
|
|
81
81
|
preview(items: CatalogImportItem[]): Promise<CatalogImportPreview>;
|
|
82
82
|
/** `POST /import/apply` — create-only, idempotent per slug. Max 200 per call. */
|
|
83
83
|
apply(items: CatalogImportItem[]): Promise<CatalogImportApplyResult>;
|
|
84
|
-
/** `GET /import/template.xlsx` — the downloadable template (xlsx bytes)
|
|
84
|
+
/** `GET /import/template.xlsx` — the downloadable template (xlsx bytes):
|
|
85
|
+
* columns codigo, nombre, precio, categoria, descripcion, stock, foto_url,
|
|
86
|
+
* tipo, plus example rows. */
|
|
85
87
|
template(): Promise<ArrayBuffer>;
|
|
86
88
|
}
|
|
87
89
|
export declare class CatalogSourcesResource {
|
|
@@ -95,9 +97,30 @@ export declare class CatalogSourcesResource {
|
|
|
95
97
|
update(sourceId: string, input: UpdateCatalogImportSourceInput): Promise<CatalogImportSource>;
|
|
96
98
|
/** `DELETE /import-sources/:id` */
|
|
97
99
|
delete(sourceId: string): Promise<void>;
|
|
100
|
+
/** `GET /sheets/:spreadsheetId/tabs` — the spreadsheet's tabs (title, size),
|
|
101
|
+
* so the owner can choose one and the caller can build the preview `range`.
|
|
102
|
+
* Throws with `code` `NO_GOOGLE_GRANT` (connect Google Sheets first),
|
|
103
|
+
* `NO_SHEETS_SCOPE` (reconnect), or `SHEET_READ_FAILED` (Google refused:
|
|
104
|
+
* not found / not shared / API disabled). */
|
|
105
|
+
tabs(spreadsheetId: string): Promise<CatalogSheetTab[]>;
|
|
106
|
+
/** `POST /sheets/template` — create a NEW Google Sheet in the tenant's Drive
|
|
107
|
+
* (its google-sheets grant), already laid out as the catalog template: the
|
|
108
|
+
* same columns as `import.template()` (codigo, nombre, precio, categoria,
|
|
109
|
+
* descripcion, stock, foto_url, tipo), header bold + frozen, HEADER ROW
|
|
110
|
+
* ONLY (no example rows — the sheet is a live sync source), codigo as
|
|
111
|
+
* plain text, number formats on precio/stock and a producto|servicio
|
|
112
|
+
* dropdown on tipo. `codigo` maps to `externalId`: a stable product id, so
|
|
113
|
+
* renaming a row updates the same product. Rows synced without a valid
|
|
114
|
+
* price are kept as `priceKind: 'on_request'` (with a warning). The
|
|
115
|
+
* result plugs straight into `create()`. Throws with `code`
|
|
116
|
+
* `NO_GOOGLE_GRANT`, `NO_SHEETS_SCOPE` (reconnect), `SHEET_CREATE_FAILED`
|
|
117
|
+
* (Google refused), `INVALID_LOCALE` or `INVALID_TITLE`. Each call creates
|
|
118
|
+
* a new spreadsheet. */
|
|
119
|
+
createTemplateSheet(input?: CreateCatalogTemplateSheetInput): Promise<CatalogTemplateSheet>;
|
|
98
120
|
/** `POST /import-sources/preview` — sample a Google Sheet (headers, rows,
|
|
99
121
|
* suggested mapping) before saving a source. Needs a connected Google grant
|
|
100
|
-
* (`NO_GOOGLE_GRANT` otherwise).
|
|
122
|
+
* (`NO_GOOGLE_GRANT` otherwise). Pass `range` (or at least `sheetTab`, from
|
|
123
|
+
* `tabs()`): the platform's fallback is `Sheet1!A1:Z7`, not the first tab. */
|
|
101
124
|
preview(input: PreviewCatalogImportSourceInput): Promise<CatalogImportSourcePreview>;
|
|
102
125
|
/** `POST /import-sources/:id/run` — sync now. Always resolves with `lastResult`;
|
|
103
126
|
* run-level failures are in `lastResult.error`. */
|
|
@@ -195,7 +195,9 @@ class CatalogImportResource {
|
|
|
195
195
|
guardItems(items);
|
|
196
196
|
return this.client.request('POST', `${BASE}/import/apply`, { items }, TENANT_AUTH);
|
|
197
197
|
}
|
|
198
|
-
/** `GET /import/template.xlsx` — the downloadable template (xlsx bytes)
|
|
198
|
+
/** `GET /import/template.xlsx` — the downloadable template (xlsx bytes):
|
|
199
|
+
* columns codigo, nombre, precio, categoria, descripcion, stock, foto_url,
|
|
200
|
+
* tipo, plus example rows. */
|
|
199
201
|
async template() {
|
|
200
202
|
const res = await this.client.requestRaw('GET', `${BASE}/import/template.xlsx`, TENANT_AUTH);
|
|
201
203
|
return res.arrayBuffer();
|
|
@@ -222,9 +224,35 @@ class CatalogSourcesResource {
|
|
|
222
224
|
async delete(sourceId) {
|
|
223
225
|
await this.client.request('DELETE', `${BASE}/import-sources/${seg(sourceId)}`, undefined, TENANT_AUTH);
|
|
224
226
|
}
|
|
227
|
+
/** `GET /sheets/:spreadsheetId/tabs` — the spreadsheet's tabs (title, size),
|
|
228
|
+
* so the owner can choose one and the caller can build the preview `range`.
|
|
229
|
+
* Throws with `code` `NO_GOOGLE_GRANT` (connect Google Sheets first),
|
|
230
|
+
* `NO_SHEETS_SCOPE` (reconnect), or `SHEET_READ_FAILED` (Google refused:
|
|
231
|
+
* not found / not shared / API disabled). */
|
|
232
|
+
async tabs(spreadsheetId) {
|
|
233
|
+
const res = await this.client.request('GET', `${BASE}/sheets/${seg(spreadsheetId)}/tabs`, undefined, TENANT_AUTH);
|
|
234
|
+
return res.tabs;
|
|
235
|
+
}
|
|
236
|
+
/** `POST /sheets/template` — create a NEW Google Sheet in the tenant's Drive
|
|
237
|
+
* (its google-sheets grant), already laid out as the catalog template: the
|
|
238
|
+
* same columns as `import.template()` (codigo, nombre, precio, categoria,
|
|
239
|
+
* descripcion, stock, foto_url, tipo), header bold + frozen, HEADER ROW
|
|
240
|
+
* ONLY (no example rows — the sheet is a live sync source), codigo as
|
|
241
|
+
* plain text, number formats on precio/stock and a producto|servicio
|
|
242
|
+
* dropdown on tipo. `codigo` maps to `externalId`: a stable product id, so
|
|
243
|
+
* renaming a row updates the same product. Rows synced without a valid
|
|
244
|
+
* price are kept as `priceKind: 'on_request'` (with a warning). The
|
|
245
|
+
* result plugs straight into `create()`. Throws with `code`
|
|
246
|
+
* `NO_GOOGLE_GRANT`, `NO_SHEETS_SCOPE` (reconnect), `SHEET_CREATE_FAILED`
|
|
247
|
+
* (Google refused), `INVALID_LOCALE` or `INVALID_TITLE`. Each call creates
|
|
248
|
+
* a new spreadsheet. */
|
|
249
|
+
async createTemplateSheet(input = {}) {
|
|
250
|
+
return this.client.request('POST', `${BASE}/sheets/template`, input, TENANT_AUTH);
|
|
251
|
+
}
|
|
225
252
|
/** `POST /import-sources/preview` — sample a Google Sheet (headers, rows,
|
|
226
253
|
* suggested mapping) before saving a source. Needs a connected Google grant
|
|
227
|
-
* (`NO_GOOGLE_GRANT` otherwise).
|
|
254
|
+
* (`NO_GOOGLE_GRANT` otherwise). Pass `range` (or at least `sheetTab`, from
|
|
255
|
+
* `tabs()`): the platform's fallback is `Sheet1!A1:Z7`, not the first tab. */
|
|
228
256
|
async preview(input) {
|
|
229
257
|
return this.client.request('POST', `${BASE}/import-sources/preview`, input, TENANT_AUTH);
|
|
230
258
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentForgeClient } from '../client';
|
|
2
|
-
import type { AppUserConnectorStatus, ConnectorDefaultsResult, ConnectorStatus, CreateClickupTaskInput, CreateClickupTaskResult, ListConnectorResourcesResult, ToolPermission } from '../types';
|
|
2
|
+
import type { AppUserConnectorStatus, ConnectorDefaultsResult, ConnectorStatus, CreateClickupTaskInput, CreateClickupTaskResult, GoogleSheetsPickerInput, GoogleSheetsPickerResult, GoogleSheetsPickerSession, ListConnectorResourcesResult, ToolPermission } from '../types';
|
|
3
3
|
export declare class ConnectorsResource {
|
|
4
4
|
private readonly client;
|
|
5
5
|
constructor(client: AgentForgeClient);
|
|
@@ -39,6 +39,28 @@ export declare class ConnectorsResource {
|
|
|
39
39
|
}): Promise<{
|
|
40
40
|
url: string;
|
|
41
41
|
}>;
|
|
42
|
+
/**
|
|
43
|
+
* `POST /api/v1/connectors/google-sheets/picker-session` (AGF-CATALOG-ONB
|
|
44
|
+
* C5c) — a one-time URL (5 min, consumed on first load) of a page hosted by
|
|
45
|
+
* the platform where the business owner picks a spreadsheet in Google's own
|
|
46
|
+
* Picker UI, instead of pasting a link. Open `url` in the owner's browser
|
|
47
|
+
* (e.g. `WebBrowser.openAuthSessionAsync(url, returnTo)`); the page then
|
|
48
|
+
* navigates to `returnTo` with `?spreadsheetId=…&name=…`, or
|
|
49
|
+
* `?pickerError=<code>` (`CANCELLED`, `NO_GOOGLE_GRANT`, `RECONNECT_REQUIRED`
|
|
50
|
+
* — the grant predates the `drive.file` scope: run `authorizeForTenant('google-sheets')`
|
|
51
|
+
* again — …). Read it back with `parseGoogleSheetsPickerResult()`.
|
|
52
|
+
*
|
|
53
|
+
* Tenant-wide credential (`ak_live_`, or App secret + `forTenant`). Throws
|
|
54
|
+
* `AgentForgeError` with `code` `INVALID_RETURN_TO` (origin not allowed by
|
|
55
|
+
* the platform), `INVALID_LOCALE`, or `PICKER_NOT_CONFIGURED` (503).
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* const { url } = await af.forTenant(tenantId).connectors.googleSheetsPicker({
|
|
59
|
+
* returnTo: 'https://app.example.com/catalog/sheets',
|
|
60
|
+
* locale: 'es',
|
|
61
|
+
* });
|
|
62
|
+
*/
|
|
63
|
+
googleSheetsPicker(input: GoogleSheetsPickerInput): Promise<GoogleSheetsPickerSession>;
|
|
42
64
|
/**
|
|
43
65
|
* `POST /connectors/oauth/:id/api-key-for-tenant` — guarda un API key
|
|
44
66
|
* pegado por el usuario para el tenant del ak_live_ (sin sesión de
|
|
@@ -386,3 +408,16 @@ export interface InboxChannelView {
|
|
|
386
408
|
createdAt: string;
|
|
387
409
|
updatedAt: string;
|
|
388
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Reads the Google Sheets Picker outcome from the `returnTo` URL the hosted
|
|
413
|
+
* picker navigated to (`connectors.googleSheetsPicker()`). Accepts the full
|
|
414
|
+
* URL, its search string, `URLSearchParams`, or a plain query object (e.g.
|
|
415
|
+
* Expo Router's `useLocalSearchParams()`). Returns `null` when the URL carries
|
|
416
|
+
* no picker result.
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* const r = parseGoogleSheetsPickerResult(result.url);
|
|
420
|
+
* if (r?.ok) await biz.catalog.sources.tabs(r.spreadsheetId);
|
|
421
|
+
* else if (r?.error === 'RECONNECT_REQUIRED') { … }
|
|
422
|
+
*/
|
|
423
|
+
export declare function parseGoogleSheetsPickerResult(input: string | URL | URLSearchParams | Record<string, string | string[] | undefined>): GoogleSheetsPickerResult | null;
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// llaman `this.client.request()` directo en lugar de `requestWithApiKey()`.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.ConnectorsResource = void 0;
|
|
17
|
+
exports.parseGoogleSheetsPickerResult = parseGoogleSheetsPickerResult;
|
|
17
18
|
class ConnectorsResource {
|
|
18
19
|
constructor(client) {
|
|
19
20
|
this.client = client;
|
|
@@ -57,6 +58,30 @@ class ConnectorsResource {
|
|
|
57
58
|
: '';
|
|
58
59
|
return this.client.requestWithApiKey('POST', `/connectors/oauth/${encodeURIComponent(connectorId)}/authorize-for-tenant${qs}`);
|
|
59
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* `POST /api/v1/connectors/google-sheets/picker-session` (AGF-CATALOG-ONB
|
|
63
|
+
* C5c) — a one-time URL (5 min, consumed on first load) of a page hosted by
|
|
64
|
+
* the platform where the business owner picks a spreadsheet in Google's own
|
|
65
|
+
* Picker UI, instead of pasting a link. Open `url` in the owner's browser
|
|
66
|
+
* (e.g. `WebBrowser.openAuthSessionAsync(url, returnTo)`); the page then
|
|
67
|
+
* navigates to `returnTo` with `?spreadsheetId=…&name=…`, or
|
|
68
|
+
* `?pickerError=<code>` (`CANCELLED`, `NO_GOOGLE_GRANT`, `RECONNECT_REQUIRED`
|
|
69
|
+
* — the grant predates the `drive.file` scope: run `authorizeForTenant('google-sheets')`
|
|
70
|
+
* again — …). Read it back with `parseGoogleSheetsPickerResult()`.
|
|
71
|
+
*
|
|
72
|
+
* Tenant-wide credential (`ak_live_`, or App secret + `forTenant`). Throws
|
|
73
|
+
* `AgentForgeError` with `code` `INVALID_RETURN_TO` (origin not allowed by
|
|
74
|
+
* the platform), `INVALID_LOCALE`, or `PICKER_NOT_CONFIGURED` (503).
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* const { url } = await af.forTenant(tenantId).connectors.googleSheetsPicker({
|
|
78
|
+
* returnTo: 'https://app.example.com/catalog/sheets',
|
|
79
|
+
* locale: 'es',
|
|
80
|
+
* });
|
|
81
|
+
*/
|
|
82
|
+
async googleSheetsPicker(input) {
|
|
83
|
+
return this.client.requestWithApiKey('POST', '/api/v1/connectors/google-sheets/picker-session', { returnTo: input.returnTo, ...(input.locale ? { locale: input.locale } : {}) });
|
|
84
|
+
}
|
|
60
85
|
/**
|
|
61
86
|
* `POST /connectors/oauth/:id/api-key-for-tenant` — guarda un API key
|
|
62
87
|
* pegado por el usuario para el tenant del ak_live_ (sin sesión de
|
|
@@ -448,3 +473,47 @@ class ConnectorsResource {
|
|
|
448
473
|
}
|
|
449
474
|
}
|
|
450
475
|
exports.ConnectorsResource = ConnectorsResource;
|
|
476
|
+
/**
|
|
477
|
+
* Reads the Google Sheets Picker outcome from the `returnTo` URL the hosted
|
|
478
|
+
* picker navigated to (`connectors.googleSheetsPicker()`). Accepts the full
|
|
479
|
+
* URL, its search string, `URLSearchParams`, or a plain query object (e.g.
|
|
480
|
+
* Expo Router's `useLocalSearchParams()`). Returns `null` when the URL carries
|
|
481
|
+
* no picker result.
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* const r = parseGoogleSheetsPickerResult(result.url);
|
|
485
|
+
* if (r?.ok) await biz.catalog.sources.tabs(r.spreadsheetId);
|
|
486
|
+
* else if (r?.error === 'RECONNECT_REQUIRED') { … }
|
|
487
|
+
*/
|
|
488
|
+
function parseGoogleSheetsPickerResult(input) {
|
|
489
|
+
const get = toGetter(input);
|
|
490
|
+
const error = get('pickerError');
|
|
491
|
+
if (error)
|
|
492
|
+
return { ok: false, error };
|
|
493
|
+
const spreadsheetId = get('spreadsheetId');
|
|
494
|
+
if (!spreadsheetId)
|
|
495
|
+
return null;
|
|
496
|
+
return { ok: true, spreadsheetId, name: get('name') ?? '' };
|
|
497
|
+
}
|
|
498
|
+
function toGetter(input) {
|
|
499
|
+
let params = null;
|
|
500
|
+
if (input instanceof URLSearchParams)
|
|
501
|
+
params = input;
|
|
502
|
+
else if (input instanceof URL)
|
|
503
|
+
params = input.searchParams;
|
|
504
|
+
else if (typeof input === 'string') {
|
|
505
|
+
const q = input.indexOf('?');
|
|
506
|
+
const query = q >= 0 ? input.slice(q + 1) : input;
|
|
507
|
+
params = new URLSearchParams(query.split('#')[0]);
|
|
508
|
+
}
|
|
509
|
+
if (params) {
|
|
510
|
+
const p = params;
|
|
511
|
+
return (key) => p.get(key) || undefined;
|
|
512
|
+
}
|
|
513
|
+
const obj = input;
|
|
514
|
+
return (key) => {
|
|
515
|
+
const v = obj[key];
|
|
516
|
+
const first = Array.isArray(v) ? v[0] : v;
|
|
517
|
+
return first || undefined;
|
|
518
|
+
};
|
|
519
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1155,6 +1155,11 @@ export interface CatalogImportColumnMapping {
|
|
|
1155
1155
|
externalId?: string;
|
|
1156
1156
|
description?: string;
|
|
1157
1157
|
image?: string;
|
|
1158
|
+
/** The "tipo" column: `producto`/`product` → product, `servicio`/`service`
|
|
1159
|
+
* → service (services never carry stock); blank keeps the default, any
|
|
1160
|
+
* other value → product with a warning. Optional; omit for sources
|
|
1161
|
+
* without such a column. */
|
|
1162
|
+
kind?: string;
|
|
1158
1163
|
}
|
|
1159
1164
|
export interface CatalogImportRunResult {
|
|
1160
1165
|
created: number;
|
|
@@ -1174,6 +1179,15 @@ export interface CatalogImportSource {
|
|
|
1174
1179
|
spreadsheetId?: string | null;
|
|
1175
1180
|
sheetTab?: string | null;
|
|
1176
1181
|
range?: string | null;
|
|
1182
|
+
/** The synced file's name, for display (e.g. "Catálogo de prueba
|
|
1183
|
+
* (AgentForge)"): the spreadsheet title for `google-sheets`, the shop
|
|
1184
|
+
* domain for `shopify`. `list()` backfills it from Google when missing;
|
|
1185
|
+
* null when it could not be read (no grant, sheet not shared…) — fall
|
|
1186
|
+
* back to `sheetTab` then. Absent on platforms older than C5f. */
|
|
1187
|
+
name?: string | null;
|
|
1188
|
+
/** Link that opens the source (the Sheets edit URL for `google-sheets`;
|
|
1189
|
+
* null for other connectors). Derived by the platform — don't build it. */
|
|
1190
|
+
url?: string | null;
|
|
1177
1191
|
columnMapping: CatalogImportColumnMapping;
|
|
1178
1192
|
/** Per-connector extras, e.g. `{ shop: 'acme.myshopify.com' }`. */
|
|
1179
1193
|
config: {
|
|
@@ -1196,6 +1210,10 @@ export interface CreateCatalogImportSourceInput {
|
|
|
1196
1210
|
sheetTab?: string;
|
|
1197
1211
|
/** A1 range, e.g. "Menu!A1:E999". Required for `google-sheets`. */
|
|
1198
1212
|
range?: string;
|
|
1213
|
+
/** File name to show (≤255, trimmed; blank = none) — e.g. the `name` from
|
|
1214
|
+
* `createTemplateSheet()` or the Google Picker result. Omit it and
|
|
1215
|
+
* `list()` fills it from Google. */
|
|
1216
|
+
name?: string | null;
|
|
1199
1217
|
columnMapping?: CatalogImportColumnMapping;
|
|
1200
1218
|
config?: {
|
|
1201
1219
|
shop?: string;
|
|
@@ -1210,6 +1228,10 @@ export interface UpdateCatalogImportSourceInput {
|
|
|
1210
1228
|
spreadsheetId?: string;
|
|
1211
1229
|
sheetTab?: string | null;
|
|
1212
1230
|
range?: string;
|
|
1231
|
+
/** File name (≤255, trimmed). `null`/blank clears it (the next `list()`
|
|
1232
|
+
* re-reads it from Google). Changing `spreadsheetId` without `name` also
|
|
1233
|
+
* clears the old file's name. */
|
|
1234
|
+
name?: string | null;
|
|
1213
1235
|
columnMapping?: CatalogImportColumnMapping;
|
|
1214
1236
|
config?: {
|
|
1215
1237
|
shop?: string;
|
|
@@ -1221,10 +1243,55 @@ export interface UpdateCatalogImportSourceInput {
|
|
|
1221
1243
|
}
|
|
1222
1244
|
export interface PreviewCatalogImportSourceInput {
|
|
1223
1245
|
spreadsheetId: string;
|
|
1246
|
+
/** Tab title (see `catalog.sources.tabs()`). Used to build the default
|
|
1247
|
+
* range when `range` is omitted. */
|
|
1224
1248
|
sheetTab?: string;
|
|
1225
|
-
/**
|
|
1249
|
+
/** A1 range to sample, e.g. `'Hoja 1'!A1:Z7`. Callers SHOULD pass it (or at
|
|
1250
|
+
* least `sheetTab`): when both are omitted the platform reads
|
|
1251
|
+
* `Sheet1!A1:Z7` — NOT the first tab — which fails on sheets whose first
|
|
1252
|
+
* tab has another name (Spanish Google Sheets default to `Hoja 1`). Get
|
|
1253
|
+
* the real tab titles from `catalog.sources.tabs(spreadsheetId)`. */
|
|
1226
1254
|
range?: string;
|
|
1227
1255
|
}
|
|
1256
|
+
/** Input of `catalog.sources.createTemplateSheet()`. */
|
|
1257
|
+
export interface CreateCatalogTemplateSheetInput {
|
|
1258
|
+
/** Spreadsheet title (max 200). Default `Catálogo` (es) / `Catalog` (en);
|
|
1259
|
+
* pass e.g. `Catálogo — <business name>`. */
|
|
1260
|
+
title?: string;
|
|
1261
|
+
/** `'es'` (default) or `'en'` (`'es-CO'` etc. accepted): names the tab
|
|
1262
|
+
* `Catálogo` / `Catalog`. The header row is the same in both. */
|
|
1263
|
+
locale?: string;
|
|
1264
|
+
}
|
|
1265
|
+
/** A new Google Sheet laid out as the catalog template (header row only, no
|
|
1266
|
+
* example rows). Pass `spreadsheetId`,
|
|
1267
|
+
* `sheetTab`, `range` and `columnMapping` straight to `catalog.sources.create`
|
|
1268
|
+
* (`connectorId: 'google-sheets'`) — no mapping step needed. */
|
|
1269
|
+
export interface CatalogTemplateSheet {
|
|
1270
|
+
spreadsheetId: string;
|
|
1271
|
+
/** Link to open the sheet in Google Sheets. */
|
|
1272
|
+
url: string;
|
|
1273
|
+
/** Spreadsheet title. */
|
|
1274
|
+
name: string;
|
|
1275
|
+
/** Tab holding the catalog (`Catálogo` / `Catalog`). */
|
|
1276
|
+
sheetTab: string;
|
|
1277
|
+
/** `'<tab>'!A1:<lastColumn>`, e.g. `'Catálogo'!A1:H`. */
|
|
1278
|
+
range: string;
|
|
1279
|
+
/** Exact header → field mapping of the template, e.g. `{ externalId:
|
|
1280
|
+
* 'codigo', title: 'nombre', priceCents: 'precio', kind: 'tipo', … }`. */
|
|
1281
|
+
columnMapping: CatalogImportColumnMapping;
|
|
1282
|
+
/** Present when the sheet was created but its formatting (number formats,
|
|
1283
|
+
* "tipo" dropdown) could not be applied; the sheet is still usable. */
|
|
1284
|
+
warnings?: string[];
|
|
1285
|
+
}
|
|
1286
|
+
/** One tab of a Google Sheet (`catalog.sources.tabs()`). */
|
|
1287
|
+
export interface CatalogSheetTab {
|
|
1288
|
+
sheetId: number;
|
|
1289
|
+
title: string;
|
|
1290
|
+
/** 0-based position of the tab in the spreadsheet. */
|
|
1291
|
+
index: number;
|
|
1292
|
+
rows: number;
|
|
1293
|
+
columns: number;
|
|
1294
|
+
}
|
|
1228
1295
|
export interface CatalogImportSourcePreview {
|
|
1229
1296
|
headers: string[];
|
|
1230
1297
|
sampleRows: string[][];
|
|
@@ -1232,4 +1299,31 @@ export interface CatalogImportSourcePreview {
|
|
|
1232
1299
|
confidence?: 'high' | 'medium' | 'low';
|
|
1233
1300
|
notes?: string;
|
|
1234
1301
|
}
|
|
1302
|
+
export interface GoogleSheetsPickerInput {
|
|
1303
|
+
/** Where the hosted picker sends the owner back. Must be an origin the
|
|
1304
|
+
* platform allows (`CONNECTOR_RETURN_ALLOWED_ORIGINS`, the platform's own
|
|
1305
|
+
* domains, or — outside production — loopback), or a listed custom scheme
|
|
1306
|
+
* (`myapp://…`). Otherwise the call fails with `code: 'INVALID_RETURN_TO'`. */
|
|
1307
|
+
returnTo: string;
|
|
1308
|
+
/** Picker UI language, e.g. `'es'` or `'es-419'`. Defaults to the browser's. */
|
|
1309
|
+
locale?: string;
|
|
1310
|
+
}
|
|
1311
|
+
export interface GoogleSheetsPickerSession {
|
|
1312
|
+
/** One-time URL (valid 5 minutes, consumed on first load) to open in the
|
|
1313
|
+
* owner's browser. */
|
|
1314
|
+
url: string;
|
|
1315
|
+
/** ISO timestamp after which `url` no longer works. */
|
|
1316
|
+
expiresAt: string;
|
|
1317
|
+
}
|
|
1318
|
+
/** `pickerError` values the picker appends to `returnTo`. */
|
|
1319
|
+
export type GoogleSheetsPickerErrorCode = 'CANCELLED' | 'NOTHING_PICKED' | 'PICKER_ERROR' | 'PICKER_LOAD_FAILED' | 'PICKER_NOT_CONFIGURED' | 'NO_GOOGLE_GRANT' | 'RECONNECT_REQUIRED';
|
|
1320
|
+
/** Result read back from the `returnTo` URL (`parseGoogleSheetsPickerResult`). */
|
|
1321
|
+
export type GoogleSheetsPickerResult = {
|
|
1322
|
+
ok: true;
|
|
1323
|
+
spreadsheetId: string;
|
|
1324
|
+
name: string;
|
|
1325
|
+
} | {
|
|
1326
|
+
ok: false;
|
|
1327
|
+
error: GoogleSheetsPickerErrorCode | (string & {});
|
|
1328
|
+
};
|
|
1235
1329
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentforge-io/sdk-server",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.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",
|