@kardalum/plugin-sdk 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/README.md +10 -0
  3. package/dist/admin-section-registry.d.ts +14 -5
  4. package/dist/admin-section-registry.js +14 -4
  5. package/dist/built-in-value-schemas.js +1 -1
  6. package/dist/built-ins.js +2 -2
  7. package/dist/capabilities.d.ts +8 -78
  8. package/dist/capabilities.js +23 -322
  9. package/dist/host-entry.d.ts +1 -1
  10. package/dist/host-entry.js +1 -1
  11. package/dist/index.d.ts +5 -5
  12. package/dist/index.js +13 -12
  13. package/dist/license-verdict-keys.d.ts +4 -3
  14. package/dist/license-verdict-keys.js +6 -5
  15. package/dist/manifest-entry.d.ts +3 -3
  16. package/dist/manifest-entry.js +2 -2
  17. package/dist/manifest-schema.d.ts +113 -56
  18. package/dist/manifest-schema.js +192 -295
  19. package/dist/manifest.d.ts +145 -112
  20. package/dist/manifest.js +13 -36
  21. package/dist/media/media-picker.js +21 -12
  22. package/dist/media/upload-error.d.ts +1 -1
  23. package/dist/media/upload-error.js +1 -1
  24. package/dist/plugin-context.d.ts +7 -0
  25. package/dist/plugin-context.js +7 -0
  26. package/dist/plugin-screen-context.d.ts +44 -3
  27. package/dist/plugin-screen-context.js +27 -2
  28. package/dist/read-all-pages.d.ts +23 -0
  29. package/dist/read-all-pages.js +30 -0
  30. package/dist/richtext/block-panel.js +6 -6
  31. package/dist/richtext/insert-menu.js +4 -4
  32. package/dist/richtext/style-listbox.js +4 -4
  33. package/dist/tokens/tokens.css +1 -0
  34. package/dist/tokens/tokens.json +2 -1
  35. package/dist/type-equality.d.ts +2 -0
  36. package/dist/type-equality.js +1 -0
  37. package/dist/views/content-list-view.js +2 -2
  38. package/dist/views/html-view.js +1 -1
  39. package/dist/views/image-view.js +24 -39
  40. package/dist/views/rich-text-view.js +3 -3
  41. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +12 -0
  42. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +19 -0
  43. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +43 -25
  44. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +60 -8
  45. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +90 -0
  46. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +33 -2
  47. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +22 -1
  48. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +50 -15
  49. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +204 -0
  50. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +134 -0
  51. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +5 -0
  52. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +18 -13
  53. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
  54. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +1 -1
  55. package/node_modules/@kardalum/api-schemas/dist/content-path.js +11 -7
  56. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +4 -0
  57. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -0
  58. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +1 -0
  59. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +2 -1
  60. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +143 -57
  61. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +110 -60
  62. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +1 -0
  63. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +2 -0
  64. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +1 -1
  65. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +67 -40
  66. package/node_modules/@kardalum/api-schemas/dist/index.js +35 -19
  67. package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.d.ts +4 -0
  68. package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.js +8 -0
  69. package/node_modules/@kardalum/api-schemas/dist/issue-list.d.ts +6 -0
  70. package/node_modules/@kardalum/api-schemas/dist/issue-list.js +6 -0
  71. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
  72. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
  73. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +356 -16
  74. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +93 -10
  75. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +10 -0
  76. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +38 -30
  77. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +2 -2
  78. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +1 -1
  79. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +6 -2
  80. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +8 -6
  81. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +69 -4
  82. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +4 -0
  83. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +76 -9
  84. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +84 -24
  85. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +17 -7
  86. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +18 -8
  87. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
  88. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
  89. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +597 -0
  90. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +503 -0
  91. package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +60 -0
  92. package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +116 -0
  93. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +82 -0
  94. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +228 -0
  95. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +33 -4
  96. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +28 -2
  97. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +11 -3
  98. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +17 -4
  99. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +58 -0
  100. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +198 -0
  101. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.d.ts +64 -0
  102. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.js +134 -0
  103. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +2 -0
  104. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +4 -0
  105. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +74 -0
  106. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +132 -0
  107. package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.d.ts +13 -0
  108. package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.js +15 -0
  109. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +8 -0
  110. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -4
  111. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
  112. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +17 -0
  113. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +13 -0
  114. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +44 -0
  115. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +97 -0
  116. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +126 -0
  117. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +70 -0
  118. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +36 -6
  119. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -5
  120. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +52 -33
  121. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +195 -56
  122. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +19 -3
  123. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +16 -0
  124. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
  125. package/node_modules/@kardalum/api-schemas/dist/strict-url.d.ts +12 -0
  126. package/node_modules/@kardalum/api-schemas/dist/strict-url.js +31 -0
  127. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +105 -1
  128. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +47 -7
  129. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +30 -2
  130. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +19 -5
  131. package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.d.ts +4 -0
  132. package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.js +29 -0
  133. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +15 -3
  134. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +8 -0
  135. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +19 -0
  136. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +22 -0
  137. package/node_modules/@kardalum/api-schemas/package.json +2 -2
  138. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -0
  139. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
  140. package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
  141. package/node_modules/@kardalum/design-tokens/dist/tokens.js +3 -0
  142. package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
  143. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -0
  144. package/node_modules/@kardalum/plugin-package/README.md +4 -1
  145. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +96 -0
  146. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +66 -0
  147. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
  148. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +346 -0
  149. package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +4 -0
  150. package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
  151. package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +25 -0
  152. package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +203 -0
  153. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +3 -0
  154. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +73 -0
  155. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +5 -0
  156. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +60 -0
  157. package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.d.ts +1 -0
  158. package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.js +2052 -0
  159. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.d.ts +2 -0
  160. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +51 -0
  161. package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +8 -0
  162. package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +7 -0
  163. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.d.ts +17 -0
  164. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +119 -0
  165. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +14 -0
  166. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +21 -0
  167. package/node_modules/@kardalum/plugin-package/dist/delivery/locales.d.ts +5 -0
  168. package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +148 -0
  169. package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.d.ts +5 -0
  170. package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.js +76 -0
  171. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.d.ts +22 -0
  172. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +133 -0
  173. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.d.ts +3 -0
  174. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +90 -0
  175. package/node_modules/@kardalum/plugin-package/dist/delivery/support.d.ts +24 -0
  176. package/node_modules/@kardalum/plugin-package/dist/delivery/support.js +55 -0
  177. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +6 -0
  178. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +158 -0
  179. package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +53 -0
  180. package/node_modules/@kardalum/plugin-package/dist/delivery/types.js +1 -0
  181. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +3 -2
  182. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +4 -2
  183. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +92 -3
  184. package/node_modules/@kardalum/plugin-package/dist/extract.js +251 -41
  185. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +11 -2
  186. package/node_modules/@kardalum/plugin-package/dist/index.js +8 -2
  187. package/node_modules/@kardalum/plugin-package/dist/manifest-entry.d.ts +5 -0
  188. package/node_modules/@kardalum/plugin-package/dist/manifest-entry.js +20 -0
  189. package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +3 -0
  190. package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +7 -0
  191. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +38 -1
  192. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +84 -16
  193. package/node_modules/@kardalum/plugin-package/dist/shipped-files.d.ts +39 -0
  194. package/node_modules/@kardalum/plugin-package/dist/shipped-files.js +133 -0
  195. package/node_modules/@kardalum/plugin-package/dist/shipped-locales.d.ts +7 -0
  196. package/node_modules/@kardalum/plugin-package/dist/shipped-locales.js +27 -0
  197. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +4 -6
  198. package/node_modules/@kardalum/plugin-package/dist/types.js +15 -1
  199. package/node_modules/@kardalum/plugin-package/package.json +9 -2
  200. package/node_modules/@kardalum/ui/dist/components/checkbox.js +2 -2
  201. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +2 -2
  202. package/node_modules/@kardalum/ui/dist/components/property-field.js +4 -1
  203. package/node_modules/@kardalum/ui/package.json +1 -1
  204. package/package.json +6 -6
@@ -1,19 +1,14 @@
1
1
  import { z } from "zod";
2
- export declare const ApiKeyScopeSchema: z.ZodEnum<{
3
- read: "read";
4
- write: "write";
5
- }>;
6
- export type ApiKeyScope = z.infer<typeof ApiKeyScopeSchema>;
7
2
  export declare const ApiKeySummarySchema: z.ZodObject<{
8
3
  id: z.ZodString;
9
4
  name: z.ZodString;
10
- scope: z.ZodEnum<{
11
- read: "read";
12
- write: "write";
13
- }>;
5
+ actions: z.ZodArray<z.ZodString>;
14
6
  createdAt: z.ZodString;
7
+ expiresAt: z.ZodNullable<z.ZodString>;
15
8
  lastUsedAt: z.ZodNullable<z.ZodString>;
16
9
  revokedAt: z.ZodNullable<z.ZodString>;
10
+ createdById: z.ZodNullable<z.ZodString>;
11
+ createdByName: z.ZodNullable<z.ZodString>;
17
12
  }, z.core.$strip>;
18
13
  export type ApiKeySummary = z.infer<typeof ApiKeySummarySchema>;
19
14
  export declare const ApiKeyListQuerySchema: z.ZodObject<{
@@ -25,51 +20,74 @@ export declare const ApiKeyListResponseSchema: z.ZodObject<{
25
20
  items: z.ZodArray<z.ZodObject<{
26
21
  id: z.ZodString;
27
22
  name: z.ZodString;
28
- scope: z.ZodEnum<{
29
- read: "read";
30
- write: "write";
31
- }>;
23
+ actions: z.ZodArray<z.ZodString>;
32
24
  createdAt: z.ZodString;
25
+ expiresAt: z.ZodNullable<z.ZodString>;
33
26
  lastUsedAt: z.ZodNullable<z.ZodString>;
34
27
  revokedAt: z.ZodNullable<z.ZodString>;
28
+ createdById: z.ZodNullable<z.ZodString>;
29
+ createdByName: z.ZodNullable<z.ZodString>;
35
30
  }, z.core.$strip>>;
36
31
  nextCursor: z.ZodNullable<z.ZodString>;
37
32
  }, z.core.$strip>;
38
33
  export type ApiKeyListResponse = z.infer<typeof ApiKeyListResponseSchema>;
34
+ /** The most actions one key may be created with: more than the vocabulary plus any plugin will hold. */
35
+ export declare const API_KEY_MAX_ACTIONS = 500;
39
36
  export declare const CreateApiKeyRequestSchema: z.ZodObject<{
40
37
  name: z.ZodString;
41
- scope: z.ZodDefault<z.ZodEnum<{
42
- read: "read";
43
- write: "write";
44
- }>>;
38
+ actions: z.ZodArray<z.ZodString>;
39
+ expiresAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
45
40
  }, z.core.$strip>;
46
41
  export type CreateApiKeyRequest = z.infer<typeof CreateApiKeyRequestSchema>;
47
42
  export declare const CreateApiKeyResponseSchema: z.ZodObject<{
48
43
  apiKey: z.ZodObject<{
49
44
  id: z.ZodString;
50
45
  name: z.ZodString;
51
- scope: z.ZodEnum<{
52
- read: "read";
53
- write: "write";
54
- }>;
46
+ actions: z.ZodArray<z.ZodString>;
55
47
  createdAt: z.ZodString;
48
+ expiresAt: z.ZodNullable<z.ZodString>;
56
49
  lastUsedAt: z.ZodNullable<z.ZodString>;
57
50
  revokedAt: z.ZodNullable<z.ZodString>;
51
+ createdById: z.ZodNullable<z.ZodString>;
52
+ createdByName: z.ZodNullable<z.ZodString>;
58
53
  }, z.core.$strip>;
59
54
  secret: z.ZodString;
60
55
  }, z.core.$strip>;
61
56
  export type CreateApiKeyResponse = z.infer<typeof CreateApiKeyResponseSchema>;
57
+ export declare const ApiKeyRefusalSchema: z.ZodObject<{
58
+ message: z.ZodString;
59
+ action: z.ZodString;
60
+ }, z.core.$strip>;
61
+ export type ApiKeyRefusal = z.infer<typeof ApiKeyRefusalSchema>;
62
+ export declare const ApiKeyCreateForbiddenSchema: z.ZodUnion<readonly [z.ZodObject<{
63
+ message: z.ZodString;
64
+ action: z.ZodString;
65
+ }, z.core.$strip>, z.ZodObject<{
66
+ message: z.ZodString;
67
+ }, z.core.$strip>]>;
62
68
  export declare const RevokeApiKeyResponseSchema: z.ZodObject<{
63
69
  apiKey: z.ZodObject<{
64
70
  id: z.ZodString;
65
71
  name: z.ZodString;
66
- scope: z.ZodEnum<{
67
- read: "read";
68
- write: "write";
69
- }>;
72
+ actions: z.ZodArray<z.ZodString>;
70
73
  createdAt: z.ZodString;
74
+ expiresAt: z.ZodNullable<z.ZodString>;
71
75
  lastUsedAt: z.ZodNullable<z.ZodString>;
72
76
  revokedAt: z.ZodNullable<z.ZodString>;
77
+ createdById: z.ZodNullable<z.ZodString>;
78
+ createdByName: z.ZodNullable<z.ZodString>;
73
79
  }, z.core.$strip>;
74
80
  }, z.core.$strip>;
75
81
  export type RevokeApiKeyResponse = z.infer<typeof RevokeApiKeyResponseSchema>;
82
+ export declare const API_KEY_PRESETS: readonly [{
83
+ readonly id: "read";
84
+ readonly actions: readonly ["content.read", "media.read", "documentTypes.read", "templates.read", "sites.read"];
85
+ }, {
86
+ readonly id: "readWrite";
87
+ readonly actions: readonly ["content.read", "media.read", "documentTypes.read", "templates.read", "sites.read", "content.create", "content.update", "content.publish", "content.delete", "media.create", "media.update", "media.delete"];
88
+ }];
89
+ export type ApiKeyPresetId = (typeof API_KEY_PRESETS)[number]["id"];
90
+ export declare const ApiKeyParamsSchema: z.ZodObject<{
91
+ id: z.ZodString;
92
+ }, z.core.$strip>;
93
+ export type ApiKeyParams = z.infer<typeof ApiKeyParamsSchema>;
@@ -1,16 +1,30 @@
1
1
  import { z } from "zod";
2
- // What a key is allowed to do on the public /api/v1 surface. "write"
3
- // implies read; "read" is the default so a key can never write by
4
- // accident (S182 — before it, any key could write).
5
- export const ApiKeyScopeSchema = z.enum(["read", "write"]);
6
- // What key management reads — never the keyHash, never the plaintext.
2
+ import { ActionStringSchema } from "./action.schema.js";
3
+ import { ApiErrorSchema } from "./api-error.schema.js";
4
+ // What key management reads: never the keyHash, never the plaintext.
7
5
  export const ApiKeySummarySchema = z.object({
8
6
  id: z.string().uuid(),
9
7
  name: z.string(),
10
- scope: ApiKeyScopeSchema,
8
+ // The actions the key was created with, sorted. Fixed at creation; a key made
9
+ // before S299 holds none.
10
+ actions: z.array(z.string()),
11
11
  createdAt: z.string().datetime(),
12
+ // The moment the key stops working, or null when it never expires.
13
+ expiresAt: z.string().datetime().nullable(),
12
14
  lastUsedAt: z.string().datetime().nullable(),
13
15
  revokedAt: z.string().datetime().nullable(),
16
+ // Who created it, or null when that user is gone or the key came from the ops script.
17
+ createdById: z.string().uuid().nullable(),
18
+ // The display name of the user `createdById` names, so the list can say who
19
+ // made a key instead of showing an editor a uuid. Nullable rather than
20
+ // optional, because the server always decides: null means there is no name to
21
+ // show, which covers a creator who is gone, a key the ops script made and a
22
+ // creator who never set a name (`User.name` is itself nullable).
23
+ //
24
+ // NAME ONLY, deliberately: never the email and never the role. Those live on
25
+ // GET /api/manage/v1/users, which needs users.read, and holding apiKeys.read does not
26
+ // imply it (the same rule MediaVersionSchema.createdByName follows).
27
+ createdByName: z.string().nullable(),
14
28
  });
15
29
  export const ApiKeyListQuerySchema = z.object({
16
30
  cursor: z.string().uuid().optional(),
@@ -21,16 +35,54 @@ export const ApiKeyListResponseSchema = z.object({
21
35
  // null = no more pages.
22
36
  nextCursor: z.string().uuid().nullable(),
23
37
  });
38
+ /** The most actions one key may be created with: more than the vocabulary plus any plugin will hold. */
39
+ export const API_KEY_MAX_ACTIONS = 500;
24
40
  export const CreateApiKeyRequestSchema = z.object({
25
41
  name: z.string().min(1).max(100),
26
- // Omitted = read. Write keys can create, save and publish content.
27
- scope: ApiKeyScopeSchema.default("read"),
42
+ // Chosen once: a key keeps exactly these. At least one, because a key that
43
+ // holds nothing can never be given anything.
44
+ actions: z.array(ActionStringSchema).min(1).max(API_KEY_MAX_ACTIONS),
45
+ // Optional; omitted or null means the key never expires.
46
+ expiresAt: z.string().datetime().nullable().default(null),
28
47
  });
29
48
  // The only response, anywhere, that ever carries the plaintext secret.
30
49
  export const CreateApiKeyResponseSchema = z.object({
31
50
  apiKey: ApiKeySummarySchema,
32
51
  secret: z.string(),
33
52
  });
53
+ // The 403 that creating a key answers when the creator does not hold an action
54
+ // the request names (the subset rule). `action` is the first such action, as its
55
+ // id, so a client can mark that row without reading the sentence. It has the
56
+ // shape of the node refusal (`message` plus `action`, node-access.schema.ts), and
57
+ // the admin's error class already reads `action` off any failed response.
58
+ export const ApiKeyRefusalSchema = ApiErrorSchema.extend({ action: ActionStringSchema });
59
+ // The route's whole 403: the subset refusal, or the gate's plain error (the
60
+ // creator's role no longer holds apiKeys.create). The refusal is listed first so
61
+ // it is the one a body with `action` serialises as (a plain object schema would
62
+ // strip `action`), the order ContentForbiddenSchema uses.
63
+ export const ApiKeyCreateForbiddenSchema = z.union([ApiKeyRefusalSchema, ApiErrorSchema]);
34
64
  export const RevokeApiKeyResponseSchema = z.object({
35
65
  apiKey: ApiKeySummarySchema,
36
66
  });
67
+ // S299: the two starting points the admin's key form offers, and the sets the
68
+ // old scopes reached: "read" was every GET under /api/v1 and GraphQL, "write"
69
+ // added every write route (content create, update, publish, delete; media
70
+ // upload, visibility, delete). Typed against the registered actions, so a
71
+ // mistyped string fails to compile. A preset is a convenience: a key stores the
72
+ // actions it was given, never the preset.
73
+ const READ_ACTIONS = ["content.read", "media.read", "documentTypes.read", "templates.read", "sites.read"];
74
+ const WRITE_ACTIONS = [
75
+ "content.create",
76
+ "content.update",
77
+ "content.publish",
78
+ "content.delete",
79
+ "media.create",
80
+ "media.update",
81
+ "media.delete",
82
+ ];
83
+ export const API_KEY_PRESETS = [
84
+ { id: "read", actions: READ_ACTIONS },
85
+ { id: "readWrite", actions: [...READ_ACTIONS, ...WRITE_ACTIONS] },
86
+ ];
87
+ // S301: the params of POST /api-keys/:id/revoke, moved here from the route file.
88
+ export const ApiKeyParamsSchema = z.object({ id: z.string().uuid() });
@@ -14,6 +14,11 @@ export declare const AssetTreeEntrySchema: z.ZodObject<{
14
14
  pluginId: z.ZodNullable<z.ZodString>;
15
15
  }, z.core.$strip>;
16
16
  export type AssetTreeEntry = z.infer<typeof AssetTreeEntrySchema>;
17
+ export declare const AssetTreeSkipSchema: z.ZodObject<{
18
+ path: z.ZodString;
19
+ reason: z.ZodString;
20
+ }, z.core.$strip>;
21
+ export type AssetTreeSkip = z.infer<typeof AssetTreeSkipSchema>;
17
22
  export declare const AssetTreeResponseSchema: z.ZodObject<{
18
23
  entries: z.ZodArray<z.ZodObject<{
19
24
  path: z.ZodString;
@@ -28,6 +33,10 @@ export declare const AssetTreeResponseSchema: z.ZodObject<{
28
33
  pluginId: z.ZodNullable<z.ZodString>;
29
34
  }, z.core.$strip>>;
30
35
  truncated: z.ZodBoolean;
36
+ skipped: z.ZodOptional<z.ZodArray<z.ZodObject<{
37
+ path: z.ZodString;
38
+ reason: z.ZodString;
39
+ }, z.core.$strip>>>;
31
40
  }, z.core.$strip>;
32
41
  export type AssetTreeResponse = z.infer<typeof AssetTreeResponseSchema>;
33
42
  export declare const AssetContentResponseSchema: z.ZodObject<{
@@ -87,3 +96,84 @@ export declare const AssetSyncReportSchema: z.ZodObject<{
87
96
  healed: z.ZodArray<z.ZodString>;
88
97
  }, z.core.$strip>;
89
98
  export type AssetSyncReport = z.infer<typeof AssetSyncReportSchema>;
99
+ export declare const AssetVersionParamsSchema: z.ZodObject<{
100
+ version: z.ZodCoercedNumber<unknown>;
101
+ }, z.core.$strip>;
102
+ export type AssetVersionParams = z.infer<typeof AssetVersionParamsSchema>;
103
+ export declare const AssetVersionListQuerySchema: z.ZodObject<{
104
+ cursor: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
105
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
106
+ path: z.ZodString;
107
+ }, z.core.$strip>;
108
+ export type AssetVersionListQuery = z.infer<typeof AssetVersionListQuerySchema>;
109
+ export declare const AssetVersionQuerySchema: z.ZodObject<{
110
+ path: z.ZodString;
111
+ }, z.core.$strip>;
112
+ export type AssetVersionQuery = z.infer<typeof AssetVersionQuerySchema>;
113
+ export declare const AssetVersionListResponseSchema: z.ZodObject<{
114
+ items: z.ZodArray<z.ZodObject<{
115
+ id: z.ZodString;
116
+ createdAt: z.ZodString;
117
+ source: z.ZodEnum<{
118
+ admin: "admin";
119
+ "plugin-install": "plugin-install";
120
+ "file-sync": "file-sync";
121
+ }>;
122
+ version: z.ZodNumber;
123
+ hash: z.ZodString;
124
+ assetId: z.ZodString;
125
+ }, z.core.$strict>>;
126
+ nextCursor: z.ZodNullable<z.ZodNumber>;
127
+ }, z.core.$strip>;
128
+ export type AssetVersionListResponse = z.infer<typeof AssetVersionListResponseSchema>;
129
+ export declare const AssetVersionResponseSchema: z.ZodObject<{
130
+ version: z.ZodObject<{
131
+ id: z.ZodString;
132
+ assetId: z.ZodString;
133
+ version: z.ZodNumber;
134
+ content: z.ZodString;
135
+ hash: z.ZodString;
136
+ source: z.ZodEnum<{
137
+ admin: "admin";
138
+ "plugin-install": "plugin-install";
139
+ "file-sync": "file-sync";
140
+ }>;
141
+ createdAt: z.ZodString;
142
+ }, z.core.$strict>;
143
+ }, z.core.$strip>;
144
+ export type AssetVersionResponse = z.infer<typeof AssetVersionResponseSchema>;
145
+ export declare const MakeAssetVersionCurrentRequestSchema: z.ZodObject<{
146
+ path: z.ZodString;
147
+ }, z.core.$strict>;
148
+ export type MakeAssetVersionCurrentRequest = z.infer<typeof MakeAssetVersionCurrentRequestSchema>;
149
+ export declare const RestoreAssetRequestSchema: z.ZodObject<{
150
+ path: z.ZodString;
151
+ id: z.ZodString;
152
+ }, z.core.$strict>;
153
+ export type RestoreAssetRequest = z.infer<typeof RestoreAssetRequestSchema>;
154
+ export declare const RestoreAssetResponseSchema: z.ZodObject<{
155
+ path: z.ZodString;
156
+ content: z.ZodString;
157
+ size: z.ZodNumber;
158
+ registered: z.ZodBoolean;
159
+ pluginId: z.ZodNullable<z.ZodString>;
160
+ version: z.ZodNullable<z.ZodNumber>;
161
+ foldedFile: z.ZodBoolean;
162
+ }, z.core.$strip>;
163
+ export type RestoreAssetResponse = z.infer<typeof RestoreAssetResponseSchema>;
164
+ export declare const AssetTrashListQuerySchema: z.ZodObject<{
165
+ cursor: z.ZodOptional<z.ZodString>;
166
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
167
+ }, z.core.$strip>;
168
+ export type AssetTrashListQuery = z.infer<typeof AssetTrashListQuerySchema>;
169
+ export declare const AssetTrashListResponseSchema: z.ZodObject<{
170
+ items: z.ZodArray<z.ZodObject<{
171
+ id: z.ZodString;
172
+ path: z.ZodString;
173
+ pluginId: z.ZodNullable<z.ZodString>;
174
+ currentVersion: z.ZodNumber;
175
+ deletedAt: z.ZodString;
176
+ }, z.core.$strict>>;
177
+ nextCursor: z.ZodNullable<z.ZodString>;
178
+ }, z.core.$strip>;
179
+ export type AssetTrashListResponse = z.infer<typeof AssetTrashListResponseSchema>;
@@ -1,5 +1,7 @@
1
1
  import { z } from "zod";
2
- import { AssetPathSchema, MAX_ASSET_CONTENT_BYTES } from "./asset.schema.js";
2
+ import { TrashCursorSchema } from "./trash-cursor.schema.js";
3
+ import { AssetPathSchema, AssetVersionMetaSchema, AssetVersionSchema, MAX_ASSET_CONTENT_BYTES, TrashedAssetSchema } from "./asset.schema.js";
4
+ import { VersionListQuerySchema } from "./content-api.schema.js";
3
5
  // S192 asset tree browser: caps mirror the content-tree pagination
4
6
  // philosophy (never load an unbounded subtree) even though the tree
5
7
  // walk itself isn't cursor-paginated — depth/entry caps bound the work.
@@ -14,9 +16,13 @@ export const AssetTreeEntrySchema = z.object({
14
16
  registered: z.boolean(),
15
17
  pluginId: z.string().min(1).nullable(),
16
18
  });
19
+ // S314j (D1, P2): a name under public/ the walk left out, with the rule of
20
+ // AssetPathSchema it broke. Present only when the walk left something out.
21
+ export const AssetTreeSkipSchema = z.object({ path: z.string(), reason: z.string() });
17
22
  export const AssetTreeResponseSchema = z.object({
18
23
  entries: z.array(AssetTreeEntrySchema),
19
24
  truncated: z.boolean(),
25
+ skipped: z.array(AssetTreeSkipSchema).optional(),
20
26
  });
21
27
  export const AssetContentResponseSchema = z.object({
22
28
  path: AssetPathSchema,
@@ -33,7 +39,7 @@ export const CreateAssetFolderRequestSchema = z.object({ path: AssetPathSchema }
33
39
  export const RenameAssetRequestSchema = z
34
40
  .object({ path: AssetPathSchema, newPath: AssetPathSchema })
35
41
  .strict();
36
- // DELETE /api/assets is a two-step confirm gate like content trash and
42
+ // DELETE /api/manage/v1/assets is a two-step confirm gate like content trash and
37
43
  // plugin uninstall: confirm is a literal "true" query string (not a
38
44
  // boolean) because query params are always strings on the wire.
39
45
  export const DeleteAssetQuerySchema = z.object({
@@ -58,3 +64,28 @@ export const AssetSyncReportSchema = z.object({
58
64
  updated: z.array(z.string()),
59
65
  healed: z.array(z.string()),
60
66
  });
67
+ // S314g (D5, P3): a registered text asset's history, addressed by its path as
68
+ // the other asset routes are. Same paging as the template history.
69
+ export const AssetVersionParamsSchema = z.object({ version: z.coerce.number().int().positive() });
70
+ export const AssetVersionListQuerySchema = VersionListQuerySchema.extend({ path: AssetPathSchema });
71
+ export const AssetVersionQuerySchema = z.object({ path: AssetPathSchema });
72
+ export const AssetVersionListResponseSchema = z.object({
73
+ items: z.array(AssetVersionMetaSchema),
74
+ nextCursor: z.number().int().positive().nullable(),
75
+ });
76
+ export const AssetVersionResponseSchema = z.object({ version: AssetVersionSchema });
77
+ export const MakeAssetVersionCurrentRequestSchema = z.object({ path: AssetPathSchema }).strict();
78
+ // The path D5 names, and the trashed row's id from the trash list: 0014 lets
79
+ // several trashed rows share one path, so the path alone cannot say which.
80
+ export const RestoreAssetRequestSchema = z.object({ path: AssetPathSchema, id: z.string().uuid() }).strict();
81
+ // The restore's answer: the asset's content response, and whether a file found
82
+ // at the path was kept as a file-sync version first (as RestoreTemplateResponse).
83
+ export const RestoreAssetResponseSchema = AssetContentResponseSchema.extend({ foldedFile: z.boolean() });
84
+ export const AssetTrashListQuerySchema = z.object({
85
+ cursor: TrashCursorSchema.optional(),
86
+ limit: z.coerce.number().int().min(1).max(100).default(50),
87
+ });
88
+ export const AssetTrashListResponseSchema = z.object({
89
+ items: z.array(TrashedAssetSchema),
90
+ nextCursor: z.string().nullable(),
91
+ });
@@ -15,10 +15,31 @@ export declare const AssetVersionSchema: z.ZodObject<{
15
15
  content: z.ZodString;
16
16
  hash: z.ZodString;
17
17
  source: z.ZodEnum<{
18
- "plugin-install": "plugin-install";
19
18
  admin: "admin";
19
+ "plugin-install": "plugin-install";
20
20
  "file-sync": "file-sync";
21
21
  }>;
22
22
  createdAt: z.ZodString;
23
23
  }, z.core.$strict>;
24
24
  export type AssetVersion = z.infer<typeof AssetVersionSchema>;
25
+ export declare const AssetVersionMetaSchema: z.ZodObject<{
26
+ id: z.ZodString;
27
+ createdAt: z.ZodString;
28
+ source: z.ZodEnum<{
29
+ admin: "admin";
30
+ "plugin-install": "plugin-install";
31
+ "file-sync": "file-sync";
32
+ }>;
33
+ version: z.ZodNumber;
34
+ hash: z.ZodString;
35
+ assetId: z.ZodString;
36
+ }, z.core.$strict>;
37
+ export type AssetVersionMeta = z.infer<typeof AssetVersionMetaSchema>;
38
+ export declare const TrashedAssetSchema: z.ZodObject<{
39
+ id: z.ZodString;
40
+ path: z.ZodString;
41
+ pluginId: z.ZodNullable<z.ZodString>;
42
+ currentVersion: z.ZodNumber;
43
+ deletedAt: z.ZodString;
44
+ }, z.core.$strict>;
45
+ export type TrashedAsset = z.infer<typeof TrashedAssetSchema>;
@@ -3,26 +3,57 @@ import { isReservedRootSlug } from "./reserved-slugs.js";
3
3
  import { TemplateVersionSourceSchema } from "./template.schema.js";
4
4
  // A registered asset: a text file under public/ whose edits are mirrored
5
5
  // into immutable asset_versions rows (S192 spec §5). Unregistered files
6
- // under public/ are just files — they never get rows here.
6
+ // under public/ are just files: they never get rows here.
7
7
  //
8
- // Path rules: relative, forward slashes, no dot-segments, no leading dot
9
- // on any segment (no hidden files), and never rooted at any
10
- // RESERVED_ROOT_SLUGS segment (kardalum, api, docs, plugin-assets, media):
11
- // the asset tree (walkPublicDir) hides every one of those roots, not just
12
- // kardalum/, so writing under e.g. media/ or api/ would create an invisible
13
- // orphan the admin UI can never see or manage again.
14
- const SEGMENT = /^[a-z0-9][a-z0-9._-]*$/i;
8
+ // Path rules (S314j, D2 and P1): relative, forward slashes, every segment
9
+ // made of what a URL path segment can carry (letters and digits of any
10
+ // script, space, and _ - . ~ @ + , ( ) ! $ ' = ; &), in any position except
11
+ // a leading dot: a dot-name is a hidden file the asset tree (walkPublicDir)
12
+ // never lists, so a write there would be an invisible orphan. Refused:
13
+ // control characters, "\", "%", "?", "#", an empty segment and the dot
14
+ // segments. Never rooted at any RESERVED_ROOT_SLUGS segment (kardalum, api,
15
+ // docs, plugin-assets, media, kardalum-edit): the tree hides every one of
16
+ // those roots for the same reason. A browser percent-encodes such names in a
17
+ // link. A segment is at most 255 UTF-8 bytes and never begins or ends with a
18
+ // space nor ends with a dot (fix wave 1, A2). Each rule carries its own
19
+ // message, because the first failing rule's message is the reason the tree
20
+ // gives for a name it does not list.
21
+ const FORBIDDEN_CHARACTER = /[\u0000-\u001f\u007f\\%?#]/;
22
+ const SEGMENT_CHARACTERS = /^[\p{L}\p{M}\p{N} _\-.~@+,()!$'=;&]+$/u;
23
+ const isPlainSegment = (segment) => segment !== "" && segment !== "." && segment !== ".." && !segment.startsWith(".");
24
+ // A file name on ext4 (NAME_MAX) and most file systems is at most 255 bytes;
25
+ // a longer segment passes the 400-character path cap and then throws
26
+ // ENAMETOOLONG after the row is created.
27
+ const MAX_SEGMENT_BYTES = 255;
28
+ // Counted by code point (this package has no TextEncoder type; see
29
+ // media-reference-use.ts): 1 to 4 bytes each, a lone surrogate as the 3 bytes
30
+ // of its replacement character.
31
+ const utf8Length = (segment) => {
32
+ let bytes = 0;
33
+ for (const ch of segment) {
34
+ const code = ch.codePointAt(0) ?? 0;
35
+ bytes += code < 0x80 ? 1 : code < 0x800 ? 2 : code < 0x10000 ? 3 : 4;
36
+ }
37
+ return bytes;
38
+ };
39
+ const segmentFitsFileSystem = (segment) => utf8Length(segment) <= MAX_SEGMENT_BYTES;
40
+ // Windows strips a trailing dot or space from a file name, so the stored path
41
+ // and the file would differ; a leading space is refused beside it, as no tool
42
+ // keeps one reliably.
43
+ const segmentKeepsItsName = (segment) => segment === "" || (!segment.startsWith(" ") && !segment.endsWith(" ") && !segment.endsWith("."));
15
44
  export const AssetPathSchema = z
16
45
  .string()
17
- .min(1)
18
- .max(400)
19
- .refine((p) => !p.includes("\\"), "forward slashes only")
20
- .refine((p) => p.split("/").every((seg) => SEGMENT.test(seg) && seg !== ".." && seg !== "."), {
21
- message: "invalid path segment",
22
- })
46
+ .min(1, "an empty path")
47
+ .max(400, "longer than 400 characters")
48
+ .refine((p) => !FORBIDDEN_CHARACTER.test(p), "contains \\, %, ?, # or a control character, which an asset name cannot carry")
49
+ .refine((p) => p.split("/").every(isPlainSegment), 'an empty, "." or ".." segment, or a name that starts with a dot (a hidden file)')
50
+ .refine((p) => p.split("/").every((segment) => segment === "" || SEGMENT_CHARACTERS.test(segment)), "a character other than letters, digits, spaces and _ - . ~ @ + , ( ) ! $ ' = ; &")
51
+ .refine((p) => p.split("/").every(segmentFitsFileSystem), "a name longer than 255 bytes (UTF-8), which a file system cannot store")
52
+ .refine((p) => p.split("/").every(segmentKeepsItsName), "a name that begins or ends with a space or ends with a dot, which Windows strips from a file name")
23
53
  .refine((p) => !isReservedRootSlug(p.split("/")[0] ?? ""), {
24
54
  message: "this path root is reserved for the server (see RESERVED_ROOT_SLUGS)",
25
- });
55
+ })
56
+ .describe("A path under public/: segments of letters, digits, spaces and _ - . ~ @ + , ( ) ! $ ' = ; & joined by /, none starting with a dot or ending with a dot or space, each at most 255 bytes, never under a reserved root.");
26
57
  export const AssetDefinitionSchema = z
27
58
  .object({
28
59
  id: z.string().uuid(),
@@ -45,3 +76,7 @@ export const AssetVersionSchema = z
45
76
  createdAt: z.string().min(1),
46
77
  })
47
78
  .strict();
79
+ // S314g: as TemplateVersionMetaSchema and TrashedTemplateSchema, for a
80
+ // registered text asset.
81
+ export const AssetVersionMetaSchema = AssetVersionSchema.omit({ content: true });
82
+ export const TrashedAssetSchema = AssetDefinitionSchema.extend({ deletedAt: z.string().min(1) });