planvortex 0.25.0 → 0.26.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/README.md CHANGED
@@ -69,6 +69,8 @@ const pv = new PlanVortex({
69
69
  const { data: accounts } = await pv.accounts.list(orgId, { capability: "publications" });
70
70
 
71
71
  // A path is the form that does not read the file into memory. A Buffer or a Blob also work.
72
+ // Made with AI? Add `ai_generated: true`: TikTok then shows its AI label. Leave it out and the
73
+ // file decides: one whose metadata says it was generated with AI comes back marked "detected".
72
74
  const upload = await pv.uploads.create(orgId, { file: "./hogaza.jpg" });
73
75
 
74
76
  const publication = await pv.publications.create(orgId, accounts[0]._id, {
@@ -440,7 +442,7 @@ if you would rather branch on `error.family`.
440
442
  | 500-554 | Authentication, tokens, permissions, client apps | `AuthError` |
441
443
  | 601-612 | Users | `UserError` |
442
444
  | 700-716 | Social accounts — disconnected, revoked, no slot left | `AccountError` |
443
- | 800-810 | Files | `FileError` |
445
+ | 800-812 | Files, and the AI mark of a file (811, 812) | `FileError` |
444
446
  | 900-996 | Publications, every per-network limit, the two rate brakes, Slack and Pinterest | `PublicationError` |
445
447
  | 1000-1003 | General | `PlanVortexError` |
446
448
  | 1100-1111 | Organizations | `OrganizationError` |
@@ -10,7 +10,9 @@ var PLANVORTEX_ERROR_RANGES = [
10
10
  //716: la sesion de Bluesky la esta renovando otro proceso. Es temporal, y fuera de familia no
11
11
  //habia forma de saber que la respuesta es reintentar.
12
12
  { from: 700, to: 716, family: "account" },
13
- { from: 800, to: 810, family: "file" },
13
+ //811-812: la marca de IA de un fichero (fase 39 del servidor): desmarcar lo que genero el
14
+ //planificador y una declaracion que no es ni true ni false.
15
+ { from: 800, to: 812, family: "file" },
14
16
  //El techo sube con el catalogo del servidor, y subir tarde no da un error: da un consejo
15
17
  //equivocado. Los codigos de Bluesky, Discord, Telegram y Threads (961-977) y los dos frenos
16
18
  //de ritmo de la fase de publicaciones ilimitadas (978, 979) nacieron por encima de 960 y
@@ -166,5 +168,5 @@ function isTokenError(error) {
166
168
  }
167
169
 
168
170
  export { AccountError, AiPlanError, AuthError, ContactError, FileError, IntegrationError, MessagingError, NO_ERROR_CODE, OrganizationError, PLANVORTEX_ERROR_RANGES, PlanLimitError, PlanVortexAuthenticationError, PlanVortexConfigError, PlanVortexConnectionError, PlanVortexError, ProductError, PublicationError, TOKEN_ERROR_CODES, UserError, createErrorFromResponse, errorFamilyForCode, isPlanVortexError, isTokenError };
169
- //# sourceMappingURL=chunk-L2DNKFA2.js.map
170
- //# sourceMappingURL=chunk-L2DNKFA2.js.map
171
+ //# sourceMappingURL=chunk-JAA666FR.js.map
172
+ //# sourceMappingURL=chunk-JAA666FR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/errors.ts"],"names":[],"mappings":";AAuBO,IAAM,uBAAA,GAA2D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpE,EAAE,IAAA,EAAM,GAAA,EAAK,EAAA,EAAI,GAAA,EAAK,QAAQ,MAAA,EAAO;AAAA,EACrC,EAAE,IAAA,EAAM,GAAA,EAAK,EAAA,EAAI,GAAA,EAAK,QAAQ,MAAA,EAAO;AAAA;AAAA;AAAA,EAGrC,EAAE,IAAA,EAAM,GAAA,EAAK,EAAA,EAAI,GAAA,EAAK,QAAQ,SAAA,EAAU;AAAA;AAAA;AAAA,EAGxC,EAAE,IAAA,EAAM,GAAA,EAAK,EAAA,EAAI,GAAA,EAAK,QAAQ,MAAA,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrC,EAAE,IAAA,EAAM,GAAA,EAAK,EAAA,EAAI,GAAA,EAAK,QAAQ,aAAA,EAAc;AAAA,EAC5C,EAAE,IAAA,EAAM,GAAA,EAAM,EAAA,EAAI,IAAA,EAAM,QAAQ,SAAA,EAAU;AAAA,EAC1C,EAAE,IAAA,EAAM,IAAA,EAAM,EAAA,EAAI,IAAA,EAAM,QAAQ,cAAA,EAAe;AAAA,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AA,CAAgB,aAAA,EAAe,CAAA,KAAA,EAAQ,KAAA,CAAM,MAAM,CAAA,CAAA,EAAI;AAAA,IAC9D,GAAG,OAAA;AAAA,IACH,MAAA,EAAQ,MAAA;AAAA,IACR,IAAA,EACI,OAAO,KAAA,CAAM,IAAA,KAAS,QAAA,IAAY,KAAA,CAAM,IAAA,KAAS,IAAA,GAC1C,KAAA,CAAM,IAAA,GACP,EAAE,IAAA,EAAM,MAAM,IAAA;AAAK,GAChC,CAAA;AACL;AAGO,SAAS,kBAAkB,KAAA,EAA0C;AACxE,EAAA,OAAO,KAAA,YAAiB,eAAA;AAC5B;AAOO,SAAS,aAAa,KAAA,EAAyB;AAClD,EAAA,OAAO,kBAAkB,KAAK,CAAA,IAAK,iBAAA,CAAkB,QAAA,CAAS,MAAM,IAAI,CAAA;AAC5E","file":"chunk-JAA666FR.js","sourcesContent":["/**\n * El catálogo de errores de PlanVortex, por rangos, y las clases que salen de él.\n *\n * LA REGLA, y no es negociable: **los errores se clasifican por `body.code`, nunca por el status\n * HTTP.** Todo error de dominio viaja con un 400 — un token caducado, una cuenta desconectada, el\n * cupo del plan agotado y un texto demasiado largo son los cuatro un 400. Sólo el 520 (permisos)\n * sale 401 y un fallo inesperado sale 500. Un `if (response.status === 401) refreshToken()` sería\n * un bug silencioso: los códigos de token, 501 y 522, viajan dentro de un 400.\n *\n * El catálogo del servidor crece cada mes, así que un código fuera de estos rangos NO es un error\n * del cliente: cae en la clase base con su `code` y su `message` intactos. Nunca se traga y nunca\n * se renombra.\n */\n\nexport type PlanVortexErrorRange = {\n /** Primer código del rango, incluido */\n from: number;\n /** Último código del rango, incluido */\n to: number;\n /** Qué familia de problemas es */\n family: string;\n};\n\nexport const PLANVORTEX_ERROR_RANGES: readonly PlanVortexErrorRange[] = [\n //Hasta 548, no 544: la API publica se abrio a todos los planes y trajo dos codigos nuevos\n //—545 (ritmo por plan, que sale 429) y 546 (correo sin verificar al crear una app)—, y las\n //apps dos mas —547 (el identificador de una app no se cambia) y 548 (fallo al rotar el\n //secreto, que es justo lo que estreno `apps.rotateSecret`)—. Y hasta 554 desde que el selector\n //de cuentas puede ponerlo el integrador (549-554: el modo y su sesion de conexion).\n { from: 500, to: 554, family: \"auth\" },\n { from: 601, to: 612, family: \"user\" },\n //716: la sesion de Bluesky la esta renovando otro proceso. Es temporal, y fuera de familia no\n //habia forma de saber que la respuesta es reintentar.\n { from: 700, to: 716, family: \"account\" },\n //811-812: la marca de IA de un fichero (fase 39 del servidor): desmarcar lo que genero el\n //planificador y una declaracion que no es ni true ni false.\n { from: 800, to: 812, family: \"file\" },\n //El techo sube con el catalogo del servidor, y subir tarde no da un error: da un consejo\n //equivocado. Los codigos de Bluesky, Discord, Telegram y Threads (961-977) y los dos frenos\n //de ritmo de la fase de publicaciones ilimitadas (978, 979) nacieron por encima de 960 y\n //caian fuera de toda familia. Slack estreno el 980-986, que es el mismo caso otra vez, y\n //Pinterest el 987-996 — la tercera vez.\n { from: 900, to: 996, family: \"publication\" },\n { from: 1000, to: 1003, family: \"general\" },\n { from: 1100, to: 1111, family: \"organization\" },\n { from: 1200, to: 1207, family: \"role\" },\n //1308 es el tope de APPS del plan, que nacio al quitar el candado de precio de la API.\n { from: 1300, to: 1308, family: \"plan_limit\" },\n { from: 1400, to: 1408, family: \"plan_limit\" },\n //1513 y 1514 son las plantillas de WhatsApp: el formato que Meta rechazaria sin decir por que,\n //y Meta rechazandola al crearla. Nacieron por encima del techo, la cuarta vez que pasa. 1515 y\n //1516 son los archivos que llegan de la red: 1515 = la red ya no lo tiene (tambien en un\n //comentario), 1516 = ese mensaje o esa posicion no existen. 1517 = ese audio o video no se pudo\n //convertir con `playable` (el original sigue ahi sin el parametro): la quinta vez.\n { from: 1500, to: 1517, family: \"messaging\" },\n { from: 1600, to: 1601, family: \"contact\" },\n { from: 1900, to: 1906, family: \"payment\" },\n { from: 2000, to: 2099, family: \"product\" },\n { from: 2100, to: 2199, family: \"ai_plan\" },\n { from: 2200, to: 2299, family: \"integration\" },\n //Los COMENTARIOS siguen aquí porque sus 945-948 se llenaron, y van con ellos a `publication`:\n //el 2600 (esta cuenta no tiene bandeja, un perfil personal de LinkedIn) es la versión por\n //cuenta del 945, y separarlos daría dos clases para el mismo «aquí no hay comentarios».\n //Los campos de publicación que no cabían en los 9xx (2500-2507: visibilidad, niños, y lo que\n //exige la auditoría de TikTok). Casi todos viajan en `publication_errors`, pero el 2508 se\n //LANZA: `accounts.publishSettings()` en una red que no los tiene.\n { from: 2500, to: 2599, family: \"publication\" },\n { from: 2600, to: 2699, family: \"publication\" },\n //Los comentarios de TikTok, que van por otra API (TikTok API for Business) con su propia\n //credencial: 2804 = hay que volver a activarlos, 2805 = TikTok frena a la app (temporal),\n //2809 = TikTok mantiene oculto el comentario. Son comentarios, así que la misma familia.\n { from: 2800, to: 2899, family: \"publication\" },\n] as const;\n\n/**\n * El `code` que lleva un error que **no** trae código del servidor: un fallo de red, un timeout, un\n * 502 de un proxy con cuerpo HTML, o el propio constructor quejándose de la configuración.\n *\n * El servidor no emite nunca el 0, así que sirve de centinela sin pisar el catálogo. Cuál de esos\n * casos es se distingue por `family`: `connection`, `http`, `oauth`, `config` o `webhook`.\n */\nexport const NO_ERROR_CODE = 0;\n\n/**\n * Los dos códigos que significan \"tu token ya no sirve\". Los dos llegan **dentro de un 400**, que es\n * justo por lo que existe esta constante: quien mire el status no los va a encontrar.\n *\n * El 520 (permisos) NO está aquí a propósito: sale 401, pero pedir un token nuevo no lo arregla — a\n * la app le faltan permisos, y con un token recién emitido le seguirán faltando.\n */\nexport const TOKEN_ERROR_CODES: readonly number[] = [501, 522];\n\n/** Opciones de construcción de un error. Todas opcionales: un error siempre se puede construir. */\nexport interface PlanVortexErrorOptions {\n /** El `data` del cuerpo — lo que el servidor adjuntó con `.withData({...})`. `{}` si no vino nada. */\n data?: Record<string, unknown>;\n /** Status HTTP. `undefined` cuando la petición no llegó a tener respuesta. */\n status?: number;\n /** `x-request-id` de la respuesta, si el despliegue lo pone delante. */\n requestId?: string;\n /** Segundos de la cabecera `Retry-After`, cuando la hay. */\n retryAfter?: number;\n /** El error original (un `TypeError` de `fetch`, por ejemplo). */\n cause?: unknown;\n /**\n * Familia, sólo para los errores que NO salen del catálogo: `connection`, `http`, `oauth`,\n * `config` y `webhook`. Los de dominio la deducen de su `code` y no la pasan nunca.\n */\n family?: string;\n}\n\n/**\n * La base de todo lo que lanza esta librería.\n *\n * Un `catch (e) { if (e instanceof PlanVortexError) }` los coge todos: los de dominio, los de red y\n * los de configuración. Para afinar están las subclases y el `code`.\n */\nexport class PlanVortexError extends Error {\n /** El `code` del cuerpo, tal cual. {@link NO_ERROR_CODE} si el error no viene del catálogo. */\n readonly code: number;\n /** La familia del rango: `auth`, `publication`, `plan_limit`... Ver {@link PLANVORTEX_ERROR_RANGES}. */\n readonly family: string;\n /** El `data` del cuerpo. */\n readonly data: Record<string, unknown>;\n /** Status HTTP, o `undefined` si nunca hubo respuesta. */\n readonly status: number | undefined;\n /** `x-request-id`, si el despliegue lo pone. Hoy el servidor no lo emite; un proxy delante sí. */\n readonly requestId: string | undefined;\n /** Segundos que pidió esperar la cabecera `Retry-After`, si llegó. */\n readonly retryAfter: number | undefined;\n\n constructor(code: number, message: string, options: PlanVortexErrorOptions = {}) {\n super(message, options.cause === undefined ? undefined : { cause: options.cause });\n this.name = new.target.name;\n this.code = code;\n this.family = options.family ?? errorFamilyForCode(code) ?? \"unknown\";\n this.data = options.data ?? {};\n this.status = options.status;\n this.requestId = options.requestId;\n this.retryAfter = options.retryAfter;\n }\n}\n\n/** 500-554 — tokens, apps de cliente, permisos, sesiones de conexion. Incluye el 501 y el 522, los de token caducado. */\nexport class AuthError extends PlanVortexError {}\n/** 601-612 — el usuario final. */\nexport class UserError extends PlanVortexError {}\n/** 700-716 — cuentas sociales: desconectada, sin permisos en la red, sin refrescar. */\nexport class AccountError extends PlanVortexError {}\n/** 800-812 — ficheros: formato no admitido, demasiado grande, conversión fallida, y la marca de IA (811, 812). */\nexport class FileError extends PlanVortexError {}\n/** 900-996 — publicaciones, incluidos los límites por red (caracteres, imágenes, duración), los\n * dos frenos de ritmo —978 (demasiado rápido en esta cuenta) y 979 (tope diario de esa red)—, los\n * de Slack (980-986), que empiezan por el más común: 980, la app no está en el canal, y los de\n * Pinterest (987-996), que empiezan igual: 987, la publicación no dice en qué tablero va. Y uno\n * de ellos no es un fallo: el 991 es Pinterest frenando a la aplicación, sale 429 con\n * `Retry-After` y la respuesta es esperar. */\nexport class PublicationError extends PlanVortexError {}\n/** 1100-1111 — organizaciones, y el token temporal atado a una sola de ellas (1101). */\nexport class OrganizationError extends PlanVortexError {}\n/**\n * 1300-1308 y 1400-1408 — el cupo del plan, del cliente o de la organización.\n *\n * Es el error que un integrador **sí** quiere distinguir: no se arregla reintentando, se arregla\n * cambiando de plan. Por eso los dos rangos comparten clase.\n */\nexport class PlanLimitError extends PlanVortexError {}\n/** 1500-1517 — conversaciones, mensajes, plantillas y sus archivos. Exige plan de pago. */\nexport class MessagingError extends PlanVortexError {}\n/** 1600-1601 — contactos. */\nexport class ContactError extends PlanVortexError {}\n/** 2000-2099 — catálogos y productos (sólo Facebook e Instagram). */\nexport class ProductError extends PlanVortexError {}\n/** 2100-2199 — planes de publicaciones generados con IA. */\nexport class AiPlanError extends PlanVortexError {}\n/** 2200-2299 — integraciones: Google Drive, RSS. */\nexport class IntegrationError extends PlanVortexError {}\n\n/**\n * La petición no llegó a tener respuesta: DNS, conexión rechazada, socket cortado o timeout.\n *\n * No lleva código del catálogo porque el servidor nunca llegó a opinar.\n */\nexport class PlanVortexConnectionError extends PlanVortexError {\n /** `true` si lo que se agotó fue nuestro propio timeout, no la red. */\n readonly timeout: boolean;\n\n constructor(message: string, options: PlanVortexErrorOptions & { timeout?: boolean } = {}) {\n super(NO_ERROR_CODE, message, { ...options, family: \"connection\" });\n this.timeout = options.timeout ?? false;\n }\n}\n\n/**\n * `POST /oauth/token` rechazó las credenciales.\n *\n * Es el ÚNICO sitio del API con forma de error distinta: `{error, error_description}` de OAuth2, no\n * el `{code, message, data}` de todo lo demás. Y por eso el `code` es {@link NO_ERROR_CODE}: el\n * servidor tiene códigos para esto (538-541) pero **no los manda en el cuerpo**, así que ponerlos\n * aquí sería inventarse algo que nadie dijo. Lo que sí viaja es `oauthError`.\n */\nexport class PlanVortexAuthenticationError extends PlanVortexError {\n /** `invalid_client`, `invalid_request`, `unsupported_grant_type`, `slow_down` o `server_error`. */\n readonly oauthError: string;\n\n constructor(oauthError: string, description: string, options: PlanVortexErrorOptions = {}) {\n super(NO_ERROR_CODE, description, { ...options, family: \"oauth\" });\n this.oauthError = oauthError;\n }\n}\n\n/**\n * La librería está mal configurada y no ha llegado a salir de casa: sin credenciales, o instanciada\n * en un navegador (§ trampa 9 del roadmap).\n */\nexport class PlanVortexConfigError extends PlanVortexError {\n constructor(message: string) {\n super(NO_ERROR_CODE, message, { family: \"config\" });\n }\n}\n\n/** La familia a la que pertenece un código, o `undefined` si cae fuera del catálogo conocido. */\nexport function errorFamilyForCode(code: number): string | undefined {\n return PLANVORTEX_ERROR_RANGES.find((range) => code >= range.from && code <= range.to)?.family;\n}\n\n/**\n * Familia -> clase. Las que faltan —`general`, `role`, `payment` y cualquier rango nuevo— caen a\n * propósito en la clase base: existen en el servidor pero no son superficie de integración, y darles\n * clase propia sería prometer un `instanceof` que luego habría que mantener.\n */\nconst FAMILY_CLASSES: Record<string, typeof PlanVortexError> = {\n auth: AuthError,\n user: UserError,\n account: AccountError,\n file: FileError,\n publication: PublicationError,\n organization: OrganizationError,\n plan_limit: PlanLimitError,\n messaging: MessagingError,\n contact: ContactError,\n product: ProductError,\n ai_plan: AiPlanError,\n integration: IntegrationError,\n};\n\n/** El cuerpo de error del API: `{code, message, data}`. */\nexport interface ApiErrorBody {\n code: number;\n message?: string;\n data?: Record<string, unknown>;\n}\n\nfunction isApiErrorBody(body: unknown): body is ApiErrorBody {\n return typeof body === \"object\" && body !== null && typeof (body as ApiErrorBody).code === \"number\";\n}\n\n/**\n * Convierte una respuesta de error en la clase que le toca.\n *\n * Un cuerpo sin `code` —un 502 de un proxy, la página HTML de un balanceador— no es un error de\n * dominio: sale como clase base con `family: \"http\"` y el cuerpo entero en `data`, que es además lo\n * que necesita `auth.ts` para reconocer el `{error, error_description}` de OAuth2.\n */\nexport function createErrorFromResponse(input: {\n body: unknown;\n status: number;\n requestId?: string | undefined;\n retryAfter?: number | undefined;\n}): PlanVortexError {\n const options: PlanVortexErrorOptions = {\n status: input.status,\n ...(input.requestId === undefined ? {} : { requestId: input.requestId }),\n ...(input.retryAfter === undefined ? {} : { retryAfter: input.retryAfter }),\n };\n\n if (isApiErrorBody(input.body)) {\n const family = errorFamilyForCode(input.body.code);\n const ErrorClass = (family === undefined ? undefined : FAMILY_CLASSES[family]) ?? PlanVortexError;\n return new ErrorClass(input.body.code, input.body.message ?? \"PlanVortex error\", {\n ...options,\n data: input.body.data ?? {},\n });\n }\n\n return new PlanVortexError(NO_ERROR_CODE, `HTTP ${input.status}`, {\n ...options,\n family: \"http\",\n data:\n typeof input.body === \"object\" && input.body !== null\n ? (input.body as Record<string, unknown>)\n : { body: input.body },\n });\n}\n\n/** ¿Es un error de esta librería? Útil en un `catch` donde no apetece importar la clase. */\nexport function isPlanVortexError(error: unknown): error is PlanVortexError {\n return error instanceof PlanVortexError;\n}\n\n/**\n * ¿Dice este error que el token ya no sirve? (los códigos 501 y 522, los dos dentro de un 400).\n *\n * Es lo que dispara el único reintento con token nuevo del cliente.\n */\nexport function isTokenError(error: unknown): boolean {\n return isPlanVortexError(error) && TOKEN_ERROR_CODES.includes(error.code);\n}\n"]}
@@ -2530,7 +2530,9 @@ interface paths {
2530
2530
  put?: never;
2531
2531
  /**
2532
2532
  * Upload new file
2533
- * @description Upload new file to the received organization
2533
+ * @description Upload a new file to the received organization.
2534
+ *
2535
+ * **Made with AI.** Send `ai_generated` as `true` to declare it, or `false` to say it is not. Leave it out and the file decides: if its C2PA manifest or IPTC metadata says it was generated or edited with AI, it is stored marked with `source: "detected"` (see `AiImageOrigin`). The mark is read before any conversion, and the file is stored as it came.
2534
2536
  */
2535
2537
  post: operations["addUpload"];
2536
2538
  delete?: never;
@@ -2553,7 +2555,9 @@ interface paths {
2553
2555
  get: operations["getUpload"];
2554
2556
  /**
2555
2557
  * Update file by identifier
2556
- * @description Update file by identifier
2558
+ * @description Update an uploaded file: its cover, and whether it is made with AI. Only the properties sent are changed.
2559
+ *
2560
+ * **Made with AI.** `{"ai_generated": true}` marks it (`source: "user"`), `{"ai_generated": false}` unmarks it. What PlanVortex's planner generated cannot be unmarked (`811`). Changing the mark also updates `ai_generated.image` on the publications that use the file and have not been sent yet.
2557
2561
  */
2558
2562
  put: operations["updateUpload"];
2559
2563
  post?: never;
@@ -2585,6 +2589,8 @@ interface paths {
2585
2589
  * **The response is deliberately partial**: `uploads` carries what got in and `errors` what did not, so picking six files and getting five plus one named failure is the normal, expected outcome — not an error.
2586
2590
  *
2587
2591
  * Requires the `files:create` permission (`client_organization_files:create` for apps).
2592
+ *
2593
+ * The AI mark is read from each file before the HEIC conversion, as on upload (see `AiImageOrigin`). A wrong `ai_generated` on one file is reported for that file in `errors` (`812`).
2588
2594
  */
2589
2595
  post: operations["importUploads"];
2590
2596
  delete?: never;
@@ -3127,21 +3133,52 @@ interface components {
3127
3133
  website?: string;
3128
3134
  };
3129
3135
  /**
3130
- * @description Where an AI-generated image came from. **Only images a model generated carry it**: a photo the organization uploaded, a product photo pulled from a connected shop or an image imported from an integration never does.
3136
+ * @description Marks a file as made or retouched with AI, and says who says so (`source`):
3137
+ *
3138
+ * - `planvortex`: generated by the PlanVortex AI planner. It carries `provider`, `model`, `generated_at` and `id_ai_plan`, and it **cannot be unmarked** (error `811`).
3139
+ * - `user`: declared by whoever uploaded it, with `ai_generated: true` on upload or later with `PUT`. `tool` is the tool they named, if any.
3140
+ * - `detected`: the file said so itself when it was uploaded. Its C2PA manifest or its IPTC metadata carried the digital source type `trainedAlgorithmicMedia` (generated) or `compositeWithTrainedAlgorithmicMedia` (edited with AI). PlanVortex reads what the generator declared and does not guess: it cannot see invisible watermarks such as SynthID, nor metadata already stripped (screenshots, files forwarded through messaging apps, many editors). A C2PA manifest that says the photo came from a camera is not marked.
3131
3141
  *
3132
- * It is set when the image is generated and cannot be edited. Use it to show your own AI label: under article 50(4) of the EU AI Act, telling the audience that an image is AI-generated is the job of whoever publishes it.
3142
+ * `user` and `detected` can be unmarked with `PUT .../uploads/{id_upload}` and `{"ai_generated": false}`. Absent means nobody says the file was made with AI.
3133
3143
  *
3134
- * Images made with the default model also carry a signed C2PA manifest, IPTC metadata and a SynthID watermark in the file itself. PlanVortex keeps the IPTC marker when it crops or recompresses an image for a network; the C2PA signature does not survive a change of pixels.
3144
+ * What the mark does: TikTok receives `is_aigc` and shows its «Creator labeled as AI-generated» label; when PlanVortex crops or recompresses an image for a network it writes the IPTC marker back, which is what Meta, LinkedIn and Pinterest read; and `Publication.ai_generated.image` follows it, also on publications not sent yet when the mark changes. Use it to show your own AI label: under article 50(4) of the EU AI Act, telling the audience is the job of whoever publishes.
3145
+ *
3146
+ * Images made with the planner's default model also carry a signed C2PA manifest, IPTC metadata and a SynthID watermark in the file itself. The C2PA signature does not survive a change of pixels.
3135
3147
  */
3136
3148
  AiImageOrigin: {
3137
- /** Format: date-time */
3138
- generated_at: string;
3139
- /** @description The AI plan that generated it. */
3149
+ /**
3150
+ * @description The IPTC term the file carried: generated with AI, or edited with AI.
3151
+ * @enum {string}
3152
+ */
3153
+ digital_source_type?: "trainedAlgorithmicMedia" | "compositeWithTrainedAlgorithmicMedia";
3154
+ /**
3155
+ * @description Where the file carried the mark: a C2PA manifest or the IPTC metadata. Present on `detected`, and on `user` when the file also carried one.
3156
+ * @enum {string}
3157
+ */
3158
+ found_in?: "c2pa" | "iptc";
3159
+ /**
3160
+ * Format: date-time
3161
+ * @description `planvortex` only: when it was generated.
3162
+ */
3163
+ generated_at?: string;
3164
+ /** @description `planvortex` only: the AI plan that generated it. */
3140
3165
  id_ai_plan?: string;
3141
- /** @description The model, as it was requested, for instance `google/gemini-3.1-flash-image`. */
3142
- model: string;
3143
- /** @description The AI provider that answered: `openrouter` unless the client brought its own key. */
3144
- provider: string;
3166
+ /**
3167
+ * Format: date-time
3168
+ * @description `user` and `detected`: when it was marked.
3169
+ */
3170
+ marked_at?: string;
3171
+ /** @description `planvortex` only: the model, as it was requested, for instance `google/gemini-3.1-flash-image`. */
3172
+ model?: string;
3173
+ /** @description `planvortex` only: the AI provider that answered, `openrouter` unless the client brought its own key. */
3174
+ provider?: string;
3175
+ /**
3176
+ * @description Who says the file was made with AI.
3177
+ * @enum {string}
3178
+ */
3179
+ source: "planvortex" | "user" | "detected";
3180
+ /** @description `user` and `detected`: the tool, when it is known. What the person named («ElevenLabs»), or the software agent of the C2PA action («Adobe Firefly»). */
3181
+ tool?: string;
3145
3182
  };
3146
3183
  /**
3147
3184
  * @description What ONE AI plan achieved with what it published.
@@ -4490,7 +4527,7 @@ interface components {
4490
4527
  * The catalogue grows with the product, so treat an unknown `code` as a generic failure instead of rejecting it.
4491
4528
  */
4492
4529
  Error: {
4493
- /** @description PlanVortex error code. Ranges: 500-554 auth, tokens, client apps and connect sessions · 601-612 user · 700-716 social accounts · 800-810 files · 900-996 publications · 1000-1003 general · 1100-1111 organizations · 1200-1207 roles · 1300-1309 client plan · 1400-1408 organization plan · 1500-1517 messaging · 1600-1601 contacts · 1900-1906 payments · 2000-2099 products · 2100-2199 AI plans · 2200-2299 integrations · 2500-2599 publication fields, the ones that no longer fit in 900-996 (visibility, made for kids, TikTok's interactions and commercial content) · 2600-2699 comments, the ones that no longer fit in 945-948 · 2700-2799 Discord · 2800-2899 TikTok comments, the ones that go through TikTok API for Business. */
4530
+ /** @description PlanVortex error code. Ranges: 500-554 auth, tokens, client apps and connect sessions · 601-612 user · 700-716 social accounts · 800-812 files · 900-996 publications · 1000-1003 general · 1100-1111 organizations · 1200-1207 roles · 1300-1309 client plan · 1400-1408 organization plan · 1500-1517 messaging · 1600-1601 contacts · 1900-1906 payments · 2000-2099 products · 2100-2199 AI plans · 2200-2299 integrations · 2500-2599 publication fields, the ones that no longer fit in 900-996 (visibility, made for kids, TikTok's interactions and commercial content) · 2600-2699 comments, the ones that no longer fit in 945-948 · 2700-2799 Discord · 2800-2899 TikTok comments, the ones that go through TikTok API for Business. */
4494
4531
  code: number;
4495
4532
  /** @description Extra context attached to the error, when there is any. */
4496
4533
  data?: {
@@ -12358,6 +12395,13 @@ interface operations {
12358
12395
  requestBody: {
12359
12396
  content: {
12360
12397
  "multipart/form-data": {
12398
+ /**
12399
+ * @description Optional. `true`: made or retouched with AI (`source: "user"`). `false`: not, even if the file's metadata says otherwise. Absent: the file's metadata decides. Any other value is error `812`, and nothing is stored.
12400
+ * @enum {string}
12401
+ */
12402
+ ai_generated?: "true" | "false";
12403
+ /** @description Optional: the AI tool, for instance `ElevenLabs`. Stored as `ai_generated.tool`. */
12404
+ ai_tool?: string;
12361
12405
  /**
12362
12406
  * Format: binary
12363
12407
  * @description file uploaded as multipart/formdata
@@ -12391,6 +12435,7 @@ interface operations {
12391
12435
  * | `809` | Only videos con have a thumbnail image |
12392
12436
  * | `810` | Thumbnail must be an image |
12393
12437
  * | `523` | Invalid application |
12438
+ * | `812` | Invalid AI declaration: `ai_generated` must be true or false, and `ai_tool` a text of up to 100 characters |
12394
12439
  */
12395
12440
  400: {
12396
12441
  headers: {
@@ -12473,9 +12518,13 @@ interface operations {
12473
12518
  requestBody: {
12474
12519
  content: {
12475
12520
  "application/json": {
12521
+ /** @description `true`: made or retouched with AI. `false`: not (error `811` if PlanVortex generated it). An object here, such as the upload's own `ai_generated` sent back unchanged, is ignored. */
12522
+ ai_generated?: boolean;
12523
+ /** @description Optional: the AI tool, for instance `ElevenLabs`. Stored as `ai_generated.tool`. */
12524
+ ai_tool?: string;
12476
12525
  /** @description Identifier of ANOTHER upload, which must be an image, to use as the cover. Returns error 810 if it does not exist or is not an image. Replacing an existing cover deletes the previous file. */
12477
12526
  cover_image?: string;
12478
- /** @description Point of the video, in milliseconds, used as the cover frame. Used by TikTok videos. WARNING: this property is written unconditionally, so omitting it clears the stored value - always send it back if you want to keep it. */
12527
+ /** @description Point of the video, in milliseconds, used as the cover frame. Used by TikTok videos. Only changed when sent. */
12479
12528
  cover_offset?: number;
12480
12529
  };
12481
12530
  };
@@ -12500,6 +12549,8 @@ interface operations {
12500
12549
  * | `809` | Only videos con have a thumbnail image |
12501
12550
  * | `810` | Thumbnail must be an image |
12502
12551
  * | `523` | Invalid application |
12552
+ * | `811` | This file was generated with AI by PlanVortex and cannot be unmarked |
12553
+ * | `812` | Invalid AI declaration: `ai_generated` must be true or false, and `ai_tool` a text of up to 100 characters |
12503
12554
  */
12504
12555
  400: {
12505
12556
  headers: {
@@ -12583,7 +12634,15 @@ interface operations {
12583
12634
  requestBody: {
12584
12635
  content: {
12585
12636
  "application/json": {
12637
+ /** @description Optional: the AI mark for the whole batch, as on upload. `true` declares every file, `false` none; absent lets each file's metadata decide. A file can override it with its own `ai_generated`. */
12638
+ ai_generated?: boolean;
12639
+ /** @description Optional: the AI tool, for instance `ElevenLabs`. Stored as `ai_generated.tool`. */
12640
+ ai_tool?: string;
12586
12641
  files: {
12642
+ /** @description Optional: the AI mark of this file. Wins over the batch's. */
12643
+ ai_generated?: boolean;
12644
+ /** @description Optional: the AI tool, for instance `ElevenLabs`. Stored as `ai_generated.tool`. */
12645
+ ai_tool?: string;
12587
12646
  /** @description File identifier at the provider (the Drive file id). */
12588
12647
  external_id: string;
12589
12648
  /** @description Type reported by the picker. Used to reject early; the real type of the body wins. */
@@ -13483,14 +13542,15 @@ type Upload = Override<Schemas["Upload"], {
13483
13542
  /** Ancho, alto, duracion y tamano de un fichero, mas en que redes cabe **por su recorte**. */
13484
13543
  type FileProperties = Schemas["FileProperties"];
13485
13544
  /**
13486
- * De que modelo salio una imagen: el `ai_generated` de un {@link Upload}. **Solo lo llevan las
13487
- * imagenes que genero la IA** —nunca una foto subida, ni la de un producto de una tienda— y no se
13488
- * puede editar.
13545
+ * Que un fichero esta hecho o retocado con IA, y quien lo dice: el `ai_generated` de un {@link Upload}.
13546
+ * `source` es `planvortex` (lo genero el planificador; no se puede quitar), `user` (lo declaro quien
13547
+ * lo subio) o `detected` (el propio fichero lo decia al subirlo, en su C2PA o en su XMP de IPTC).
13548
+ * Ausente = nadie dice que lo sea. Se marca y se desmarca con `uploads.update(..., { ai_generated })`.
13489
13549
  *
13490
13550
  * Es lo que necesitas para cumplir TU parte del AI Act: el articulo 50.4 obliga a quien publica a
13491
13551
  * avisar a su audiencia cuando una imagen generada puede pasar por real, y con este campo pintas la
13492
- * etiqueta en tu producto. La marca en el propio fichero (C2PA, IPTC y SynthID con el modelo por
13493
- * defecto) la pone PlanVortex; el C2PA no sobrevive a un recorte, el IPTC si.
13552
+ * etiqueta en tu producto. TikTok lo recibe como `is_aigc`, y al recortar una imagen PlanVortex
13553
+ * repone el IPTC; el C2PA no sobrevive a un recorte.
13494
13554
  */
13495
13555
  type AiImageOrigin = Schemas["AiImageOrigin"];
13496
13556
  /**
@@ -14229,7 +14289,7 @@ declare class UserError extends PlanVortexError {
14229
14289
  /** 700-716 — cuentas sociales: desconectada, sin permisos en la red, sin refrescar. */
14230
14290
  declare class AccountError extends PlanVortexError {
14231
14291
  }
14232
- /** 800-810 — ficheros: formato no admitido, demasiado grande, conversión fallida. */
14292
+ /** 800-812 — ficheros: formato no admitido, demasiado grande, conversión fallida, y la marca de IA (811, 812). */
14233
14293
  declare class FileError extends PlanVortexError {
14234
14294
  }
14235
14295
  /** 900-996 — publicaciones, incluidos los límites por red (caracteres, imágenes, duración), los
@@ -2530,7 +2530,9 @@ interface paths {
2530
2530
  put?: never;
2531
2531
  /**
2532
2532
  * Upload new file
2533
- * @description Upload new file to the received organization
2533
+ * @description Upload a new file to the received organization.
2534
+ *
2535
+ * **Made with AI.** Send `ai_generated` as `true` to declare it, or `false` to say it is not. Leave it out and the file decides: if its C2PA manifest or IPTC metadata says it was generated or edited with AI, it is stored marked with `source: "detected"` (see `AiImageOrigin`). The mark is read before any conversion, and the file is stored as it came.
2534
2536
  */
2535
2537
  post: operations["addUpload"];
2536
2538
  delete?: never;
@@ -2553,7 +2555,9 @@ interface paths {
2553
2555
  get: operations["getUpload"];
2554
2556
  /**
2555
2557
  * Update file by identifier
2556
- * @description Update file by identifier
2558
+ * @description Update an uploaded file: its cover, and whether it is made with AI. Only the properties sent are changed.
2559
+ *
2560
+ * **Made with AI.** `{"ai_generated": true}` marks it (`source: "user"`), `{"ai_generated": false}` unmarks it. What PlanVortex's planner generated cannot be unmarked (`811`). Changing the mark also updates `ai_generated.image` on the publications that use the file and have not been sent yet.
2557
2561
  */
2558
2562
  put: operations["updateUpload"];
2559
2563
  post?: never;
@@ -2585,6 +2589,8 @@ interface paths {
2585
2589
  * **The response is deliberately partial**: `uploads` carries what got in and `errors` what did not, so picking six files and getting five plus one named failure is the normal, expected outcome — not an error.
2586
2590
  *
2587
2591
  * Requires the `files:create` permission (`client_organization_files:create` for apps).
2592
+ *
2593
+ * The AI mark is read from each file before the HEIC conversion, as on upload (see `AiImageOrigin`). A wrong `ai_generated` on one file is reported for that file in `errors` (`812`).
2588
2594
  */
2589
2595
  post: operations["importUploads"];
2590
2596
  delete?: never;
@@ -3127,21 +3133,52 @@ interface components {
3127
3133
  website?: string;
3128
3134
  };
3129
3135
  /**
3130
- * @description Where an AI-generated image came from. **Only images a model generated carry it**: a photo the organization uploaded, a product photo pulled from a connected shop or an image imported from an integration never does.
3136
+ * @description Marks a file as made or retouched with AI, and says who says so (`source`):
3137
+ *
3138
+ * - `planvortex`: generated by the PlanVortex AI planner. It carries `provider`, `model`, `generated_at` and `id_ai_plan`, and it **cannot be unmarked** (error `811`).
3139
+ * - `user`: declared by whoever uploaded it, with `ai_generated: true` on upload or later with `PUT`. `tool` is the tool they named, if any.
3140
+ * - `detected`: the file said so itself when it was uploaded. Its C2PA manifest or its IPTC metadata carried the digital source type `trainedAlgorithmicMedia` (generated) or `compositeWithTrainedAlgorithmicMedia` (edited with AI). PlanVortex reads what the generator declared and does not guess: it cannot see invisible watermarks such as SynthID, nor metadata already stripped (screenshots, files forwarded through messaging apps, many editors). A C2PA manifest that says the photo came from a camera is not marked.
3131
3141
  *
3132
- * It is set when the image is generated and cannot be edited. Use it to show your own AI label: under article 50(4) of the EU AI Act, telling the audience that an image is AI-generated is the job of whoever publishes it.
3142
+ * `user` and `detected` can be unmarked with `PUT .../uploads/{id_upload}` and `{"ai_generated": false}`. Absent means nobody says the file was made with AI.
3133
3143
  *
3134
- * Images made with the default model also carry a signed C2PA manifest, IPTC metadata and a SynthID watermark in the file itself. PlanVortex keeps the IPTC marker when it crops or recompresses an image for a network; the C2PA signature does not survive a change of pixels.
3144
+ * What the mark does: TikTok receives `is_aigc` and shows its «Creator labeled as AI-generated» label; when PlanVortex crops or recompresses an image for a network it writes the IPTC marker back, which is what Meta, LinkedIn and Pinterest read; and `Publication.ai_generated.image` follows it, also on publications not sent yet when the mark changes. Use it to show your own AI label: under article 50(4) of the EU AI Act, telling the audience is the job of whoever publishes.
3145
+ *
3146
+ * Images made with the planner's default model also carry a signed C2PA manifest, IPTC metadata and a SynthID watermark in the file itself. The C2PA signature does not survive a change of pixels.
3135
3147
  */
3136
3148
  AiImageOrigin: {
3137
- /** Format: date-time */
3138
- generated_at: string;
3139
- /** @description The AI plan that generated it. */
3149
+ /**
3150
+ * @description The IPTC term the file carried: generated with AI, or edited with AI.
3151
+ * @enum {string}
3152
+ */
3153
+ digital_source_type?: "trainedAlgorithmicMedia" | "compositeWithTrainedAlgorithmicMedia";
3154
+ /**
3155
+ * @description Where the file carried the mark: a C2PA manifest or the IPTC metadata. Present on `detected`, and on `user` when the file also carried one.
3156
+ * @enum {string}
3157
+ */
3158
+ found_in?: "c2pa" | "iptc";
3159
+ /**
3160
+ * Format: date-time
3161
+ * @description `planvortex` only: when it was generated.
3162
+ */
3163
+ generated_at?: string;
3164
+ /** @description `planvortex` only: the AI plan that generated it. */
3140
3165
  id_ai_plan?: string;
3141
- /** @description The model, as it was requested, for instance `google/gemini-3.1-flash-image`. */
3142
- model: string;
3143
- /** @description The AI provider that answered: `openrouter` unless the client brought its own key. */
3144
- provider: string;
3166
+ /**
3167
+ * Format: date-time
3168
+ * @description `user` and `detected`: when it was marked.
3169
+ */
3170
+ marked_at?: string;
3171
+ /** @description `planvortex` only: the model, as it was requested, for instance `google/gemini-3.1-flash-image`. */
3172
+ model?: string;
3173
+ /** @description `planvortex` only: the AI provider that answered, `openrouter` unless the client brought its own key. */
3174
+ provider?: string;
3175
+ /**
3176
+ * @description Who says the file was made with AI.
3177
+ * @enum {string}
3178
+ */
3179
+ source: "planvortex" | "user" | "detected";
3180
+ /** @description `user` and `detected`: the tool, when it is known. What the person named («ElevenLabs»), or the software agent of the C2PA action («Adobe Firefly»). */
3181
+ tool?: string;
3145
3182
  };
3146
3183
  /**
3147
3184
  * @description What ONE AI plan achieved with what it published.
@@ -4490,7 +4527,7 @@ interface components {
4490
4527
  * The catalogue grows with the product, so treat an unknown `code` as a generic failure instead of rejecting it.
4491
4528
  */
4492
4529
  Error: {
4493
- /** @description PlanVortex error code. Ranges: 500-554 auth, tokens, client apps and connect sessions · 601-612 user · 700-716 social accounts · 800-810 files · 900-996 publications · 1000-1003 general · 1100-1111 organizations · 1200-1207 roles · 1300-1309 client plan · 1400-1408 organization plan · 1500-1517 messaging · 1600-1601 contacts · 1900-1906 payments · 2000-2099 products · 2100-2199 AI plans · 2200-2299 integrations · 2500-2599 publication fields, the ones that no longer fit in 900-996 (visibility, made for kids, TikTok's interactions and commercial content) · 2600-2699 comments, the ones that no longer fit in 945-948 · 2700-2799 Discord · 2800-2899 TikTok comments, the ones that go through TikTok API for Business. */
4530
+ /** @description PlanVortex error code. Ranges: 500-554 auth, tokens, client apps and connect sessions · 601-612 user · 700-716 social accounts · 800-812 files · 900-996 publications · 1000-1003 general · 1100-1111 organizations · 1200-1207 roles · 1300-1309 client plan · 1400-1408 organization plan · 1500-1517 messaging · 1600-1601 contacts · 1900-1906 payments · 2000-2099 products · 2100-2199 AI plans · 2200-2299 integrations · 2500-2599 publication fields, the ones that no longer fit in 900-996 (visibility, made for kids, TikTok's interactions and commercial content) · 2600-2699 comments, the ones that no longer fit in 945-948 · 2700-2799 Discord · 2800-2899 TikTok comments, the ones that go through TikTok API for Business. */
4494
4531
  code: number;
4495
4532
  /** @description Extra context attached to the error, when there is any. */
4496
4533
  data?: {
@@ -12358,6 +12395,13 @@ interface operations {
12358
12395
  requestBody: {
12359
12396
  content: {
12360
12397
  "multipart/form-data": {
12398
+ /**
12399
+ * @description Optional. `true`: made or retouched with AI (`source: "user"`). `false`: not, even if the file's metadata says otherwise. Absent: the file's metadata decides. Any other value is error `812`, and nothing is stored.
12400
+ * @enum {string}
12401
+ */
12402
+ ai_generated?: "true" | "false";
12403
+ /** @description Optional: the AI tool, for instance `ElevenLabs`. Stored as `ai_generated.tool`. */
12404
+ ai_tool?: string;
12361
12405
  /**
12362
12406
  * Format: binary
12363
12407
  * @description file uploaded as multipart/formdata
@@ -12391,6 +12435,7 @@ interface operations {
12391
12435
  * | `809` | Only videos con have a thumbnail image |
12392
12436
  * | `810` | Thumbnail must be an image |
12393
12437
  * | `523` | Invalid application |
12438
+ * | `812` | Invalid AI declaration: `ai_generated` must be true or false, and `ai_tool` a text of up to 100 characters |
12394
12439
  */
12395
12440
  400: {
12396
12441
  headers: {
@@ -12473,9 +12518,13 @@ interface operations {
12473
12518
  requestBody: {
12474
12519
  content: {
12475
12520
  "application/json": {
12521
+ /** @description `true`: made or retouched with AI. `false`: not (error `811` if PlanVortex generated it). An object here, such as the upload's own `ai_generated` sent back unchanged, is ignored. */
12522
+ ai_generated?: boolean;
12523
+ /** @description Optional: the AI tool, for instance `ElevenLabs`. Stored as `ai_generated.tool`. */
12524
+ ai_tool?: string;
12476
12525
  /** @description Identifier of ANOTHER upload, which must be an image, to use as the cover. Returns error 810 if it does not exist or is not an image. Replacing an existing cover deletes the previous file. */
12477
12526
  cover_image?: string;
12478
- /** @description Point of the video, in milliseconds, used as the cover frame. Used by TikTok videos. WARNING: this property is written unconditionally, so omitting it clears the stored value - always send it back if you want to keep it. */
12527
+ /** @description Point of the video, in milliseconds, used as the cover frame. Used by TikTok videos. Only changed when sent. */
12479
12528
  cover_offset?: number;
12480
12529
  };
12481
12530
  };
@@ -12500,6 +12549,8 @@ interface operations {
12500
12549
  * | `809` | Only videos con have a thumbnail image |
12501
12550
  * | `810` | Thumbnail must be an image |
12502
12551
  * | `523` | Invalid application |
12552
+ * | `811` | This file was generated with AI by PlanVortex and cannot be unmarked |
12553
+ * | `812` | Invalid AI declaration: `ai_generated` must be true or false, and `ai_tool` a text of up to 100 characters |
12503
12554
  */
12504
12555
  400: {
12505
12556
  headers: {
@@ -12583,7 +12634,15 @@ interface operations {
12583
12634
  requestBody: {
12584
12635
  content: {
12585
12636
  "application/json": {
12637
+ /** @description Optional: the AI mark for the whole batch, as on upload. `true` declares every file, `false` none; absent lets each file's metadata decide. A file can override it with its own `ai_generated`. */
12638
+ ai_generated?: boolean;
12639
+ /** @description Optional: the AI tool, for instance `ElevenLabs`. Stored as `ai_generated.tool`. */
12640
+ ai_tool?: string;
12586
12641
  files: {
12642
+ /** @description Optional: the AI mark of this file. Wins over the batch's. */
12643
+ ai_generated?: boolean;
12644
+ /** @description Optional: the AI tool, for instance `ElevenLabs`. Stored as `ai_generated.tool`. */
12645
+ ai_tool?: string;
12587
12646
  /** @description File identifier at the provider (the Drive file id). */
12588
12647
  external_id: string;
12589
12648
  /** @description Type reported by the picker. Used to reject early; the real type of the body wins. */
@@ -13483,14 +13542,15 @@ type Upload = Override<Schemas["Upload"], {
13483
13542
  /** Ancho, alto, duracion y tamano de un fichero, mas en que redes cabe **por su recorte**. */
13484
13543
  type FileProperties = Schemas["FileProperties"];
13485
13544
  /**
13486
- * De que modelo salio una imagen: el `ai_generated` de un {@link Upload}. **Solo lo llevan las
13487
- * imagenes que genero la IA** —nunca una foto subida, ni la de un producto de una tienda— y no se
13488
- * puede editar.
13545
+ * Que un fichero esta hecho o retocado con IA, y quien lo dice: el `ai_generated` de un {@link Upload}.
13546
+ * `source` es `planvortex` (lo genero el planificador; no se puede quitar), `user` (lo declaro quien
13547
+ * lo subio) o `detected` (el propio fichero lo decia al subirlo, en su C2PA o en su XMP de IPTC).
13548
+ * Ausente = nadie dice que lo sea. Se marca y se desmarca con `uploads.update(..., { ai_generated })`.
13489
13549
  *
13490
13550
  * Es lo que necesitas para cumplir TU parte del AI Act: el articulo 50.4 obliga a quien publica a
13491
13551
  * avisar a su audiencia cuando una imagen generada puede pasar por real, y con este campo pintas la
13492
- * etiqueta en tu producto. La marca en el propio fichero (C2PA, IPTC y SynthID con el modelo por
13493
- * defecto) la pone PlanVortex; el C2PA no sobrevive a un recorte, el IPTC si.
13552
+ * etiqueta en tu producto. TikTok lo recibe como `is_aigc`, y al recortar una imagen PlanVortex
13553
+ * repone el IPTC; el C2PA no sobrevive a un recorte.
13494
13554
  */
13495
13555
  type AiImageOrigin = Schemas["AiImageOrigin"];
13496
13556
  /**
@@ -14229,7 +14289,7 @@ declare class UserError extends PlanVortexError {
14229
14289
  /** 700-716 — cuentas sociales: desconectada, sin permisos en la red, sin refrescar. */
14230
14290
  declare class AccountError extends PlanVortexError {
14231
14291
  }
14232
- /** 800-810 — ficheros: formato no admitido, demasiado grande, conversión fallida. */
14292
+ /** 800-812 — ficheros: formato no admitido, demasiado grande, conversión fallida, y la marca de IA (811, 812). */
14233
14293
  declare class FileError extends PlanVortexError {
14234
14294
  }
14235
14295
  /** 900-996 — publicaciones, incluidos los límites por red (caracteres, imágenes, duración), los
package/dist/index.cjs CHANGED
@@ -4,7 +4,7 @@ var path = require('path');
4
4
 
5
5
  // src/version.ts
6
6
  var PLANVORTEX_API_URL = "https://api.planvortex.com/v1.0.0";
7
- var VERSION = "0.25.0";
7
+ var VERSION = "0.26.0";
8
8
 
9
9
  // src/core/errors.ts
10
10
  var PLANVORTEX_ERROR_RANGES = [
@@ -18,7 +18,9 @@ var PLANVORTEX_ERROR_RANGES = [
18
18
  //716: la sesion de Bluesky la esta renovando otro proceso. Es temporal, y fuera de familia no
19
19
  //habia forma de saber que la respuesta es reintentar.
20
20
  { from: 700, to: 716, family: "account" },
21
- { from: 800, to: 810, family: "file" },
21
+ //811-812: la marca de IA de un fichero (fase 39 del servidor): desmarcar lo que genero el
22
+ //planificador y una declaracion que no es ni true ni false.
23
+ { from: 800, to: 812, family: "file" },
22
24
  //El techo sube con el catalogo del servidor, y subir tarde no da un error: da un consejo
23
25
  //equivocado. Los codigos de Bluesky, Discord, Telegram y Threads (961-977) y los dos frenos
24
26
  //de ritmo de la fase de publicaciones ilimitadas (978, 979) nacieron por encima de 960 y
@@ -3044,10 +3046,21 @@ var UploadsResource = class extends Resource {
3044
3046
  * ```ts
3045
3047
  * await pv.uploads.create(orgId, { file: "./hogaza.jpg" });
3046
3048
  * await pv.uploads.create(orgId, { file: bytes, filename: "hogaza.jpg" });
3049
+ * // hecho con IA: TikTok lo recibe como `is_aigc`
3050
+ * await pv.uploads.create(orgId, { file: "./promo.mp4", ai_generated: true, ai_tool: "ElevenLabs" });
3047
3051
  * ```
3052
+ *
3053
+ * Sin `ai_generated`, decide el fichero: si trae la marca de IA en sus metadatos, vuelve con
3054
+ * `ai_generated.source === "detected"` (ver {@link AiDeclaration}).
3048
3055
  */
3049
3056
  async create(idOrganization, input, options = {}) {
3050
3057
  const form = await buildUploadForm(input);
3058
+ if (input.ai_generated !== void 0) {
3059
+ form.append("ai_generated", String(input.ai_generated));
3060
+ }
3061
+ if (input.ai_tool) {
3062
+ form.append("ai_tool", input.ai_tool);
3063
+ }
3051
3064
  return this.postOne(
3052
3065
  `/organizations/${requireId(idOrganization, "idOrganization")}/uploads`,
3053
3066
  "upload",
@@ -3077,7 +3090,14 @@ var UploadsResource = class extends Resource {
3077
3090
  async get(idOrganization, idUpload, options = {}) {
3078
3091
  return this.getOne(this.path(idOrganization, idUpload), "upload", void 0, options);
3079
3092
  }
3080
- /** Cambia la portada de un vídeo. Ojo con `cover_offset`: se escribe siempre (ver arriba). */
3093
+ /**
3094
+ * Cambia la portada de un vídeo o la marca de IA. Marcar o desmarcar recalcula también
3095
+ * `ai_generated.image` de las publicaciones que lo usan y aún no han salido.
3096
+ *
3097
+ * ```ts
3098
+ * await pv.uploads.update(orgId, uploadId, { ai_generated: true });
3099
+ * ```
3100
+ */
3081
3101
  async update(idOrganization, idUpload, body, options = {}) {
3082
3102
  return this.putOne(this.path(idOrganization, idUpload), "upload", body, options);
3083
3103
  }
@@ -3100,11 +3120,21 @@ var UploadsResource = class extends Resource {
3100
3120
  * La respuesta es PARCIAL a propósito: mira `errors` aunque `uploads` traiga algo — de seis
3101
3121
  * ficheros pueden entrar cuatro. Un `2204` significa que el proveedor no da los bytes: un
3102
3122
  * documento nativo de Google no tiene fichero que descargar.
3123
+ *
3124
+ * `ai_generated` y `ai_tool` en `options` valen para toda la tanda; cada fichero puede traer
3125
+ * los suyos, que mandan.
3103
3126
  */
3104
3127
  async import(idOrganization, idIntegration, files, options = {}) {
3128
+ const body = { id_integration: requireId(idIntegration, "idIntegration"), files };
3129
+ if (options.ai_generated !== void 0) {
3130
+ body.ai_generated = options.ai_generated;
3131
+ }
3132
+ if (options.ai_tool) {
3133
+ body.ai_tool = options.ai_tool;
3134
+ }
3105
3135
  return this.httpPost(
3106
3136
  `/organizations/${requireId(idOrganization, "idOrganization")}/uploads/import`,
3107
- { id_integration: requireId(idIntegration, "idIntegration"), files },
3137
+ body,
3108
3138
  options
3109
3139
  );
3110
3140
  }