@surnie/plugin-kit 0.2.0 → 0.2.2

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/cli.js CHANGED
@@ -281,13 +281,17 @@ var networkPermission = z.strictObject({
281
281
  "domains"
282
282
  )
283
283
  }).meta({ description: "Dominios a los que el plugin podr\xE1 llamar (por la recepci\xF3n). Solo el nombre: api.ejemplo.com." });
284
+ var mailPermission = z.strictObject({
285
+ kind: z.literal("mail"),
286
+ ...permissionBase
287
+ }).meta({ description: "Mandar correos desde la direcci\xF3n del proyecto (sus clientes, avisos\u2026), con l\xEDmites." });
284
288
  var fieldsPermission = z.strictObject({
285
289
  kind: z.literal("fields"),
286
290
  ...permissionBase,
287
291
  fields: z.record(z.string(), z.looseObject({ type: z.string() }))
288
292
  }).meta({ description: "Campos que el plugin a\xF1ade a colecciones del proyecto que elija el admin; con el prefijo del plugin." });
289
- var permissionSchema = z.discriminatedUnion("kind", [contentPermission, usersPermission, networkPermission, fieldsPermission], {
290
- error: "kind: content, users, network o fields."
293
+ var permissionSchema = z.discriminatedUnion("kind", [contentPermission, usersPermission, networkPermission, mailPermission, fieldsPermission], {
294
+ error: "kind: content, users, network, mail o fields."
291
295
  });
292
296
  var KEY = /^[a-z][a-zA-Z0-9]{0,39}$/;
293
297
  var keyOf = (what) => z.string().regex(KEY, { error: `${what}: letras y d\xEDgitos, empieza por min\xFAscula, hasta 40 (es el nombre en el c\xF3digo).` });
@@ -986,6 +990,7 @@ function grantedType(p) {
986
990
  if (p.kind === "content") return `{ kind: "content"; actions: (${union(p.actions)})[]; collections: SurnieGrantedCollection[] }`;
987
991
  if (p.kind === "fields") return `{ kind: "fields"; collections: { collection: string; label: string }[] }`;
988
992
  if (p.kind === "users") return `{ kind: "users"; fields: (${union(p.fields)})[] }`;
993
+ if (p.kind === "mail") return `{ kind: "mail" }`;
989
994
  return `{ kind: "network"; domains: (${union(p.domains)})[] }`;
990
995
  }
991
996
  function routeParams(path) {
@@ -1063,6 +1068,11 @@ function pluginTypes(m) {
1063
1068
  update(input: { collection: string; id?: string; data: Record<string, unknown>; locale?: string; rev?: number }): Promise<SurnieEntry>;
1064
1069
  delete(input: { collection: string; id: string }): Promise<{ ok: true }>;
1065
1070
  publish(input: { collection: string; id: string; locale: string; publish?: boolean }): Promise<{ ok: true }>;
1071
+ /**
1072
+ * \xBFvalue es la contrase\xF1a guardada en ese campo password? El hash nunca sale. Tiempo constante y
1073
+ * l\xEDmite de fallos por registro (10 en 15 minutos): limita t\xFA tambi\xE9n por IP en tu ruta de login.
1074
+ */
1075
+ verifyPassword(input: { collection: string; id: string; field: string; value: string; locale?: string }): Promise<boolean>;
1066
1076
  };`);
1067
1077
  }
1068
1078
  if (userFields.length) {
@@ -1081,6 +1091,13 @@ function pluginTypes(m) {
1081
1091
  permissions: {
1082
1092
  get(): Promise<SurniePermissions>;
1083
1093
  };`);
1094
+ if (all.some((p) => p.kind === "mail")) {
1095
+ api.push(` /** Correo con la direcci\xF3n del proyecto (si el admin te dio el permiso). Un correo por destinatario. */
1096
+ mail: {
1097
+ /** Hasta 10 destinatarios; text, html o los dos. Como mucho 500 correos por hora. */
1098
+ send(input: { to: string | string[]; subject: string; text?: string; html?: string }): Promise<{ sent: number }>;
1099
+ };`);
1100
+ }
1084
1101
  if (secrets.length) {
1085
1102
  api.push(` /** Los secretos que rellena el admin; null si no est\xE1 puesto. Nunca salen del servidor. */
1086
1103
  secrets: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surnie/plugin-kit",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Kit para escribir plugins de Surnie: manifiesto, compilación reproducible, firma e inspección.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  "acorn-walk": "8.3.4",
22
22
  "age-encryption": "0.3.1",
23
23
  "esbuild": "0.28.0",
24
- "zod": "4.4.3"
24
+ "zod": "4.6.7"
25
25
  },
26
26
  "engines": {
27
27
  "node": ">=22"
@@ -195,6 +195,33 @@
195
195
  "additionalProperties": false,
196
196
  "description": "Dominios a los que el plugin podrá llamar (por la recepción). Solo el nombre: api.ejemplo.com."
197
197
  },
198
+ {
199
+ "type": "object",
200
+ "properties": {
201
+ "kind": {
202
+ "type": "string",
203
+ "const": "mail"
204
+ },
205
+ "id": {
206
+ "type": "string",
207
+ "pattern": "^[a-z][a-zA-Z0-9]{0,39}$",
208
+ "description": "Id estable del permiso (no cambiarlo entre versiones): así se sabe qué es nuevo al actualizar."
209
+ },
210
+ "purpose": {
211
+ "type": "string",
212
+ "minLength": 1,
213
+ "maxLength": 200,
214
+ "description": "Para qué lo quiere el plugin, en una frase: el admin lo lee antes de aceptar."
215
+ }
216
+ },
217
+ "required": [
218
+ "kind",
219
+ "id",
220
+ "purpose"
221
+ ],
222
+ "additionalProperties": false,
223
+ "description": "Mandar correos desde la dirección del proyecto (sus clientes, avisos…), con límites."
224
+ },
198
225
  {
199
226
  "type": "object",
200
227
  "properties": {
@@ -371,6 +398,33 @@
371
398
  "additionalProperties": false,
372
399
  "description": "Dominios a los que el plugin podrá llamar (por la recepción). Solo el nombre: api.ejemplo.com."
373
400
  },
401
+ {
402
+ "type": "object",
403
+ "properties": {
404
+ "kind": {
405
+ "type": "string",
406
+ "const": "mail"
407
+ },
408
+ "id": {
409
+ "type": "string",
410
+ "pattern": "^[a-z][a-zA-Z0-9]{0,39}$",
411
+ "description": "Id estable del permiso (no cambiarlo entre versiones): así se sabe qué es nuevo al actualizar."
412
+ },
413
+ "purpose": {
414
+ "type": "string",
415
+ "minLength": 1,
416
+ "maxLength": 200,
417
+ "description": "Para qué lo quiere el plugin, en una frase: el admin lo lee antes de aceptar."
418
+ }
419
+ },
420
+ "required": [
421
+ "kind",
422
+ "id",
423
+ "purpose"
424
+ ],
425
+ "additionalProperties": false,
426
+ "description": "Mandar correos desde la dirección del proyecto (sus clientes, avisos…), con límites."
427
+ },
374
428
  {
375
429
  "type": "object",
376
430
  "properties": {
@@ -579,16 +633,10 @@
579
633
  },
580
634
  "default": {
581
635
  "description": "Valor por defecto (no en un secreto).",
582
- "anyOf": [
583
- {
584
- "type": "string"
585
- },
586
- {
587
- "type": "number"
588
- },
589
- {
590
- "type": "boolean"
591
- }
636
+ "type": [
637
+ "string",
638
+ "number",
639
+ "boolean"
592
640
  ]
593
641
  },
594
642
  "options": {