@mitralab.io/sdk-core 0.2.14 → 0.2.15
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/CHANGELOG.md +20 -0
- package/README.md +3 -2
- package/contracts/README.md +5 -0
- package/contracts/manifest.json +6 -1
- package/contracts/v0.2.15/sdk-parity.json +2902 -0
- package/dist/index.cjs +129 -2
- package/dist/index.d.cts +79 -3
- package/dist/index.d.ts +79 -3
- package/dist/index.js +129 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.2.15
|
|
6
|
+
|
|
7
|
+
- `messenger` manages the current app's account email templates on Messenger's
|
|
8
|
+
`/api/v1/email/templates` and `/api/v1/email/template-types` routes: `listEmailTemplates()`,
|
|
9
|
+
`getEmailTemplateType(type)`, `getEmailTemplate(type)`, `upsertEmailTemplate(type, input)`,
|
|
10
|
+
`previewEmailTemplate(type)` and `deleteEmailTemplate(type)`. `EmailTemplateType` is the four
|
|
11
|
+
types an app token may edit: `SIGN_IN`, `SSO_GUIDANCE`, `APP_USER_INVITED` and
|
|
12
|
+
`APP_ACCESS_REQUIRED`.
|
|
13
|
+
- The `appId` comes from `getAppId`, now passed to the messenger module too, never from the
|
|
14
|
+
caller; without it the app calls fail with `SdkCoreConfigurationError` before any request. The
|
|
15
|
+
`PUT` body is built field by field, so an untyped `appId` or `senderIdentityId` is dropped, and
|
|
16
|
+
`textBody` is left out when absent, which clears the saved one.
|
|
17
|
+
- `upsertEmailTemplate` saves and then renders the preview. A preview failure after a successful
|
|
18
|
+
save resolves with `preview: null` and the error in `previewError` instead of rejecting.
|
|
19
|
+
- Messenger refusals (`400` `TEMPLATE_MISSING_VARIABLE` or `VALIDATION_FAILED` for a blank
|
|
20
|
+
subject or HTML body, `403` `ACCESS_DENIED` for another app, no edit access or a type outside the
|
|
21
|
+
four, `404` on a delete without an app row) come from the transport unchanged.
|
|
22
|
+
- In responses `type` is a string, not `EmailTemplateType`: a console token also lists the
|
|
23
|
+
platform's other types, and a type Messenger opens later must not break the list.
|
|
24
|
+
|
|
5
25
|
## 0.2.14
|
|
6
26
|
|
|
7
27
|
- `messenger.sendEmail({ to, subject, html, text?, cc?, bcc?, replyTo? })` sends an email through
|
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ const { data: tasks, hasMore } = await core.entities.getTable("Task").list({ lim
|
|
|
67
67
|
- `integration`, `integrationAdmin`, `integrationResources` e `integrationTemplates`: chamadas a APIs externas e a configuração delas.
|
|
68
68
|
- `agentTasks`, com `createAgentTaskSessionManager` e `withAgentTaskSessions`: chats de agente com `send`, `sendAndWait`, `cancel` e eventos. O gerenciador recebe `tasks`, o `eventSource` do seu SDK e `directChannel`, com o `apiUrl` do gateway e, se quiser, `WebSocket` e `fetch`.
|
|
69
69
|
- `apps`, `context`, `agents`, `agentConnections`, `agentCredentials`, `members`, `imports`, `dataSources` e `auth`: o app em si, a configuração de agentes e os demais recursos.
|
|
70
|
-
- `messenger`: `notify` avisa o usuário autenticado
|
|
70
|
+
- `messenger`: `notify` avisa o usuário autenticado, `sendEmail` manda e-mail com o remetente do app, e `listEmailTemplates`, `getEmailTemplateType`, `getEmailTemplate`, `upsertEmailTemplate`, `previewEmailTemplate` e `deleteEmailTemplate` cuidam dos templates de e-mail de conta do app.
|
|
71
71
|
- `resolveApiKeyToken`, `readTokenAppId` e `tokenAuthorizesApp`: contrato da troca de API key por token, para o SDK que autentica por chave.
|
|
72
72
|
|
|
73
73
|
## Configuração
|
|
@@ -77,7 +77,7 @@ const { data: tasks, hasMore } = await core.entities.getTable("Task").list({ lim
|
|
|
77
77
|
| `transports.auth`, `dataManager`, `functions`, `integration` | sim | um `Transport` para cada serviço |
|
|
78
78
|
| `transports.codeStudio`, `copilot`, `messenger` | não | sem eles falham com `SdkCoreConfigurationError`, antes de sair a requisição: `apps` (`codeStudio`); `agentTasks`, `agentConnections`, `agentCredentials` e `agents.listModels` (`copilot`); `messenger`. O resto de `agents` usa `functions` |
|
|
79
79
|
| `transports.publicFunctions` | não | transporte anônimo de `publicFunctions`, sem `Authorization` nem `X-App-Id` |
|
|
80
|
-
| `getAppId` | não | devolve o app fixado pelo seu SDK; usado por `context`
|
|
80
|
+
| `getAppId` | não | devolve o app fixado pelo seu SDK; usado por `context` e pelos templates de e-mail do `messenger` |
|
|
81
81
|
| `functions.executeInvocationType` | não | `sync` ou `async` em `functions.execute`; sem valor, vale o padrão do servidor |
|
|
82
82
|
| `functions.emptyInput` | não | `empty-object` manda `{ "input": {} }` quando não há input; `omit-body` não manda corpo |
|
|
83
83
|
| `errors` | não | `SdkCoreErrorFactory` para o seu SDK lançar as próprias classes no lugar de `SdkCoreConfigurationError` e `SdkCoreResponseError` |
|
|
@@ -97,6 +97,7 @@ const { data: tasks, hasMore } = await core.entities.getTable("Task").list({ lim
|
|
|
97
97
|
- O Core não repete requisição nem renova token. Se o seu transporte repetir, repita só o que não grava.
|
|
98
98
|
- `publicFunctions` precisa de um transporte sem credencial. O Core não usa o transporte autenticado no lugar dele.
|
|
99
99
|
- `sendEmail({ to, subject, html, text?, cc?, bcc?, replyTo? })` não tem `from`: o Messenger usa o remetente do app do token. Por isso só o backend do app manda e-mail, com o token trocado pela API key ou o token da Server Function; token de usuário final do app recebe `403`. `to`, `cc` e `bcc` são listas com um endereço por item. Os limites ficam no Messenger e chegam como erro do seu `Transport`: `400` acima do limite de destinatários dele somando os três campos e `429` acima da cota diária do app, com o header `Retry-After` e `retry_after_seconds` no corpo.
|
|
100
|
+
- Templates de e-mail: os métodos do `messenger` cobrem os quatro tipos de conta que o app reescreve com o próprio token (`EmailTemplateType`: `SIGN_IN`, `SSO_GUIDANCE`, `APP_USER_INVITED` e `APP_ACCESS_REQUIRED`). O `appId` vem do `getAppId`, sem argumento de quem chama; sem ele, os métodos do app falham com `SdkCoreConfigurationError` antes da requisição. O Messenger aceita o token de app quando ele é do mesmo app e tem edição no app (`FUNCTION_WRITE`). `listEmailTemplates()` traz a linha do app e a da plataforma (`platformDefault: true`), então um tipo pode vir duas vezes; `getEmailTemplate(type)` devolve a do app ou, sem ela, a da plataforma. `getEmailTemplateType(type)` lista as variáveis, usadas como `$nome`; toda variável obrigatória precisa estar no assunto ou no HTML. `upsertEmailTemplate(type, { subject, htmlBody, textBody? })` substitui o template inteiro (sem `textBody`, o texto salvo antes some) e devolve `{ template, preview }`; se só o preview falhar, a promise resolve com `preview: null` e o erro em `previewError`, porque o template já está salvo. O preview mostra o template salvo (ou o da plataforma) com os valores de exemplo do catálogo; ele não prova qual HTML sai no envio, porque isso depende do remetente do app e da política de marca. `deleteEmailTemplate(type)` volta ao texto da plataforma. As recusas chegam como erro do seu `Transport`, com o `error_code` do Messenger: `400` `TEMPLATE_MISSING_VARIABLE` (variável obrigatória faltando) ou `VALIDATION_FAILED` (assunto ou HTML em branco), `403` `ACCESS_DENIED` (outro app, sem edição no app ou tipo fora dos quatro) e, no delete sem versão do app, `404`. Na resposta, `type` vem como string: com token de console a lista traz também os outros tipos da plataforma.
|
|
100
101
|
- `sendAndWait` com `timeoutMs` ou `signal` só para de esperar; o turno continua no servidor. Para interromper, chame `cancel()`.
|
|
101
102
|
- `cancel()` chamado antes de a box aceitar o prompt espera esse aceite e só então manda o stop; a promise resolve depois disso. Se o prompt não chegar a virar turno, nada é enviado e o status não passa por `cancelled`.
|
|
102
103
|
- O `open()` do seu `eventSource` só deve resolver depois que o stream estiver conectado, para nenhum evento do turno se perder.
|
package/contracts/README.md
CHANGED
|
@@ -24,6 +24,11 @@ publishes.
|
|
|
24
24
|
|
|
25
25
|
## Versions
|
|
26
26
|
|
|
27
|
+
- `0.2.15` is the `0.2.14` parity surface republished with the app email template methods of
|
|
28
|
+
`messenger` (`listEmailTemplates`, `getEmailTemplate`, `getEmailTemplateType`, `upsertEmailTemplate`,
|
|
29
|
+
`previewEmailTemplate` and `deleteEmailTemplate`), which the parity cases do not cover. Same parity
|
|
30
|
+
cases; the version exists so a consumer pinning the package can pin a corpus with the same number.
|
|
31
|
+
|
|
27
32
|
- `0.2.14` is the `0.2.13` parity surface republished with `messenger.sendEmail()` and the
|
|
28
33
|
`emailLoginEnabled` and `passwordLoginEnabled` fields of `apps.update()`, which the parity cases do
|
|
29
34
|
not cover. Same parity cases; the version exists so a consumer pinning the package can pin a corpus
|
package/contracts/manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"contract": "SDK-PARITY-001",
|
|
3
|
-
"current": "0.2.
|
|
3
|
+
"current": "0.2.15",
|
|
4
4
|
"versions": [
|
|
5
5
|
{
|
|
6
6
|
"version": "0.1.0",
|
|
@@ -125,6 +125,11 @@
|
|
|
125
125
|
"version": "0.2.14",
|
|
126
126
|
"path": "v0.2.14/sdk-parity.json",
|
|
127
127
|
"sha256": "112e7eb52bd4362737ef03efff2cad4f529e41d5ac8ccda442e57c09b2e3c459"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"version": "0.2.15",
|
|
131
|
+
"path": "v0.2.15/sdk-parity.json",
|
|
132
|
+
"sha256": "3105726d7e2363f6ad2bc8abe5d0f1ac3407c5bab8a3c0ab44d72d517309b016"
|
|
128
133
|
}
|
|
129
134
|
]
|
|
130
135
|
}
|