@fleetless/contracts 14.0.0 → 15.0.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 (119) hide show
  1. package/CHANGELOG.md +163 -0
  2. package/artifacts/openapi.json +19842 -11398
  3. package/artifacts/routes.json +1160 -39
  4. package/artifacts/schema/addon-catalogue-entry.schema.json +3 -1
  5. package/artifacts/schema/admin-plan-change-request.schema.json +26 -0
  6. package/artifacts/schema/app-deletion-summary.schema.json +15 -1
  7. package/artifacts/schema/asset-plan-limit-details.schema.json +3 -1
  8. package/artifacts/schema/cloud-config.schema.json +5 -5
  9. package/artifacts/schema/collection-actor.schema.json +35 -0
  10. package/artifacts/schema/collection-definitions-response.schema.json +612 -0
  11. package/artifacts/schema/collection-event.schema.json +216 -0
  12. package/artifacts/schema/collection-export-query.schema.json +56 -0
  13. package/artifacts/schema/collection-filter.schema.json +9 -0
  14. package/artifacts/schema/collection-import-preview.schema.json +143 -0
  15. package/artifacts/schema/collection-import-request.schema.json +105 -0
  16. package/artifacts/schema/collection-import-result.schema.json +38 -0
  17. package/artifacts/schema/collection-list-response.schema.json +119 -0
  18. package/artifacts/schema/collection-record-get-query.schema.json +12 -0
  19. package/artifacts/schema/collection-record-history-query.schema.json +35 -0
  20. package/artifacts/schema/collection-record-history-response.schema.json +389 -0
  21. package/artifacts/schema/collection-record-list-query.schema.json +67 -0
  22. package/artifacts/schema/collection-record-list-response.schema.json +212 -0
  23. package/artifacts/schema/collection-record-restore-request.schema.json +14 -0
  24. package/artifacts/schema/collection-record-write.schema.json +31 -0
  25. package/artifacts/schema/collection-record.schema.json +180 -0
  26. package/artifacts/schema/collection-revision.schema.json +295 -0
  27. package/artifacts/schema/collection-subscribe-error.schema.json +31 -0
  28. package/artifacts/schema/collection-subscribe.schema.json +48 -0
  29. package/artifacts/schema/collection-subscribed.schema.json +22 -0
  30. package/artifacts/schema/collection-summary.schema.json +92 -0
  31. package/artifacts/schema/collection-unsubscribe.schema.json +22 -0
  32. package/artifacts/schema/collections-access-change.schema.json +34 -0
  33. package/artifacts/schema/collections-document.schema.json +732 -0
  34. package/artifacts/schema/collections-draft-response.schema.json +845 -0
  35. package/artifacts/schema/collections-effect.schema.json +384 -0
  36. package/artifacts/schema/collections-issue.schema.json +36 -0
  37. package/artifacts/schema/collections-publish-request.schema.json +18 -0
  38. package/artifacts/schema/collections-publish-response.schema.json +450 -0
  39. package/artifacts/schema/collections-purge-preview.schema.json +60 -0
  40. package/artifacts/schema/collections-purge-request.schema.json +27 -0
  41. package/artifacts/schema/collections-purge-response.schema.json +30 -0
  42. package/artifacts/schema/collections-restore-preview-query.schema.json +20 -0
  43. package/artifacts/schema/collections-restore-preview.schema.json +581 -0
  44. package/artifacts/schema/collections-restore-request.schema.json +27 -0
  45. package/artifacts/schema/collections-restore-response.schema.json +455 -0
  46. package/artifacts/schema/collections-schema-preview.schema.json +519 -0
  47. package/artifacts/schema/collections-schema-published.schema.json +22 -0
  48. package/artifacts/schema/collections-version-response.schema.json +869 -0
  49. package/artifacts/schema/collections-version-summary.schema.json +139 -0
  50. package/artifacts/schema/collections-versions-response.schema.json +167 -0
  51. package/artifacts/schema/config-draft-response.schema.json +5 -5
  52. package/artifacts/schema/config-version-response.schema.json +5 -5
  53. package/artifacts/schema/confirmation-required-details.schema.json +13 -0
  54. package/artifacts/schema/dangling-reference.schema.json +7 -6
  55. package/artifacts/schema/datapoint-list-response.schema.json +2 -2
  56. package/artifacts/schema/effective-rights-response.schema.json +87 -1
  57. package/artifacts/schema/org-plan.schema.json +29 -1
  58. package/artifacts/schema/org-quota-usage-counts.schema.json +18 -0
  59. package/artifacts/schema/org-quota-usage.schema.json +47 -1
  60. package/artifacts/schema/org-quotas.schema.json +29 -1
  61. package/artifacts/schema/org-role-list-response.schema.json +8 -7
  62. package/artifacts/schema/org-role.schema.json +1 -1
  63. package/artifacts/schema/plan-catalogue-entry.schema.json +29 -1
  64. package/artifacts/schema/plan-change-decision-status-response.schema.json +29 -1
  65. package/artifacts/schema/plan-limit-details.schema.json +3 -1
  66. package/artifacts/schema/plan-limits.schema.json +29 -1
  67. package/artifacts/schema/plan-overrides.schema.json +26 -0
  68. package/artifacts/schema/put-collections-draft-request.schema.json +16 -0
  69. package/artifacts/schema/record-changed-details.schema.json +16 -0
  70. package/artifacts/schema/record-referenced-details.schema.json +35 -0
  71. package/artifacts/schema/reference-invalid-details.schema.json +25 -0
  72. package/artifacts/schema/reference-place.schema.json +7 -6
  73. package/artifacts/schema/required-missing-details.schema.json +19 -0
  74. package/artifacts/schema/robot-config-doc.schema.json +5 -5
  75. package/artifacts/schema/robot-deletion-summary.schema.json +33 -1
  76. package/artifacts/schema/role-collection-rights.schema.json +82 -0
  77. package/artifacts/schema/role-rename-preview.schema.json +7 -6
  78. package/dist/apps.d.ts +18 -2
  79. package/dist/apps.js +12 -2
  80. package/dist/audit.d.ts +32 -2
  81. package/dist/audit.js +40 -2
  82. package/dist/collections-issues.d.ts +67 -0
  83. package/dist/collections-issues.js +340 -0
  84. package/dist/collections-records.d.ts +562 -0
  85. package/dist/collections-records.js +525 -0
  86. package/dist/collections-rights.d.ts +17 -0
  87. package/dist/collections-rights.js +41 -0
  88. package/dist/collections-schema.d.ts +1064 -0
  89. package/dist/collections-schema.js +386 -0
  90. package/dist/collections-templates.d.ts +55 -0
  91. package/dist/collections-templates.js +137 -0
  92. package/dist/collections-transfer.d.ts +101 -0
  93. package/dist/collections-transfer.js +206 -0
  94. package/dist/collections-values.d.ts +67 -0
  95. package/dist/collections-values.js +284 -0
  96. package/dist/collections.d.ts +568 -0
  97. package/dist/collections.js +332 -0
  98. package/dist/config.d.ts +8 -8
  99. package/dist/config.js +13 -13
  100. package/dist/errors.d.ts +50 -1
  101. package/dist/errors.js +115 -0
  102. package/dist/index.d.ts +24 -8
  103. package/dist/index.js +13 -3
  104. package/dist/org-roles.d.ts +4 -0
  105. package/dist/org-roles.js +10 -9
  106. package/dist/plans.d.ts +19 -1
  107. package/dist/plans.js +21 -1
  108. package/dist/realtime.d.ts +166 -0
  109. package/dist/realtime.js +163 -0
  110. package/dist/rest.d.ts +28 -28
  111. package/dist/rest.js +39 -27
  112. package/dist/rights.d.ts +2 -2
  113. package/dist/rights.js +1 -1
  114. package/dist/routes.d.ts +1 -1
  115. package/dist/routes.js +495 -21
  116. package/package.json +1 -1
  117. package/artifacts/schema/put-robot-details-request.schema.json +0 -41
  118. package/artifacts/schema/put-robot-details-response.schema.json +0 -43
  119. package/artifacts/schema/robot-details-doc.schema.json +0 -33
@@ -47,6 +47,37 @@
47
47
  },
48
48
  "had_unpublished_draft": {
49
49
  "type": "boolean"
50
+ },
51
+ "collection_records": {
52
+ "type": "array",
53
+ "items": {
54
+ "type": "object",
55
+ "properties": {
56
+ "app_id": {
57
+ "type": "string",
58
+ "format": "uuid",
59
+ "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
60
+ "description": "The app whose collections hold records of the robot."
61
+ },
62
+ "app_name": {
63
+ "type": "string",
64
+ "description": "The app's name."
65
+ },
66
+ "records": {
67
+ "type": "integer",
68
+ "minimum": 0,
69
+ "maximum": 9007199254740991,
70
+ "description": "How many records of the robot the app's collections hold, deleted with the robot."
71
+ }
72
+ },
73
+ "required": [
74
+ "app_id",
75
+ "app_name",
76
+ "records"
77
+ ],
78
+ "additionalProperties": false
79
+ },
80
+ "description": "App collection records that go with the robot, per app. A robot's records are kept in every app it was attached to, also in one it was detached from, and are deleted with their history when the robot is; apps without records of this robot are left out."
50
81
  }
51
82
  },
52
83
  "required": [
@@ -58,7 +89,8 @@
58
89
  "asset_bytes_freed",
59
90
  "job_run_count",
60
91
  "had_live_session",
61
- "had_unpublished_draft"
92
+ "had_unpublished_draft",
93
+ "collection_records"
62
94
  ],
63
95
  "additionalProperties": false
64
96
  }
@@ -0,0 +1,82 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "collection": {
6
+ "type": "string",
7
+ "pattern": "^[a-z][a-z0-9_]{0,62}$",
8
+ "description": "The collection's key."
9
+ },
10
+ "label": {
11
+ "type": "string",
12
+ "description": "The collection's label for people to read; its key when the schema gives none."
13
+ },
14
+ "binding": {
15
+ "type": "string",
16
+ "enum": [
17
+ "global",
18
+ "per_robot",
19
+ "one_per_robot"
20
+ ],
21
+ "description": "`global`: records belong to the app and no robot. `per_robot`: every record belongs to one robot (system field `robot_id`, fixed when the record is created). `one_per_robot`: every robot of the app has exactly one record, which Fleetless creates itself."
22
+ },
23
+ "read": {
24
+ "type": "boolean",
25
+ "description": "Whether the role may read the records."
26
+ },
27
+ "create": {
28
+ "type": "boolean",
29
+ "description": "Whether the role may create records."
30
+ },
31
+ "update": {
32
+ "anyOf": [
33
+ {
34
+ "type": "string",
35
+ "const": "all"
36
+ },
37
+ {
38
+ "type": "string",
39
+ "const": "own"
40
+ },
41
+ {
42
+ "type": "boolean",
43
+ "const": false
44
+ }
45
+ ],
46
+ "description": "`all`: the role may change every record. `own`: only records its user created. `false`: none."
47
+ },
48
+ "delete": {
49
+ "anyOf": [
50
+ {
51
+ "type": "string",
52
+ "const": "all"
53
+ },
54
+ {
55
+ "type": "string",
56
+ "const": "own"
57
+ },
58
+ {
59
+ "type": "boolean",
60
+ "const": false
61
+ }
62
+ ],
63
+ "description": "`all`: the role may delete every record. `own`: only records its user created. `false`: none."
64
+ },
65
+ "robot_filter": {
66
+ "type": "boolean",
67
+ "description": "`true` on a collection that belongs to robots (`per_robot`, `one_per_robot`): the role sees and writes only the records of robots a session of the role reaches, whatever the rights above say. `false` on a `global` collection."
68
+ }
69
+ },
70
+ "required": [
71
+ "collection",
72
+ "label",
73
+ "binding",
74
+ "read",
75
+ "create",
76
+ "update",
77
+ "delete",
78
+ "robot_filter"
79
+ ],
80
+ "additionalProperties": false,
81
+ "description": "What one role may do with the records of one collection."
82
+ }
@@ -19,17 +19,18 @@
19
19
  "type": "string",
20
20
  "enum": [
21
21
  "config",
22
+ "collection_schema",
22
23
  "app_user",
23
24
  "invitation",
24
25
  "app_default",
25
26
  "role_inherits",
26
27
  "org_default"
27
28
  ],
28
- "description": "What writes the key: `config` is a `role` or `access` value in a robot's `fleetless.yaml`, `app_user` an app user who holds it, `invitation` an invitation that carries it, `app_default` an app's default role, `role_inherits` another role that inherits from it, and `org_default` one of the organization's defaults."
29
+ "description": "What writes the key: `config` is a `role` or `access` value in a robot's `fleetless.yaml`, `collection_schema` an `access` entry of a collection in an app's collections schema, `app_user` an app user who holds it, `invitation` an invitation that carries it, `app_default` an app's default role, `role_inherits` another role that inherits from it, and `org_default` one of the organization's defaults."
29
30
  },
30
31
  "label": {
31
32
  "type": "string",
32
- "description": "What a person reads to find the place: the robot name (`config`), the e-mail address of the app user or of the invitee (`app_user`, `invitation`), the app name (`app_default`), the name of the inheriting role (`role_inherits`), or the access kind of an organization default (`org_default`)."
33
+ "description": "What a person reads to find the place: the robot name (`config`), the app name (`collection_schema`, `app_default`), the e-mail address of the app user or of the invitee (`app_user`, `invitation`), the name of the inheriting role (`role_inherits`), or the access kind of an organization default (`org_default`)."
33
34
  },
34
35
  "path": {
35
36
  "anyOf": [
@@ -40,7 +41,7 @@
40
41
  "type": "null"
41
42
  }
42
43
  ],
43
- "description": "Where the key is written. For `config`, the place in the YAML, such as `services.arm_home.role` or `access.rules[1].role`; for `role_inherits`, the key of the role that inherits from it, because display names are not unique; `null` for every other kind."
44
+ "description": "Where the key is written. For `config`, the place in the YAML, such as `services.arm_home.role` or `access.rules[1].role`; for `collection_schema`, the place in the collections schema, such as `collections.notes.access.update.own[1]`; for `role_inherits`, the key of the role that inherits from it, because display names are not unique; `null` for every other kind."
44
45
  },
45
46
  "robot_id": {
46
47
  "anyOf": [
@@ -66,7 +67,7 @@
66
67
  "type": "null"
67
68
  }
68
69
  ],
69
- "description": "The app the user, invitation or default role belongs to (`app_user`, `invitation`, `app_default`); `null` for every other kind."
70
+ "description": "The app the key belongs to: the app whose collections schema holds it (`collection_schema`), or the app of the user, invitation or default role (`app_user`, `invitation`, `app_default`); `null` for every other kind."
70
71
  },
71
72
  "user_id": {
72
73
  "anyOf": [
@@ -94,7 +95,7 @@
94
95
  "type": "null"
95
96
  }
96
97
  ],
97
- "description": "Which version of the robot's document holds the key (`config`): the published one or the draft; `null` for every other kind."
98
+ "description": "Which version of the document holds the key (`config`: the robot's configuration, `collection_schema`: the app's collections schema): the published one or the draft; `null` for every other kind."
98
99
  },
99
100
  "new_version": {
100
101
  "anyOf": [
@@ -107,7 +108,7 @@
107
108
  "type": "null"
108
109
  }
109
110
  ],
110
- "description": "For a published document, the version number a rename with `update_references` would give it, a copy that differs only in the key; `null` for a draft and for every place that is no document."
111
+ "description": "For a published document (`config` or `collection_schema`), the version number a rename with `update_references` would give it, a copy that differs only in the key; `null` for a draft and for every place that is no document."
111
112
  }
112
113
  },
113
114
  "required": [
package/dist/apps.d.ts CHANGED
@@ -49,9 +49,9 @@ export type AppListResponse = z.infer<typeof appListResponse>;
49
49
  * What deleting an app would destroy — read before the irreversible click,
50
50
  * and carried again by the `app.deleted` audit event.
51
51
  *
52
- * **Five numbers, never a sum**, for the reason `robotDeletionSummary` states
52
+ * **Seven numbers, never a sum**, for the reason `robotDeletionSummary` states
53
53
  * at length: the console reads this aloud as one sentence, and a total would
54
- * describe five unrelated magnitudes with one figure on the one screen whose
54
+ * describe seven unrelated magnitudes with one figure on the one screen whose
55
55
  * entire justification is naming what cannot be undone.
56
56
  *
57
57
  * Roles are not here: they belong to the organization, so deleting an app
@@ -67,6 +67,8 @@ export declare const appDeletionSummary: z.ZodObject<{
67
67
  invitation_count: z.ZodNumber;
68
68
  oidc_provider_count: z.ZodNumber;
69
69
  mail_template_count: z.ZodNumber;
70
+ collection_count: z.ZodNumber;
71
+ record_count: z.ZodNumber;
70
72
  }, z.core.$strip>;
71
73
  export type AppDeletionSummary = z.infer<typeof appDeletionSummary>;
72
74
  /**
@@ -395,5 +397,19 @@ export declare const effectiveRightsResponse: z.ZodObject<{
395
397
  }, z.core.$strip>>;
396
398
  }, z.core.$strip>;
397
399
  }, z.core.$strip>>;
400
+ collections: z.ZodArray<z.ZodObject<{
401
+ collection: z.ZodString;
402
+ label: z.ZodString;
403
+ binding: z.ZodEnum<{
404
+ global: "global";
405
+ per_robot: "per_robot";
406
+ one_per_robot: "one_per_robot";
407
+ }>;
408
+ read: z.ZodBoolean;
409
+ create: z.ZodBoolean;
410
+ update: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodLiteral<"own">, z.ZodLiteral<false>]>;
411
+ delete: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodLiteral<"own">, z.ZodLiteral<false>]>;
412
+ robot_filter: z.ZodBoolean;
413
+ }, z.core.$strip>>;
398
414
  }, z.core.$strip>;
399
415
  export type EffectiveRightsResponse = z.infer<typeof effectiveRightsResponse>;
package/dist/apps.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { z } from 'zod';
3
3
  import { slug } from './common.js';
4
4
  import { mcpRobotDatasheet } from './mcp.js';
5
+ import { roleCollectionRights } from './collections-rights.js';
5
6
  import { ACCESS_KINDS, accessKind, roleKey } from './rights.js';
6
7
  /**
7
8
  * Apps, roles and rights.
@@ -75,9 +76,9 @@ export const appListResponse = z.object({
75
76
  * What deleting an app would destroy — read before the irreversible click,
76
77
  * and carried again by the `app.deleted` audit event.
77
78
  *
78
- * **Five numbers, never a sum**, for the reason `robotDeletionSummary` states
79
+ * **Seven numbers, never a sum**, for the reason `robotDeletionSummary` states
79
80
  * at length: the console reads this aloud as one sentence, and a total would
80
- * describe five unrelated magnitudes with one figure on the one screen whose
81
+ * describe seven unrelated magnitudes with one figure on the one screen whose
81
82
  * entire justification is naming what cannot be undone.
82
83
  *
83
84
  * Roles are not here: they belong to the organization, so deleting an app
@@ -103,6 +104,12 @@ export const appDeletionSummary = z.object({
103
104
  mail_template_count: z.number().int().nonnegative().meta({
104
105
  description: 'Custom mail templates, of at most three. A kind using the Fleetless default text is not counted — there is no row to lose.',
105
106
  }),
107
+ collection_count: z.number().int().nonnegative().meta({
108
+ description: 'Collections of the app\'s latest published schema. They go with the app, together with their records and history.',
109
+ }),
110
+ record_count: z.number().int().nonnegative().meta({
111
+ description: 'Records of the app\'s collections, deleted with the app.',
112
+ }),
106
113
  });
107
114
  /**
108
115
  * **`robot_ids` is accepted here, and `.strict()` catches everything else.**
@@ -383,4 +390,7 @@ export const effectiveRightsResponse = z.object({
383
390
  robots: z.array(effectiveRobotRights).meta({
384
391
  description: 'The robots attached to the app, each with what the role may use.',
385
392
  }),
393
+ collections: z.array(roleCollectionRights).meta({
394
+ description: 'What the role may do with the records of each collection of the app\'s latest published schema, in the schema\'s order. Empty when the app has no published schema. A role that is no role, and a user who is not `active`, are granted nothing in any row.',
395
+ }),
386
396
  });
package/dist/audit.d.ts CHANGED
@@ -6,8 +6,9 @@ import { z } from 'zod';
6
6
  * its actor — never anonymous**. Reads are not audited.
7
7
  *
8
8
  * What is written: logins, failed logins, user management, configuration
9
- * publishes, bridge connect and disconnect. The log is filterable, exportable
10
- * as CSV, and kept for ninety days.
9
+ * publishes, bridge connect and disconnect, and the writes of app collections
10
+ * (`COLLECTION_AUDIT_ACTIONS`). The log is filterable, exportable as CSV, and
11
+ * kept for ninety days.
11
12
  */
12
13
  /**
13
14
  * The kinds of actor the platform knows. `label` is what a human reads in the
@@ -135,3 +136,32 @@ export declare const AUDIT_CSV_COLUMNS: readonly ["seq", "at", "actor_kind", "ac
135
136
  * as `ROBOT_ASSET_STORE_BYTES`.
136
137
  */
137
138
  export declare const AUDIT_RETENTION_DAYS = 90;
139
+ /**
140
+ * **The audit actions of app collections.** Each write request writes exactly
141
+ * one entry, whatever it changed: an import of 5,000 rows is one
142
+ * `collection_import.completed`, not 5,000 record entries. Reads and exports
143
+ * are not audited, here as everywhere in this log.
144
+ *
145
+ * - `collection_schema.published`: a schema version was published; the entry
146
+ * names the version and counts the effects it had on data. A role rename
147
+ * that rewrites the key in the `access` of an app's collections also appends
148
+ * a version, which changes no record: its entry has no effects and carries
149
+ * `role_rename` with the `from` and `to` keys, and its actor is the
150
+ * developer who renamed the role.
151
+ * - `collection_schema.restored`: an earlier version was restored; the entry
152
+ * names the version, says whether records were put back too and counts what
153
+ * changed.
154
+ * - `collection_record.created`, `.updated`, `.deleted`, `.restored`: one
155
+ * record write; the entry names the collection, the record and its robot.
156
+ * - `collection_import.completed`: an import was carried out; the entry names
157
+ * the collection and the mode and counts the records created, updated and
158
+ * deleted.
159
+ * - `collection_history.purged`: an organization owner removed history older
160
+ * than a date; the entry names the date, the collection or the whole app,
161
+ * and how many revisions went. The actor is the owner.
162
+ *
163
+ * The strings are stable: filter the log with `action` or with
164
+ * `action_prefix` (`collection_record.`).
165
+ */
166
+ export declare const COLLECTION_AUDIT_ACTIONS: readonly ["collection_schema.published", "collection_schema.restored", "collection_record.created", "collection_record.updated", "collection_record.deleted", "collection_record.restored", "collection_import.completed", "collection_history.purged"];
167
+ export type CollectionAuditAction = (typeof COLLECTION_AUDIT_ACTIONS)[number];
package/dist/audit.js CHANGED
@@ -7,8 +7,9 @@ import { wireSeqCursor, wireTimestampMs } from './common.js';
7
7
  * its actor — never anonymous**. Reads are not audited.
8
8
  *
9
9
  * What is written: logins, failed logins, user management, configuration
10
- * publishes, bridge connect and disconnect. The log is filterable, exportable
11
- * as CSV, and kept for ninety days.
10
+ * publishes, bridge connect and disconnect, and the writes of app collections
11
+ * (`COLLECTION_AUDIT_ACTIONS`). The log is filterable, exportable as CSV, and
12
+ * kept for ninety days.
12
13
  */
13
14
  /**
14
15
  * The kinds of actor the platform knows. `label` is what a human reads in the
@@ -226,3 +227,40 @@ export const AUDIT_CSV_COLUMNS = ['seq', 'at', 'actor_kind', 'actor_id', 'action
226
227
  * as `ROBOT_ASSET_STORE_BYTES`.
227
228
  */
228
229
  export const AUDIT_RETENTION_DAYS = 90;
230
+ /**
231
+ * **The audit actions of app collections.** Each write request writes exactly
232
+ * one entry, whatever it changed: an import of 5,000 rows is one
233
+ * `collection_import.completed`, not 5,000 record entries. Reads and exports
234
+ * are not audited, here as everywhere in this log.
235
+ *
236
+ * - `collection_schema.published`: a schema version was published; the entry
237
+ * names the version and counts the effects it had on data. A role rename
238
+ * that rewrites the key in the `access` of an app's collections also appends
239
+ * a version, which changes no record: its entry has no effects and carries
240
+ * `role_rename` with the `from` and `to` keys, and its actor is the
241
+ * developer who renamed the role.
242
+ * - `collection_schema.restored`: an earlier version was restored; the entry
243
+ * names the version, says whether records were put back too and counts what
244
+ * changed.
245
+ * - `collection_record.created`, `.updated`, `.deleted`, `.restored`: one
246
+ * record write; the entry names the collection, the record and its robot.
247
+ * - `collection_import.completed`: an import was carried out; the entry names
248
+ * the collection and the mode and counts the records created, updated and
249
+ * deleted.
250
+ * - `collection_history.purged`: an organization owner removed history older
251
+ * than a date; the entry names the date, the collection or the whole app,
252
+ * and how many revisions went. The actor is the owner.
253
+ *
254
+ * The strings are stable: filter the log with `action` or with
255
+ * `action_prefix` (`collection_record.`).
256
+ */
257
+ export const COLLECTION_AUDIT_ACTIONS = [
258
+ 'collection_schema.published',
259
+ 'collection_schema.restored',
260
+ 'collection_record.created',
261
+ 'collection_record.updated',
262
+ 'collection_record.deleted',
263
+ 'collection_record.restored',
264
+ 'collection_import.completed',
265
+ 'collection_history.purged',
266
+ ];
@@ -0,0 +1,67 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { z } from 'zod';
3
+ import { type CollectionsDocument } from './collections.js';
4
+ /**
5
+ * Everything wrong with a collections document that only the whole document
6
+ * can tell: the questions a zod schema cannot ask because they compare one
7
+ * part with another (does the reference point at a collection? does the
8
+ * default fit?) or count (how many collections?).
9
+ *
10
+ * It lives in contracts, as a pure function, so the cloud that refuses a
11
+ * document, the console that shows its problems while someone types, and the
12
+ * tools that write documents give the same answer in the same words.
13
+ */
14
+ /** One finding about a document. */
15
+ export declare const collectionsIssue: z.ZodObject<{
16
+ path: z.ZodString;
17
+ code: z.ZodString;
18
+ message: z.ZodString;
19
+ severity: z.ZodEnum<{
20
+ error: "error";
21
+ warning: "warning";
22
+ info: "info";
23
+ }>;
24
+ }, z.core.$strip>;
25
+ export type CollectionsIssue = z.infer<typeof collectionsIssue>;
26
+ export type CollectionsDocumentIssuesOptions = {
27
+ /**
28
+ * Returns what is wrong with an inline JSON Schema, or `null` when it is a
29
+ * usable JSON Schema (draft 2020-12). Contracts carries no JSON Schema
30
+ * validator, so a caller that has one passes it; without it inline schemas
31
+ * are not judged.
32
+ */
33
+ validateJsonSchema?: (schema: unknown) => string | null;
34
+ /** Checks a value against a JSON Schema, as for `checkCollectionValue`. Needed to judge a `default` on a `json` field. */
35
+ validateJsonValue?: (schema: unknown, value: unknown) => string | null;
36
+ /** Matches a text against a `pattern`, as for `checkCollectionValue`. Used to judge a `default` the way a write is judged. */
37
+ matchPattern?: (pattern: string, value: string) => boolean;
38
+ };
39
+ /**
40
+ * Finds every way a document is invalid, and the things worth knowing about a
41
+ * valid one.
42
+ *
43
+ * **Errors** make the document invalid: `too_many_collections`,
44
+ * `too_many_fields`, `reserved_key`, `unknown_reference_target`,
45
+ * `robot_reference_from_global`, `unknown_template`, `invalid_json_schema`,
46
+ * `invalid_pattern`, `display_template_invalid`,
47
+ * `display_placeholder_unresolved`, `duplicate_option`, `invalid_default`,
48
+ * `required_without_default` and `unique_not_allowed`.
49
+ *
50
+ * **Warnings** (`access_ignored`) and **information** (`no_role_has_access`)
51
+ * leave it valid. Nothing about stored data is judged here: a document is
52
+ * never invalid because of the records it would affect.
53
+ *
54
+ * Issues come in document order: each collection's fields, then its display,
55
+ * then its access. A field that is wrong in one way is not also reported for
56
+ * the knock-on effects of that (an unknown template does not also make its
57
+ * default invalid).
58
+ */
59
+ export declare function collectionsDocumentIssues(document: CollectionsDocument, options?: CollectionsDocumentIssuesOptions): CollectionsIssue[];
60
+ /**
61
+ * One warning for each role key in `access` that the organization does not
62
+ * have, per collection and action. The document stays valid: renaming or
63
+ * deleting a role never makes a published document fail, and a key that names
64
+ * no role grants nothing. `roleKeys` is the set of the organization's role
65
+ * keys.
66
+ */
67
+ export declare function collectionsAccessWarnings(document: CollectionsDocument, roleKeys: ReadonlySet<string>): CollectionsIssue[];