@superjackfruitlabs/treaty-matrix-events 0.0.11 → 0.0.12
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/expiry.d.ts +19 -0
- package/dist/expiry.js +30 -0
- package/dist/gate.js +10 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/examples.json +3930 -1546
- package/package.json +1 -1
- package/schemas/dev.agentpod.permission.v2.json +3 -0
- package/schemas/dev.superpipeline.delivery.v2.json +3 -0
- package/schemas/dev.superpipeline.gate.v2.json +3 -0
- package/schemas/dev.superpipeline.question.v2.json +3 -0
package/dist/expiry.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A subject's expiry, `subject.expires_at`: an RFC 3339 date-time with seconds and an explicit
|
|
3
|
+
* offset, such as `2030-01-02T03:04:05Z` or `2030-01-02T08:34:05.5+05:30`.
|
|
4
|
+
*
|
|
5
|
+
* The one spelling every reader accepts. Looser ones that `Date.parse` happens to read (a date
|
|
6
|
+
* only, `Jan 2 2030`, no seconds, no offset, a space for the `T`) are refused, because a strict
|
|
7
|
+
* reader of the event would drop it, and two readers disagreeing on when an approval lapses is
|
|
8
|
+
* worse than either refusing it. SuperPipeline sends only this form.
|
|
9
|
+
*
|
|
10
|
+
* The schemas (`subject.expires_at` in gate.v2, question.v2, delivery.v2, permission.v2) carry the
|
|
11
|
+
* same rule as `"format": "date-time"` and as this pattern, because a JSON Schema validator need
|
|
12
|
+
* not assert `format`.
|
|
13
|
+
*/
|
|
14
|
+
/** The pattern the schemas carry, as a JSON Schema `pattern` string. */
|
|
15
|
+
export declare const SUBJECT_EXPIRY_PATTERN = "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])T([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(\\.\\d+)?(Z|[+-]([01]\\d|2[0-3]):[0-5]\\d)$";
|
|
16
|
+
/** The schemas' `maxLength` on `expires_at`. */
|
|
17
|
+
export declare const SUBJECT_EXPIRY_MAX = 200;
|
|
18
|
+
/** Is this an expiry in the one form a subject may carry, naming a real calendar day? */
|
|
19
|
+
export declare function isSubjectExpiry(v: unknown): v is string;
|
package/dist/expiry.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A subject's expiry, `subject.expires_at`: an RFC 3339 date-time with seconds and an explicit
|
|
3
|
+
* offset, such as `2030-01-02T03:04:05Z` or `2030-01-02T08:34:05.5+05:30`.
|
|
4
|
+
*
|
|
5
|
+
* The one spelling every reader accepts. Looser ones that `Date.parse` happens to read (a date
|
|
6
|
+
* only, `Jan 2 2030`, no seconds, no offset, a space for the `T`) are refused, because a strict
|
|
7
|
+
* reader of the event would drop it, and two readers disagreeing on when an approval lapses is
|
|
8
|
+
* worse than either refusing it. SuperPipeline sends only this form.
|
|
9
|
+
*
|
|
10
|
+
* The schemas (`subject.expires_at` in gate.v2, question.v2, delivery.v2, permission.v2) carry the
|
|
11
|
+
* same rule as `"format": "date-time"` and as this pattern, because a JSON Schema validator need
|
|
12
|
+
* not assert `format`.
|
|
13
|
+
*/
|
|
14
|
+
/** The pattern the schemas carry, as a JSON Schema `pattern` string. */
|
|
15
|
+
export const SUBJECT_EXPIRY_PATTERN = "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])T([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(\\.\\d+)?(Z|[+-]([01]\\d|2[0-3]):[0-5]\\d)$";
|
|
16
|
+
/** The schemas' `maxLength` on `expires_at`. */
|
|
17
|
+
export const SUBJECT_EXPIRY_MAX = 200;
|
|
18
|
+
const EXPIRY = new RegExp(SUBJECT_EXPIRY_PATTERN);
|
|
19
|
+
/** Is this an expiry in the one form a subject may carry, naming a real calendar day? */
|
|
20
|
+
export function isSubjectExpiry(v) {
|
|
21
|
+
if (typeof v !== "string" || v.length > SUBJECT_EXPIRY_MAX)
|
|
22
|
+
return false;
|
|
23
|
+
if (!EXPIRY.test(v))
|
|
24
|
+
return false;
|
|
25
|
+
const year = Number(v.slice(0, 4));
|
|
26
|
+
const month = Number(v.slice(5, 7));
|
|
27
|
+
const day = Number(v.slice(8, 10));
|
|
28
|
+
// 2030-02-30 matches the pattern; the calendar refuses it, as `format: date-time` does.
|
|
29
|
+
return new Date(Date.UTC(year, month - 1, day)).getUTCDate() === day;
|
|
30
|
+
}
|
package/dist/gate.js
CHANGED
|
@@ -11,6 +11,7 @@ import { quorumField } from "./quorum.js";
|
|
|
11
11
|
import { releaseField, releaseSentence, releaseV2 } from "./release.js";
|
|
12
12
|
import { checksField, checksSentence, checksV2 } from "./checks.js";
|
|
13
13
|
import { isHttpsUrl } from "./safe-url.js";
|
|
14
|
+
import { isSubjectExpiry } from "./expiry.js";
|
|
14
15
|
export const GATE_EVENT_TYPE = "dev.superpipeline.gate.v1";
|
|
15
16
|
export const GATE_DECISION_SUITE_TYPE = "dev.superpipeline.gate.decision.v1";
|
|
16
17
|
/**
|
|
@@ -272,7 +273,15 @@ const RawSubject = z.object({
|
|
|
272
273
|
digest: z.string().min(1).max(SUBJECT_KEY_MAX),
|
|
273
274
|
schema: z.string().min(1).max(PREVIEW_FIELD_MAX),
|
|
274
275
|
revision: z.number().int().nonnegative(),
|
|
275
|
-
|
|
276
|
+
/**
|
|
277
|
+
* Strict (`isSubjectExpiry`): a loosely spelled expiry refuses the whole subject, since carrying
|
|
278
|
+
* it would emit an event its schema refuses, and dropping it would carry an approval with no
|
|
279
|
+
* expiry. A value that is not a string at all is read as none, as before.
|
|
280
|
+
*/
|
|
281
|
+
expiresAt: z
|
|
282
|
+
.unknown()
|
|
283
|
+
.refine((v) => typeof v !== "string" || isSubjectExpiry(v))
|
|
284
|
+
.transform((v) => (typeof v === "string" ? v : null)),
|
|
276
285
|
preview: z.array(z.unknown()).optional().catch(undefined),
|
|
277
286
|
/** False when the board had to cut or drop blocks to fit the bounds. Absent from older boards. */
|
|
278
287
|
previewComplete: z.boolean().optional().catch(undefined),
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./decision-timeout.ts";
|
|
|
17
17
|
export * from "./deliveries.ts";
|
|
18
18
|
export * from "./delivery.ts";
|
|
19
19
|
export * from "./elicitation.ts";
|
|
20
|
+
export * from "./expiry.ts";
|
|
20
21
|
export * from "./gate.ts";
|
|
21
22
|
export * from "./permission.ts";
|
|
22
23
|
export * from "./question.ts";
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./decision-timeout.js";
|
|
|
17
17
|
export * from "./deliveries.js";
|
|
18
18
|
export * from "./delivery.js";
|
|
19
19
|
export * from "./elicitation.js";
|
|
20
|
+
export * from "./expiry.js";
|
|
20
21
|
export * from "./gate.js";
|
|
21
22
|
export * from "./permission.js";
|
|
22
23
|
export * from "./question.js";
|