@ganju/utils 0.0.20 → 0.0.22
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/constants.d.ts +16 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +43 -0
- package/dist/data.d.ts +7 -5
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +27 -3
- package/dist/dataApi.d.ts +82 -6
- package/dist/dataApi.d.ts.map +1 -1
- package/dist/dataApi.js +47 -4
- package/dist/dataAttachment.d.ts +8 -0
- package/dist/dataAttachment.d.ts.map +1 -0
- package/dist/dataAttachment.js +19 -0
- package/dist/dataCompiler.d.ts +4 -0
- package/dist/dataCompiler.d.ts.map +1 -1
- package/dist/dataCompiler.js +27 -2
- package/dist/dataDdl.d.ts.map +1 -1
- package/dist/dataDdl.js +5 -0
- package/dist/dataEngine.d.ts +25 -3
- package/dist/dataEngine.d.ts.map +1 -1
- package/dist/dataEngine.js +508 -14
- package/dist/dataImport.d.ts +3 -0
- package/dist/dataImport.d.ts.map +1 -1
- package/dist/dataImport.js +12 -2
- package/dist/dataIndexAdvice.d.ts +36 -0
- package/dist/dataIndexAdvice.d.ts.map +1 -0
- package/dist/dataIndexAdvice.js +89 -0
- package/dist/dataRpc.d.ts +20 -1
- package/dist/dataRpc.d.ts.map +1 -1
- package/dist/dataSheet.d.ts +34 -0
- package/dist/dataSheet.d.ts.map +1 -0
- package/dist/dataSheet.js +100 -0
- package/dist/dataTools.js +3 -3
- package/dist/dataTriggers.d.ts +66 -4
- package/dist/dataTriggers.d.ts.map +1 -1
- package/dist/dataTriggers.js +446 -20
- package/dist/dataTypes.d.ts +69 -0
- package/dist/dataTypes.d.ts.map +1 -1
- package/dist/dataTypes.js +21 -1
- package/dist/index.d.ts +91 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/localizeDataError.d.ts.map +1 -1
- package/dist/localizeDataError.js +109 -3
- package/dist/schema.d.ts +67 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +57 -2
- package/dist/untrustedContent.d.ts +7 -0
- package/dist/untrustedContent.d.ts.map +1 -1
- package/dist/untrustedContent.js +13 -1
- package/dist/whatsappWebhook.d.ts +28 -0
- package/dist/whatsappWebhook.d.ts.map +1 -0
- package/dist/whatsappWebhook.js +30 -0
- package/package.json +1 -1
- package/src/constants.ts +46 -0
- package/src/data.ts +33 -3
- package/src/dataApi.ts +54 -4
- package/src/dataAttachment.ts +23 -0
- package/src/dataCompiler.ts +41 -1
- package/src/dataDdl.ts +7 -0
- package/src/dataEngine.ts +680 -15
- package/src/dataImport.ts +16 -1
- package/src/dataIndexAdvice.ts +127 -0
- package/src/dataRpc.ts +27 -2
- package/src/dataSheet.ts +147 -0
- package/src/dataTools.ts +3 -3
- package/src/dataTriggers.ts +599 -20
- package/src/dataTypes.ts +108 -0
- package/src/index.ts +15 -0
- package/src/localizeDataError.ts +183 -4
- package/src/schema.ts +60 -2
- package/src/untrustedContent.ts +15 -0
- package/src/whatsappWebhook.ts +55 -0
|
@@ -25,6 +25,18 @@ const guardSuffix = (suffix) => {
|
|
|
25
25
|
return ` Valores actuales: ${current[1]}.`;
|
|
26
26
|
return suffix;
|
|
27
27
|
};
|
|
28
|
+
// Meta's other template statuses, as the refusal writes them.
|
|
29
|
+
const TEMPLATE_STATUS_ES = {
|
|
30
|
+
paused: 'pausada',
|
|
31
|
+
disabled: 'desactivada',
|
|
32
|
+
flagged: 'marcada',
|
|
33
|
+
'in appeal': 'en apelación',
|
|
34
|
+
'pending deletion': 'pendiente de eliminación',
|
|
35
|
+
deleted: 'eliminada',
|
|
36
|
+
'limit exceeded': 'por encima del límite'
|
|
37
|
+
};
|
|
38
|
+
// "The WhatsApp template x (es)", as a channel's refusal names it.
|
|
39
|
+
const templateLabel = (label) => label.replace(/^The WhatsApp template /, 'La plantilla de WhatsApp ');
|
|
28
40
|
exports.DATA_ERROR_MESSAGES_ES = {
|
|
29
41
|
'Unknown column "{0}" in {1}. Columns: {2}.': 'Columna desconocida "{0}" en {1}. Columnas: {2}.',
|
|
30
42
|
'Unknown table "{0}". Tables: {1}.': 'Tabla desconocida "{0}". Tablas: {1}.',
|
|
@@ -79,7 +91,14 @@ exports.DATA_ERROR_MESSAGES_ES = {
|
|
|
79
91
|
'{0}: only integer and decimal columns take "min".': '{0}: solo las columnas integer y decimal llevan "min".',
|
|
80
92
|
'{0}: "min" is a number.': '{0}: "min" es un número.',
|
|
81
93
|
"{0}: a {1} column can't be unique.": '{0}: una columna {1} no puede ser única.',
|
|
82
|
-
'{0}: only text columns can be searchable (text, long_text, email, url, phone, enum).': '{0}: solo las columnas de texto pueden ser buscables (text, long_text, email, url, phone, enum).',
|
|
94
|
+
'{0}: only text and file columns can be searchable (text, long_text, email, url, phone, enum, file).': '{0}: solo las columnas de texto y de archivo pueden ser buscables (text, long_text, email, url, phone, enum, file).',
|
|
95
|
+
"{0} takes a knowledge item's uri, e.g. resource://menu-photo.": '{0} lleva el uri de un elemento del conocimiento, p. ej. resource://menu-photo.',
|
|
96
|
+
'{0}: a uri is at most {1} characters.': '{0}: un uri tiene como máximo {1} caracteres.',
|
|
97
|
+
'"uris" lists 1 to {0} knowledge item uris.': '"uris" lista de 1 a {0} uris de elementos del conocimiento.',
|
|
98
|
+
'No resource in this project has the uri {0}; link an existing resource by its uri.': 'Ningún recurso de este proyecto tiene el uri {0}; enlaza un recurso que exista por su uri.',
|
|
99
|
+
'File links are for the owner.': 'Los enlaces a archivos son para el dueño.',
|
|
100
|
+
'"changes" lists 1 to {0} { from, to } pairs.': '"changes" lista de 1 a {0} pares { from, to }.',
|
|
101
|
+
'Each change is { from, to }; to is null to clear.': 'Cada cambio es { from, to }; to es null para quitar el enlace.',
|
|
83
102
|
'{0}: a column named "rank" can\'t be searchable; rename it (e.g. "ranking").': '{0}: una columna llamada "rank" no puede ser buscable; cámbiale el nombre (p. ej. "ranking").',
|
|
84
103
|
"{0}: a {1} column can't be filterable; mark it searchable instead.": '{0}: una columna {1} no puede ser filtrable; márcala como buscable.',
|
|
85
104
|
"{0}: a {1} column can't have a default.": '{0}: una columna {1} no puede tener valor por defecto.',
|
|
@@ -232,7 +251,16 @@ exports.DATA_ERROR_MESSAGES_ES = {
|
|
|
232
251
|
'A trigger is an object.': 'Un disparador es un objeto.',
|
|
233
252
|
'There is no table named {0}.': 'No hay ninguna tabla llamada {0}.',
|
|
234
253
|
'A trigger needs "table".': 'Un disparador necesita "table".',
|
|
235
|
-
'"on" is insert, update or
|
|
254
|
+
'"on" is insert, update, delete or time.': '"on" es insert, update, delete o time.',
|
|
255
|
+
// Time triggers.
|
|
256
|
+
'"after" is for "on": "time" only.': '"after" es solo para "on": "time".',
|
|
257
|
+
'A time trigger needs "after": { "column", "minutes" }, such as { "column": "created_at", "minutes": 30 }.': 'Un disparador por tiempo necesita "after": { "column", "minutes" }, por ejemplo { "column": "created_at", "minutes": 30 }.',
|
|
258
|
+
'"after.column" is created_at, updated_at or a date or datetime column of {0}.': '"after.column" es created_at, updated_at o una columna de fecha o de fecha y hora de {0}.',
|
|
259
|
+
'"after.minutes" is a whole number of minutes from {0} to {1} (30 days), negative for before the column\'s time.': '"after.minutes" es un número entero de minutos de {0} a {1} (30 días), negativo para antes de la hora de la columna.',
|
|
260
|
+
'"after.minutes" can\'t be negative on {0}: that time has already passed when the row is written. Use a date or datetime column for a reminder before.': '"after.minutes" no puede ser negativo en {0}: esa hora ya pasó cuando se escribe la fila. Usa una columna de fecha o de fecha y hora para un recordatorio antes.',
|
|
261
|
+
'"when".{0}.{1}: a time trigger reads the row as it is when it comes due, so its tests are "equals" only.': '"when".{0}.{1}: un disparador por tiempo lee la fila tal como está cuando se cumple el plazo, así que sus pruebas son solo "equals".',
|
|
262
|
+
'A database holds up to {0} time triggers.': 'Una base de datos tiene hasta {0} disparadores por tiempo.',
|
|
263
|
+
'{0}.{1} stays a date or datetime while time triggers count from it ({2}); change or delete them first.': '{0}.{1} debe seguir siendo de fecha o de fecha y hora mientras haya disparadores por tiempo que cuenten desde ella ({2}); cámbialos o elimínalos primero.',
|
|
236
264
|
"A trigger's name is lowercase letters, digits, _ and -, starting with a letter.": 'El nombre de un disparador usa minúsculas, dígitos, _ y -, empezando por una letra.',
|
|
237
265
|
'"rateLimit" is 1 to {0} runs a minute.': '"rateLimit" va de 1 a {0} ejecuciones por minuto.',
|
|
238
266
|
'"enabled" is true or false.': '"enabled" es true o false.',
|
|
@@ -274,6 +302,8 @@ exports.DATA_ERROR_MESSAGES_ES = {
|
|
|
274
302
|
'That bookmark is not one to restore to: use the one a checkpoint, a dropped table or column, a type change, or a restore answered with.': 'Ese marcador no sirve para restaurar: usa el que te devolvió un punto de control, una tabla o columna eliminada, un cambio de tipo o una restauración.',
|
|
275
303
|
'Type the table\'s name, "{0}", to drop it.': 'Escribe el nombre de la tabla, "{0}", para eliminarla.',
|
|
276
304
|
'There is no such run.': 'No existe esa ejecución.',
|
|
305
|
+
'There is no such index suggestion.': 'No existe esa sugerencia de índice.',
|
|
306
|
+
'An unused index is only flagged; remove it from the column if you want to, or dismiss the suggestion.': 'Un índice sin uso solo se señala; quítalo de la columna si quieres, o descarta la sugerencia.',
|
|
277
307
|
'Only a failed or skipped run can be tried again.': 'Solo se puede reintentar una ejecución fallida u omitida.',
|
|
278
308
|
'This run kept no event to send again.': 'Esta ejecución no guardó ningún evento para enviar de nuevo.',
|
|
279
309
|
'This export failed: {0}.': a => `Esta exportación falló: ${a[0] === 'unknown error' ? 'error desconocido' : a[0]}.`,
|
|
@@ -300,7 +330,83 @@ exports.DATA_ERROR_MESSAGES_ES = {
|
|
|
300
330
|
'"{0}" looks like one of the database\'s own index names; pick another table name.': '"{0}" parece el nombre de uno de los índices de la base de datos; elige otro nombre de tabla.',
|
|
301
331
|
'"{0}" is reserved by SQLite; pick another table name (e.g. "{1}_ref").': '"{0}" está reservado por SQLite; elige otro nombre de tabla (p. ej. "{1}_ref").',
|
|
302
332
|
'"{0}" is reserved by SQLite; pick another column name (e.g. "{1}_ref").': '"{0}" está reservado por SQLite; elige otro nombre de columna (p. ej. "{1}_ref").',
|
|
303
|
-
'"{0}" is a column every table already has.': '"{0}" es una columna que ya tienen todas las tablas.'
|
|
333
|
+
'"{0}" is a column every table already has.': '"{0}" es una columna que ya tienen todas las tablas.',
|
|
334
|
+
// A test send of a trigger's customer message.
|
|
335
|
+
"You haven't linked a chat with this project's bots: write to the bot from your own phone and send /link.": 'No has vinculado un chat con los bots de este proyecto: escríbele al bot desde tu propio teléfono y envía /link.',
|
|
336
|
+
"{0} isn't one of your linked chats with this project's bots.": '{0} no es uno de tus chats vinculados con los bots de este proyecto.',
|
|
337
|
+
'Several of your chats are linked to this project\'s bots; pick one with "participantId".': 'Varios de tus chats están vinculados con los bots de este proyecto; elige uno con "participantId".',
|
|
338
|
+
"This organization's plan no longer includes Data, so its triggers are paused and can't be tested. Upgrade to Pro to send a test.": 'El plan de esta organización ya no incluye Datos, así que sus disparadores están en pausa y no se pueden probar. Pasa a Pro para enviar una prueba.',
|
|
339
|
+
'{0} has no rows yet; add one to build the test from.': '{0} aún no tiene filas; agrega una para armar la prueba.',
|
|
340
|
+
'Reading a row as its trigger event is for the project owner.': 'Leer una fila como su evento de disparador es solo para el dueño del proyecto.',
|
|
341
|
+
// The channel's refusals, which a test send answers with.
|
|
342
|
+
"This channel's credentials can't be read; connect it again.": 'No se pueden leer las credenciales de este canal; conéctalo de nuevo.',
|
|
343
|
+
'A message needs "text".': 'Un mensaje necesita "text".',
|
|
344
|
+
'A message is at most {0} characters.': 'Un mensaje tiene como máximo {0} caracteres.',
|
|
345
|
+
'{0} refused the message: {1}': '{0} rechazó el mensaje: {1}',
|
|
346
|
+
'{0} refused the message.': '{0} rechazó el mensaje.',
|
|
347
|
+
"Ganju can't send messages on {0} channels.": 'Ganju no puede enviar mensajes en canales de {0}.',
|
|
348
|
+
'WhatsApp: {0}': 'WhatsApp: {0}',
|
|
349
|
+
'The {0} channel is paused.': 'El canal de {0} está en pausa.',
|
|
350
|
+
"{0} isn't on this channel's WhatsApp Business account. Create it in the channel's Message templates, or check its name and language.": a => `${templateLabel(a[0])} no está en la cuenta de WhatsApp Business de este canal. Créala en Plantillas de mensajes del canal, o revisa su nombre e idioma.`,
|
|
351
|
+
'{0} {1}; only approved templates can be sent.': a => {
|
|
352
|
+
const whole = `${a[0]} ${a[1]}`;
|
|
353
|
+
const m = /^(The WhatsApp template [\s\S]+? \([^)]*\)) (is still in Meta's review|was rejected by Meta|is ([\s\S]+?) by Meta)( \([\s\S]*\))?$/.exec(whole);
|
|
354
|
+
if (!m)
|
|
355
|
+
return `${whole}; solo se pueden enviar plantillas aprobadas.`;
|
|
356
|
+
const why = m[2].startsWith('is still')
|
|
357
|
+
? 'sigue en revisión de Meta'
|
|
358
|
+
: m[2].startsWith('was rejected')
|
|
359
|
+
? 'fue rechazada por Meta'
|
|
360
|
+
: `está ${TEMPLATE_STATUS_ES[m[3]] ?? `en el estado ${m[3]}`} por Meta`;
|
|
361
|
+
return `${templateLabel(m[1])} ${why}${m[4] ?? ''}; solo se pueden enviar plantillas aprobadas.`;
|
|
362
|
+
},
|
|
363
|
+
"{0} has a media header, a header variable or a button that takes a value; Ganju only fills the message's variables. Make a version without them.": a => `${templateLabel(a[0])} tiene un encabezado con archivo, una variable en el encabezado o un botón que recibe un valor; Ganju solo llena las variables del mensaje. Haz una versión sin ellos.`,
|
|
364
|
+
"There is no customer {0} on this project's channels.": 'No hay ningún cliente {0} en los canales de este proyecto.',
|
|
365
|
+
'A message needs "text", a "template", or both.': 'Un mensaje necesita "text", una "template", o ambos.',
|
|
366
|
+
'This customer has never written to the bot privately, so there is no chat to message them in.': 'Este cliente nunca le ha escrito al bot en privado, así que no hay un chat donde escribirle.',
|
|
367
|
+
"This customer already got the channel's {0} messages for the last 24 hours.": 'Este cliente ya recibió los {0} mensajes del canal de las últimas 24 horas.',
|
|
368
|
+
"Outside WhatsApp's 24-hour window (this customer last wrote more than 24 hours ago); use an approved template.": 'Fuera de la ventana de 24 horas de WhatsApp (este cliente escribió por última vez hace más de 24 horas); usa una plantilla aprobada.',
|
|
369
|
+
'Templates are for WhatsApp; {0} takes "text".': 'Las plantillas son para WhatsApp; {0} recibe "text".',
|
|
370
|
+
'The WhatsApp template {0} has {1} variable; {2} value was given.': 'La plantilla de WhatsApp {0} tiene {1} variable; se dio {2} valor.',
|
|
371
|
+
'The WhatsApp template {0} has {1} variable; {2} values were given.': 'La plantilla de WhatsApp {0} tiene {1} variable; se dieron {2} valores.',
|
|
372
|
+
'The WhatsApp template {0} has {1} variables; {2} value was given.': 'La plantilla de WhatsApp {0} tiene {1} variables; se dio {2} valor.',
|
|
373
|
+
'The WhatsApp template {0} has {1} variables; {2} values were given.': 'La plantilla de WhatsApp {0} tiene {1} variables; se dieron {2} valores.',
|
|
374
|
+
// Tables synced from a sheet
|
|
375
|
+
'{0} is synced from "{1}"; change the sheet, or stop syncing it.': '{0} se sincroniza desde "{1}"; cambia la hoja, o deja de sincronizarla.',
|
|
376
|
+
'"source" is { "uri", "sheet"?, "key" }, or null to stop syncing.': '"source" es { "uri", "sheet"?, "key" }, o null para dejar de sincronizar.',
|
|
377
|
+
'"source" takes uri, sheet and key, not "{0}".': '"source" recibe uri, sheet y key, no "{0}".',
|
|
378
|
+
'"source.uri" is the uri of a spreadsheet or CSV in the project\'s knowledge.': '"source.uri" es el uri de una hoja de cálculo o un CSV en el conocimiento del proyecto.',
|
|
379
|
+
'"source.sheet" is the name of a sheet in the file, up to 100 characters.': '"source.sheet" es el nombre de una hoja del archivo, de hasta 100 caracteres.',
|
|
380
|
+
'"source.key" is the column that names a row in both the sheet and {0}. Columns: {1}.': '"source.key" es la columna que identifica una fila tanto en la hoja como en {0}. Columnas: {1}.',
|
|
381
|
+
'{0}.{1} must be unique to be the sync key.': '{0}.{1} debe ser única para ser la clave de la sincronización.',
|
|
382
|
+
'{0}.{1} is the key the sheet sync matches rows by, so it stays unique.': '{0}.{1} es la clave con la que la sincronización empareja las filas, así que sigue siendo única.',
|
|
383
|
+
"{0}.{1} is the sheet sync's key: rename it on its own, then make the other changes.": '{0}.{1} es la clave de la sincronización: cámbiale el nombre por separado, y luego haz los demás cambios.',
|
|
384
|
+
'{0}.{1} is the key the sheet sync matches rows by; stop syncing the table, or pick another key, first.': '{0}.{1} es la clave con la que la sincronización empareja las filas; primero deja de sincronizar la tabla, o elige otra clave.',
|
|
385
|
+
"{0} isn't synced from a sheet.": '{0} no se sincroniza desde una hoja.',
|
|
386
|
+
'A sync takes "columns" and "rows".': 'Una sincronización recibe "columns" y "rows".',
|
|
387
|
+
"The sheet has no column for {0}'s key, {1}.": 'La hoja no tiene una columna para la clave de {0}, {1}.',
|
|
388
|
+
'The sheet has no column for {0}, which is required.': 'La hoja no tiene una columna para {0}, que es obligatoria.',
|
|
389
|
+
'The sheet has no column for {0}, which are required.': 'La hoja no tiene columnas para {0}, que son obligatorias.',
|
|
390
|
+
'The sheet has {0} rows; a synced table takes up to {1}.': 'La hoja tiene {0} filas; una tabla sincronizada recibe hasta {1}.',
|
|
391
|
+
'Line {0}: {1}': (a, t) => `Línea ${a[0]}: ${t(a[1])}`,
|
|
392
|
+
'A row is an object of column: value.': 'Una fila es un objeto de columna: valor.',
|
|
393
|
+
'The key, {0}, is empty.': 'La clave, {0}, está vacía.',
|
|
394
|
+
'{0} {1} is already on line {2}; each line of the sheet needs its own key.': '{0} {1} ya está en la línea {2}; cada línea de la hoja necesita su propia clave.',
|
|
395
|
+
'Rows in {0} still point at a row the sheet no longer has ({1}.{2}); put them back in the sheet, or change those rows first.': 'Filas de {0} todavía apuntan a una fila que la hoja ya no tiene ({1}.{2}); vuelve a ponerla en la hoja, o cambia esas filas primero.',
|
|
396
|
+
'Rows in {0} still point at {1} rows the sheet no longer has ({2}.{3}); put them back in the sheet, or change those rows first.': 'Filas de {0} todavía apuntan a {1} filas que la hoja ya no tiene ({2}.{3}); vuelve a ponerlas en la hoja, o cambia esas filas primero.',
|
|
397
|
+
"There is no file {0} in the project's knowledge.": 'No hay ningún archivo {0} en el conocimiento del proyecto.',
|
|
398
|
+
'{0} is {1}; a table syncs from a spreadsheet or CSV.': '{0} es {1}; una tabla se sincroniza desde una hoja de cálculo o un CSV.',
|
|
399
|
+
"{0} is no longer in the project's knowledge; pick the file again, or stop syncing {1}.": '{0} ya no está en el conocimiento del proyecto; vuelve a elegir el archivo, o deja de sincronizar {1}.',
|
|
400
|
+
'{0} is over {1} MB; a synced table reads files up to that size.': '{0} pesa más de {1} MB; una tabla sincronizada lee archivos de hasta ese tamaño.',
|
|
401
|
+
'The sheet could not be read; try "Sync now" again in a few minutes.': 'No se pudo leer la hoja; vuelve a intentar "Sincronizar ahora" en unos minutos.',
|
|
402
|
+
"{0} can't be both customer-scoped and synced from a sheet: synced rows have no customer, so the bots wouldn't see them.": '{0} no puede estar limitada al cliente y a la vez sincronizarse desde una hoja: las filas sincronizadas no tienen cliente, así que los bots no las verían.',
|
|
403
|
+
'Can\'t delete: it would change a row of {0} ({1}.{2}), which is synced from "{3}"; change the sheet first, or stop syncing it.': 'No se puede eliminar: cambiaría una fila de {0} ({1}.{2}), que se sincroniza desde "{3}"; primero cambia la hoja, o deja de sincronizarla.',
|
|
404
|
+
'Can\'t delete: it would change {0} rows of {1} ({2}.{3}), which is synced from "{4}"; change the sheet first, or stop syncing it.': 'No se puede eliminar: cambiaría {0} filas de {1} ({2}.{3}), que se sincroniza desde "{4}"; primero cambia la hoja, o deja de sincronizarla.',
|
|
405
|
+
'{0} has no sheet "{1}". Sheets: {2}.': '{0} no tiene una hoja "{1}". Hojas: {2}.',
|
|
406
|
+
'{0} is over {1} MB.': '{0} pesa más de {1} MB.',
|
|
407
|
+
'{0} is {1}; a table reads CSV and Excel files.': '{0} es {1}; una tabla lee archivos CSV y de Excel.',
|
|
408
|
+
'A post needs "chatId".': 'Una publicación necesita "chatId".',
|
|
409
|
+
'WhatsApp has no group chats for bots; message a customer with send().': 'WhatsApp no tiene chats de grupo para bots; escríbele a un cliente con send().'
|
|
304
410
|
};
|
|
305
411
|
const compile = (template, render) => {
|
|
306
412
|
const parts = template.split(/\{\d+\}/);
|
package/dist/schema.d.ts
CHANGED
|
@@ -622,6 +622,7 @@ export declare const Schema: {
|
|
|
622
622
|
}, z.core.$strip>;
|
|
623
623
|
ARTIFACT_CREATE_PROMPT_VIEW: z.ZodObject<{
|
|
624
624
|
description: z.ZodOptional<z.ZodString>;
|
|
625
|
+
title: z.ZodString;
|
|
625
626
|
schema: z.ZodObject<{
|
|
626
627
|
type: z.ZodEnum<{
|
|
627
628
|
[x: string]: string;
|
|
@@ -636,7 +637,6 @@ export declare const Schema: {
|
|
|
636
637
|
pattern: z.ZodOptional<z.ZodString>;
|
|
637
638
|
enum: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
638
639
|
}, z.core.$strip>;
|
|
639
|
-
title: z.ZodString;
|
|
640
640
|
messages: z.ZodArray<z.ZodObject<{
|
|
641
641
|
role: z.ZodEnum<{
|
|
642
642
|
user: "user";
|
|
@@ -676,6 +676,7 @@ export declare const Schema: {
|
|
|
676
676
|
}, z.core.$strip>;
|
|
677
677
|
ARTIFACT_UPDATE_PROMPT_VIEW: z.ZodObject<{
|
|
678
678
|
description: z.ZodOptional<z.ZodString>;
|
|
679
|
+
title: z.ZodString;
|
|
679
680
|
schema: z.ZodObject<{
|
|
680
681
|
type: z.ZodEnum<{
|
|
681
682
|
[x: string]: string;
|
|
@@ -690,7 +691,6 @@ export declare const Schema: {
|
|
|
690
691
|
pattern: z.ZodOptional<z.ZodString>;
|
|
691
692
|
enum: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
692
693
|
}, z.core.$strip>;
|
|
693
|
-
title: z.ZodString;
|
|
694
694
|
messages: z.ZodArray<z.ZodObject<{
|
|
695
695
|
role: z.ZodEnum<{
|
|
696
696
|
user: "user";
|
|
@@ -795,6 +795,22 @@ export declare const Schema: {
|
|
|
795
795
|
userId: z.ZodUUID;
|
|
796
796
|
organizationId: z.ZodUUID;
|
|
797
797
|
}, z.core.$strip>;
|
|
798
|
+
DATA_ATTACHMENT_METADATA: z.ZodObject<{
|
|
799
|
+
table: z.ZodString;
|
|
800
|
+
column: z.ZodString;
|
|
801
|
+
index: z.ZodBoolean;
|
|
802
|
+
}, z.core.$strip>;
|
|
803
|
+
ARTIFACT_PICK_RESOURCE: z.ZodObject<{
|
|
804
|
+
projectId: z.ZodUUID;
|
|
805
|
+
userId: z.ZodUUID;
|
|
806
|
+
organizationId: z.ZodUUID;
|
|
807
|
+
q: z.ZodOptional<z.ZodString>;
|
|
808
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
809
|
+
tabular: z.ZodPipe<z.ZodOptional<z.ZodEnum<{
|
|
810
|
+
1: "1";
|
|
811
|
+
true: "true";
|
|
812
|
+
}>>, z.ZodTransform<boolean, "1" | "true" | undefined>>;
|
|
813
|
+
}, z.core.$strip>;
|
|
798
814
|
ARTIFACT_CREATE_RESOURCE_VIEW: z.ZodObject<{
|
|
799
815
|
type: z.ZodDefault<z.ZodEnum<{
|
|
800
816
|
static: "static";
|
|
@@ -851,8 +867,8 @@ export declare const Schema: {
|
|
|
851
867
|
}>>;
|
|
852
868
|
content: z.ZodOptional<z.ZodString>;
|
|
853
869
|
description: z.ZodOptional<z.ZodString>;
|
|
854
|
-
size: z.ZodOptional<z.ZodNumber>;
|
|
855
870
|
title: z.ZodString;
|
|
871
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
856
872
|
crawlConfig: z.ZodOptional<z.ZodObject<{
|
|
857
873
|
maxPages: z.ZodDefault<z.ZodNumber>;
|
|
858
874
|
maxDepth: z.ZodDefault<z.ZodNumber>;
|
|
@@ -1112,8 +1128,8 @@ export declare const Schema: {
|
|
|
1112
1128
|
}>>;
|
|
1113
1129
|
content: z.ZodOptional<z.ZodString>;
|
|
1114
1130
|
description: z.ZodOptional<z.ZodString>;
|
|
1115
|
-
size: z.ZodOptional<z.ZodNumber>;
|
|
1116
1131
|
title: z.ZodString;
|
|
1132
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
1117
1133
|
encoding: z.ZodOptional<z.ZodString>;
|
|
1118
1134
|
fileKey: z.ZodOptional<z.ZodString>;
|
|
1119
1135
|
annotations: z.ZodOptional<z.ZodObject<{
|
|
@@ -1198,6 +1214,11 @@ export declare const Schema: {
|
|
|
1198
1214
|
min: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1199
1215
|
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>;
|
|
1200
1216
|
}, z.core.$strict>;
|
|
1217
|
+
DATA_TABLE_SOURCE: z.ZodObject<{
|
|
1218
|
+
uri: z.ZodString;
|
|
1219
|
+
sheet: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1220
|
+
key: z.ZodString;
|
|
1221
|
+
}, z.core.$strict>;
|
|
1201
1222
|
DATA_TABLE_INPUT: z.ZodObject<{
|
|
1202
1223
|
name: z.ZodString;
|
|
1203
1224
|
label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -1205,12 +1226,17 @@ export declare const Schema: {
|
|
|
1205
1226
|
displayColumn: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1206
1227
|
access: z.ZodOptional<z.ZodEnum<{
|
|
1207
1228
|
none: "none";
|
|
1208
|
-
read: "read";
|
|
1209
1229
|
add: "add";
|
|
1230
|
+
read: "read";
|
|
1210
1231
|
full: "full";
|
|
1211
1232
|
}>>;
|
|
1212
1233
|
customerScoped: z.ZodOptional<z.ZodBoolean>;
|
|
1213
1234
|
history: z.ZodOptional<z.ZodBoolean>;
|
|
1235
|
+
source: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1236
|
+
uri: z.ZodString;
|
|
1237
|
+
sheet: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1238
|
+
key: z.ZodString;
|
|
1239
|
+
}, z.core.$strict>>>;
|
|
1214
1240
|
columns: z.ZodArray<z.ZodObject<{
|
|
1215
1241
|
name: z.ZodString;
|
|
1216
1242
|
type: z.ZodEnum<{
|
|
@@ -1249,13 +1275,18 @@ export declare const Schema: {
|
|
|
1249
1275
|
}, z.core.$strict>;
|
|
1250
1276
|
DATA_TABLE_PATCH: z.ZodObject<{
|
|
1251
1277
|
name: z.ZodOptional<z.ZodString>;
|
|
1278
|
+
source: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1279
|
+
uri: z.ZodString;
|
|
1280
|
+
sheet: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1281
|
+
key: z.ZodString;
|
|
1282
|
+
}, z.core.$strict>>>>;
|
|
1252
1283
|
label: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
1253
1284
|
description: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
1254
1285
|
displayColumn: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
1255
1286
|
access: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
1256
1287
|
none: "none";
|
|
1257
|
-
read: "read";
|
|
1258
1288
|
add: "add";
|
|
1289
|
+
read: "read";
|
|
1259
1290
|
full: "full";
|
|
1260
1291
|
}>>>;
|
|
1261
1292
|
customerScoped: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -1466,7 +1497,12 @@ export declare const Schema: {
|
|
|
1466
1497
|
insert: "insert";
|
|
1467
1498
|
update: "update";
|
|
1468
1499
|
delete: "delete";
|
|
1500
|
+
time: "time";
|
|
1469
1501
|
}>;
|
|
1502
|
+
after: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1503
|
+
column: z.ZodString;
|
|
1504
|
+
minutes: z.ZodNumber;
|
|
1505
|
+
}, z.core.$strict>>>;
|
|
1470
1506
|
when: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1471
1507
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1472
1508
|
replace: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1504,7 +1540,12 @@ export declare const Schema: {
|
|
|
1504
1540
|
insert: "insert";
|
|
1505
1541
|
update: "update";
|
|
1506
1542
|
delete: "delete";
|
|
1543
|
+
time: "time";
|
|
1507
1544
|
}>;
|
|
1545
|
+
after: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1546
|
+
column: z.ZodString;
|
|
1547
|
+
minutes: z.ZodNumber;
|
|
1548
|
+
}, z.core.$strict>>>;
|
|
1508
1549
|
when: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1509
1550
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1510
1551
|
replace: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1531,6 +1572,20 @@ export declare const Schema: {
|
|
|
1531
1572
|
}, z.core.$strict>>;
|
|
1532
1573
|
}, z.core.$strict>>;
|
|
1533
1574
|
}, z.core.$strict>;
|
|
1575
|
+
DATA_TRIGGER_TEST_SEND_BODY: z.ZodObject<{
|
|
1576
|
+
table: z.ZodString;
|
|
1577
|
+
customer: z.ZodObject<{
|
|
1578
|
+
text: z.ZodString;
|
|
1579
|
+
template: z.ZodOptional<z.ZodObject<{
|
|
1580
|
+
name: z.ZodString;
|
|
1581
|
+
language: z.ZodString;
|
|
1582
|
+
params: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1583
|
+
}, z.core.$strict>>;
|
|
1584
|
+
}, z.core.$strict>;
|
|
1585
|
+
rowId: z.ZodOptional<z.ZodNumber>;
|
|
1586
|
+
participantId: z.ZodOptional<z.ZodString>;
|
|
1587
|
+
asTemplate: z.ZodOptional<z.ZodBoolean>;
|
|
1588
|
+
}, z.core.$strict>;
|
|
1534
1589
|
DATA_TRIGGER_RUN_LIST_QUERY: z.ZodObject<{
|
|
1535
1590
|
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
1536
1591
|
}, z.core.$strip>;
|
|
@@ -1547,6 +1602,12 @@ export declare const Schema: {
|
|
|
1547
1602
|
name: z.ZodString;
|
|
1548
1603
|
runId: z.ZodString;
|
|
1549
1604
|
}, z.core.$strip>;
|
|
1605
|
+
DATA_INDEX_ADVICE_PARAMS: z.ZodObject<{
|
|
1606
|
+
projectId: z.ZodUUID;
|
|
1607
|
+
userId: z.ZodUUID;
|
|
1608
|
+
organizationId: z.ZodUUID;
|
|
1609
|
+
adviceId: z.ZodUUID;
|
|
1610
|
+
}, z.core.$strip>;
|
|
1550
1611
|
DATA_COLUMN_PARAMS: z.ZodObject<{
|
|
1551
1612
|
projectId: z.ZodUUID;
|
|
1552
1613
|
userId: z.ZodUUID;
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAosCxB,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGrB,CAAC;AAyDN,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4CpB,CAAC;AAWH,QAAA,MAAM,kBAAkB;;;;;;;;;;iBA+CtB,CAAC;AAqCH,QAAA,MAAM,gBAAgB;;;;;kBAOX,CAA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C,EAAE,wBAAwB,EAAE,CAAC;CACtC"}
|
package/dist/schema.js
CHANGED
|
@@ -320,6 +320,13 @@ const ARTIFACT_SYNC_ONE_DRIVE = zod_1.z.object({
|
|
|
320
320
|
userId: zod_1.z.uuid(),
|
|
321
321
|
organizationId: zod_1.z.uuid()
|
|
322
322
|
});
|
|
323
|
+
// A knowledge item uploaded from a Data row: which file column it was for,
|
|
324
|
+
// and whether it is indexed for search too (the column's searchable switch).
|
|
325
|
+
const DATA_ATTACHMENT_METADATA = zod_1.z.object({
|
|
326
|
+
table: zod_1.z.string().min(1).max(64),
|
|
327
|
+
column: zod_1.z.string().min(1).max(64),
|
|
328
|
+
index: zod_1.z.boolean()
|
|
329
|
+
});
|
|
323
330
|
const ARTIFACT_CREATE_RESOURCE = zod_1.z.object({
|
|
324
331
|
title: zod_1.z.string().min(3).max(200),
|
|
325
332
|
uri: zod_1.z.string(),
|
|
@@ -423,6 +430,19 @@ const ARTIFACT_GET_RESOURCE_BY_ID = zod_1.z.object({
|
|
|
423
430
|
userId: zod_1.z.uuid(),
|
|
424
431
|
organizationId: zod_1.z.uuid()
|
|
425
432
|
});
|
|
433
|
+
// The knowledge items a Data file column can link, newest first.
|
|
434
|
+
const ARTIFACT_PICK_RESOURCE = zod_1.z.object({
|
|
435
|
+
projectId: zod_1.z.uuid(),
|
|
436
|
+
userId: zod_1.z.uuid(),
|
|
437
|
+
organizationId: zod_1.z.uuid(),
|
|
438
|
+
q: zod_1.z.string().trim().max(200).optional(),
|
|
439
|
+
limit: zod_1.z.coerce.number().int().min(1).max(50).default(20),
|
|
440
|
+
// Only spreadsheets and CSV, for a table's sheet source.
|
|
441
|
+
tabular: zod_1.z
|
|
442
|
+
.enum(['1', 'true'])
|
|
443
|
+
.optional()
|
|
444
|
+
.transform(v => v !== undefined)
|
|
445
|
+
});
|
|
426
446
|
const ARTIFACT_REMOVE_RESOURCE = zod_1.z.object({
|
|
427
447
|
resourceId: zod_1.z.uuid(),
|
|
428
448
|
projectId: zod_1.z.uuid(),
|
|
@@ -473,6 +493,13 @@ const DATA_COLUMN_INPUT = zod_1.z.strictObject({
|
|
|
473
493
|
default: DATA_DEFAULT_VALUE.optional()
|
|
474
494
|
});
|
|
475
495
|
// The CLI's schema file holds a list of these.
|
|
496
|
+
// A spreadsheet or CSV in the project's knowledge the table's rows come
|
|
497
|
+
// from, matched by `key`. Null stops syncing.
|
|
498
|
+
const DATA_TABLE_SOURCE = zod_1.z.strictObject({
|
|
499
|
+
uri: zod_1.z.string().min(1).max(2048),
|
|
500
|
+
sheet: zod_1.z.string().trim().min(1).max(100).nullable().optional(),
|
|
501
|
+
key: DATA_IDENTIFIER
|
|
502
|
+
});
|
|
476
503
|
const DATA_TABLE_INPUT = zod_1.z.strictObject({
|
|
477
504
|
name: DATA_IDENTIFIER,
|
|
478
505
|
label: DATA_TEXT(dataTypes_1.DATA_MAX_LABEL),
|
|
@@ -481,6 +508,7 @@ const DATA_TABLE_INPUT = zod_1.z.strictObject({
|
|
|
481
508
|
access: zod_1.z.enum(dataTypes_1.DATA_ACCESS_LEVELS).optional(),
|
|
482
509
|
customerScoped: zod_1.z.boolean().optional(),
|
|
483
510
|
history: zod_1.z.boolean().optional(),
|
|
511
|
+
source: DATA_TABLE_SOURCE.nullable().optional(),
|
|
484
512
|
columns: zod_1.z.array(DATA_COLUMN_INPUT).max(dataTypes_1.DATA_MAX_COLUMNS)
|
|
485
513
|
});
|
|
486
514
|
const DATA_TABLE_PATCH = DATA_TABLE_INPUT.omit({ columns: true }).partial();
|
|
@@ -655,9 +683,18 @@ const DATA_TRIGGER_INPUT = zod_1.z.strictObject({
|
|
|
655
683
|
name: DATA_TRIGGER_NAME.optional(),
|
|
656
684
|
description: zod_1.z.string().max(300).nullish(),
|
|
657
685
|
table: DATA_IDENTIFIER,
|
|
658
|
-
on: zod_1.z.enum(['insert', 'update', 'delete']),
|
|
686
|
+
on: zod_1.z.enum(['insert', 'update', 'delete', 'time']),
|
|
687
|
+
// With "time": fires this many minutes after the column's time (negative:
|
|
688
|
+
// before it). The column is created_at, updated_at or a date / datetime.
|
|
689
|
+
after: zod_1.z
|
|
690
|
+
.strictObject({
|
|
691
|
+
column: DATA_IDENTIFIER,
|
|
692
|
+
minutes: zod_1.z.number().int().min(-43_200).max(43_200)
|
|
693
|
+
})
|
|
694
|
+
.nullish(),
|
|
659
695
|
// { column: { changedTo | changedFrom | equals: value, changed: true } },
|
|
660
|
-
// combined with { all: [...] } or { any: [...] }.
|
|
696
|
+
// combined with { all: [...] } or { any: [...] }. A time trigger takes
|
|
697
|
+
// equals only.
|
|
661
698
|
when: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullish(),
|
|
662
699
|
enabled: zod_1.z.boolean().optional(),
|
|
663
700
|
// false: refuse to save over an existing trigger of this name.
|
|
@@ -691,6 +728,17 @@ const DATA_TRIGGER_PATCH = zod_1.z.strictObject({ enabled: zod_1.z.boolean() });
|
|
|
691
728
|
const DATA_TRIGGER_DEPLOY_BODY = zod_1.z.strictObject({
|
|
692
729
|
triggers: zod_1.z.array(DATA_TRIGGER_INPUT).max(50)
|
|
693
730
|
});
|
|
731
|
+
// A test of a "customer" action as the dialog has it, sent to the signed-in
|
|
732
|
+
// owner's own chat with the bot, built from one row (the newest by default).
|
|
733
|
+
const DATA_TRIGGER_TEST_SEND_BODY = zod_1.z.strictObject({
|
|
734
|
+
table: DATA_IDENTIFIER,
|
|
735
|
+
customer: DATA_TRIGGER_INPUT.shape.customer.unwrap(),
|
|
736
|
+
rowId: zod_1.z.number().int().min(1).optional(),
|
|
737
|
+
// Which of the owner's linked chats, when there is more than one.
|
|
738
|
+
participantId: zod_1.z.string().min(1).max(64).optional(),
|
|
739
|
+
// Send the template even inside WhatsApp's 24-hour window.
|
|
740
|
+
asTemplate: zod_1.z.boolean().optional()
|
|
741
|
+
});
|
|
694
742
|
const DATA_TRIGGER_RUN_LIST_QUERY = zod_1.z.object({
|
|
695
743
|
limit: zod_1.z.coerce.number().int().min(1).max(50).optional()
|
|
696
744
|
});
|
|
@@ -704,6 +752,8 @@ const DATA_TRIGGER_PATH_PARAMS = DATA_DATABASE_GET.extend({ name: DATA_TRIGGER_N
|
|
|
704
752
|
const DATA_TRIGGER_RUN_PARAMS = DATA_TRIGGER_PATH_PARAMS.extend({
|
|
705
753
|
runId: zod_1.z.string().min(1).max(64)
|
|
706
754
|
});
|
|
755
|
+
// An index suggestion, by its id.
|
|
756
|
+
const DATA_INDEX_ADVICE_PARAMS = DATA_DATABASE_GET.extend({ adviceId: zod_1.z.uuid() });
|
|
707
757
|
const ARTIFACT_UPLOAD_RESOURCE_FILE = zod_1.z.object({
|
|
708
758
|
resourceId: zod_1.z.uuid(),
|
|
709
759
|
projectId: zod_1.z.uuid(),
|
|
@@ -1857,6 +1907,8 @@ exports.Schema = {
|
|
|
1857
1907
|
ARTIFACT_GET_PROMPT,
|
|
1858
1908
|
ARTIFACT_REMOVE_PROMPT,
|
|
1859
1909
|
ARTIFACT_CREATE_RESOURCE,
|
|
1910
|
+
DATA_ATTACHMENT_METADATA,
|
|
1911
|
+
ARTIFACT_PICK_RESOURCE,
|
|
1860
1912
|
ARTIFACT_CREATE_RESOURCE_VIEW,
|
|
1861
1913
|
ARTIFACT_CREATE_WEBSITE,
|
|
1862
1914
|
ARTIFACT_CREATE_WEBSITE_VIEW,
|
|
@@ -1876,6 +1928,7 @@ exports.Schema = {
|
|
|
1876
1928
|
DATA_DATABASE_CREATE,
|
|
1877
1929
|
DATA_DATABASE_DELETE,
|
|
1878
1930
|
DATA_COLUMN_INPUT,
|
|
1931
|
+
DATA_TABLE_SOURCE,
|
|
1879
1932
|
DATA_TABLE_INPUT,
|
|
1880
1933
|
DATA_TABLE_PATCH,
|
|
1881
1934
|
DATA_COLUMN_PATCH,
|
|
@@ -1903,9 +1956,11 @@ exports.Schema = {
|
|
|
1903
1956
|
DATA_TRIGGER_INPUT,
|
|
1904
1957
|
DATA_TRIGGER_PATCH,
|
|
1905
1958
|
DATA_TRIGGER_DEPLOY_BODY,
|
|
1959
|
+
DATA_TRIGGER_TEST_SEND_BODY,
|
|
1906
1960
|
DATA_TRIGGER_RUN_LIST_QUERY,
|
|
1907
1961
|
DATA_TRIGGER_PATH_PARAMS,
|
|
1908
1962
|
DATA_TRIGGER_RUN_PARAMS,
|
|
1963
|
+
DATA_INDEX_ADVICE_PARAMS,
|
|
1909
1964
|
DATA_COLUMN_PARAMS,
|
|
1910
1965
|
DATA_ROW_PARAMS,
|
|
1911
1966
|
ARTIFACT_REMOVE_RESOURCE,
|
|
@@ -13,6 +13,13 @@ export declare const wrapUntrustedContent: (source: string, text: string) => str
|
|
|
13
13
|
* returned as it is.
|
|
14
14
|
*/
|
|
15
15
|
export declare const unwrapUntrustedContent: (text: string) => string;
|
|
16
|
+
export declare const UNTRUSTED_CONTENT_MARK_PATTERN: string;
|
|
17
|
+
/**
|
|
18
|
+
* Text with the marks around every wrapped block removed and the bodies kept,
|
|
19
|
+
* for showing a recorded result to a person: an error that quotes an
|
|
20
|
+
* endpoint's answer reads as the message and the answer.
|
|
21
|
+
*/
|
|
22
|
+
export declare const stripUntrustedMarks: (text: string) => string;
|
|
16
23
|
/** Whether a tool result carries the flag set by the server that ran it. */
|
|
17
24
|
export declare const isUntrustedToolResult: (result: unknown) => boolean;
|
|
18
25
|
export declare const INSTRUCTION_WARNING_METADATA_KEY = "instructionWarning";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"untrustedContent.d.ts","sourceRoot":"","sources":["../src/untrustedContent.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAMzD,eAAO,MAAM,0BAA0B,uBAAuB,CAAC;AAI/D,eAAO,MAAM,sBAAsB,QASO,CAAC;AA0D3C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,MAWnE,CAAC;AAQF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,MAA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CAAA;CAAE,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,eAAe,EAC7D,UAAU,CAAC,EAAE,KACZ;IAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAW3C,CAAC;AA6BF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,EAC1E,QAAQ,MAAM,EACd,UAAU,MAAM,KACf,kBAsCF,CAAC"}
|
package/dist/untrustedContent.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
//
|
|
12
12
|
// Imports nothing, so the tests can load it on their own.
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.labelProxiedToolResult = exports.labelResourceContents = exports.readsLikeInstructions = exports.untrustedErrorResult = exports.labelOwnToolResult = exports.ownWritingToolResult = exports.untrustedToolResult = exports.findInstructionLikeText = exports.INSTRUCTION_WARNING_METADATA_KEY = exports.isUntrustedToolResult = exports.unwrapUntrustedContent = exports.wrapUntrustedContent = exports.UNTRUSTED_CONTENT_NOTE = exports.UNTRUSTED_CONTENT_META_KEY = exports.UNTRUSTED_CONTENT_TAG = void 0;
|
|
14
|
+
exports.labelProxiedToolResult = exports.labelResourceContents = exports.readsLikeInstructions = exports.untrustedErrorResult = exports.labelOwnToolResult = exports.ownWritingToolResult = exports.untrustedToolResult = exports.findInstructionLikeText = exports.INSTRUCTION_WARNING_METADATA_KEY = exports.isUntrustedToolResult = exports.stripUntrustedMarks = exports.UNTRUSTED_CONTENT_MARK_PATTERN = exports.unwrapUntrustedContent = exports.wrapUntrustedContent = exports.UNTRUSTED_CONTENT_NOTE = exports.UNTRUSTED_CONTENT_META_KEY = exports.UNTRUSTED_CONTENT_TAG = void 0;
|
|
15
15
|
exports.UNTRUSTED_CONTENT_TAG = 'untrusted_content';
|
|
16
16
|
// Set on a tool result, under `_meta`, when the text in it came from someone
|
|
17
17
|
// outside the organization (an inbox, the web, a remote server) or when a
|
|
@@ -111,6 +111,18 @@ const unwrapUntrustedContent = (text) => {
|
|
|
111
111
|
return match ? match[2] : text;
|
|
112
112
|
};
|
|
113
113
|
exports.unwrapUntrustedContent = unwrapUntrustedContent;
|
|
114
|
+
// Either line wrapUntrustedContent adds around a block, with the newline that
|
|
115
|
+
// joins it to the body. A `<` of ours inside a body was escaped, so every
|
|
116
|
+
// match is a real mark. A source string so SQL can strip the same marks.
|
|
117
|
+
exports.UNTRUSTED_CONTENT_MARK_PATTERN = `\\n?<${exports.UNTRUSTED_CONTENT_TAG} id="[0-9a-f]+" source="[^"]*">\\n?` +
|
|
118
|
+
`|\\n?</${exports.UNTRUSTED_CONTENT_TAG} id="[0-9a-f]+">`;
|
|
119
|
+
/**
|
|
120
|
+
* Text with the marks around every wrapped block removed and the bodies kept,
|
|
121
|
+
* for showing a recorded result to a person: an error that quotes an
|
|
122
|
+
* endpoint's answer reads as the message and the answer.
|
|
123
|
+
*/
|
|
124
|
+
const stripUntrustedMarks = (text) => text.replace(new RegExp(exports.UNTRUSTED_CONTENT_MARK_PATTERN, 'g'), '\n').trim();
|
|
125
|
+
exports.stripUntrustedMarks = stripUntrustedMarks;
|
|
114
126
|
/** Whether a tool result carries the flag set by the server that ran it. */
|
|
115
127
|
const isUntrustedToolResult = (result) => {
|
|
116
128
|
if (!result || typeof result !== 'object')
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface WhatsappWebhookChange<V> {
|
|
2
|
+
field?: string;
|
|
3
|
+
value?: V;
|
|
4
|
+
}
|
|
5
|
+
export interface WhatsappWebhookEnvelope<V> {
|
|
6
|
+
entry?: Array<{
|
|
7
|
+
id?: string;
|
|
8
|
+
changes?: Array<WhatsappWebhookChange<V>>;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export interface WhatsappAddressedValue {
|
|
12
|
+
metadata?: {
|
|
13
|
+
phone_number_id?: string;
|
|
14
|
+
};
|
|
15
|
+
messages?: unknown[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The change carrying a message for this channel's number, wherever Meta put
|
|
19
|
+
* it in the batch. A change that doesn't say which number it's for is kept.
|
|
20
|
+
*/
|
|
21
|
+
export declare const whatsappMessageChange: <V extends WhatsappAddressedValue>(payload: WhatsappWebhookEnvelope<V>, phoneNumberId: string) => V | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* The changes with one of `fields` from this channel's business account. An
|
|
24
|
+
* entry without an id, or a channel that hasn't saved its account, keeps
|
|
25
|
+
* them: template events only touch the channel's own stored templates.
|
|
26
|
+
*/
|
|
27
|
+
export declare const whatsappAccountChanges: <V>(payload: WhatsappWebhookEnvelope<V>, businessAccountId: string | undefined, fields: readonly string[]) => WhatsappWebhookChange<V>[];
|
|
28
|
+
//# sourceMappingURL=whatsappWebhook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsappWebhook.d.ts","sourceRoot":"","sources":["../src/whatsappWebhook.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,CAAC,CAAC;CACX;AAED,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,CAAC,CAAC;CAC3E;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,sBAAsB,EACpE,SAAS,uBAAuB,CAAC,CAAC,CAAC,EACnC,eAAe,MAAM,KACpB,CAAC,GAAG,SAQM,CAAC;AAEd;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,EACtC,SAAS,uBAAuB,CAAC,CAAC,CAAC,EACnC,mBAAmB,MAAM,GAAG,SAAS,EACrC,QAAQ,SAAS,MAAM,EAAE,KACxB,qBAAqB,CAAC,CAAC,CAAC,EAStB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// What one WhatsApp channel takes from a webhook. A Meta app sends every
|
|
3
|
+
// number's events to each of its callbacks, signed with the same app secret,
|
|
4
|
+
// so a channel keeps only what was addressed to its own number and business
|
|
5
|
+
// account; otherwise another channel's bot answers its messages.
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.whatsappAccountChanges = exports.whatsappMessageChange = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* The change carrying a message for this channel's number, wherever Meta put
|
|
10
|
+
* it in the batch. A change that doesn't say which number it's for is kept.
|
|
11
|
+
*/
|
|
12
|
+
const whatsappMessageChange = (payload, phoneNumberId) => (payload.entry ?? [])
|
|
13
|
+
.flatMap(entry => entry.changes ?? [])
|
|
14
|
+
.find(change => {
|
|
15
|
+
const value = change.value;
|
|
16
|
+
if (!value?.messages?.length)
|
|
17
|
+
return false;
|
|
18
|
+
const to = value.metadata?.phone_number_id;
|
|
19
|
+
return !to || to === phoneNumberId;
|
|
20
|
+
})?.value;
|
|
21
|
+
exports.whatsappMessageChange = whatsappMessageChange;
|
|
22
|
+
/**
|
|
23
|
+
* The changes with one of `fields` from this channel's business account. An
|
|
24
|
+
* entry without an id, or a channel that hasn't saved its account, keeps
|
|
25
|
+
* them: template events only touch the channel's own stored templates.
|
|
26
|
+
*/
|
|
27
|
+
const whatsappAccountChanges = (payload, businessAccountId, fields) => (payload.entry ?? [])
|
|
28
|
+
.filter(entry => !entry.id || !businessAccountId || entry.id === businessAccountId)
|
|
29
|
+
.flatMap(entry => (entry.changes ?? []).filter(change => !!change.field && fields.includes(change.field)));
|
|
30
|
+
exports.whatsappAccountChanges = whatsappAccountChanges;
|