Events 3.6.0, Accounts 1.5.0, contracts 1.14.0: the nightly people check
- Contracts 1.14.0: people.check in crosscode.identity-request/1 (500 subs) and its reply (active / deactivated / deleted / unknown, profile for the first two). - Accounts 1.5.0: answers people.check with profiles only for people the product knows; the reply isn't stored. - Events 3.6.0: accounts-people-check job (04:30): fixes out-of-date copies, handles deleted accounts as user.deleted, counts unknown people and stops (changing nothing) when most of a page is unknown; skipped with an Accounts older than 1.5.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/contracts",
|
||||
"version": "1.13.0",
|
||||
"version": "1.14.0",
|
||||
"description": "The shared JSON formats used by every Cross Code product: zod schemas, JSON Schema, TypeScript types and sample payloads",
|
||||
"license": "UNLICENSED",
|
||||
"type": "commonjs",
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"schema": "crosscode.identity-request/1",
|
||||
"people": [
|
||||
{
|
||||
"sub": "6b2c3d4e-5f6a-4b7c-9d8e-0f1a2b3c4d5e",
|
||||
"status": "active",
|
||||
"profile": {
|
||||
"name": "Thandi Mokoena",
|
||||
"given_name": "Thandi",
|
||||
"family_name": "Mokoena",
|
||||
"email": "thandi@example.com",
|
||||
"email_verified": true,
|
||||
"phone_number": "+27821234567",
|
||||
"phone_number_verified": false,
|
||||
"news_consent": {
|
||||
"email": true,
|
||||
"whatsapp": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"sub": "7c3d4e5f-6a7b-4c8d-8e9f-1a2b3c4d5e6f",
|
||||
"status": "deleted",
|
||||
"profile": null
|
||||
},
|
||||
{
|
||||
"sub": "8d4e5f6a-7b8c-4d9e-9f0a-2b3c4d5e6f7a",
|
||||
"status": "unknown",
|
||||
"profile": null
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"schema": "crosscode.identity-request/1",
|
||||
"actor": null,
|
||||
"requestId": "9e4f5a6b-7c8d-4e9f-8a0b-2c3d4e5f6a7b",
|
||||
"type": "people.check",
|
||||
"subs": [
|
||||
"6b2c3d4e-5f6a-4b7c-9d8e-0f1a2b3c4d5e",
|
||||
"7c3d4e5f-6a7b-4c8d-8e9f-1a2b3c4d5e6f",
|
||||
"8d4e5f6a-7b8c-4d9e-9f0a-2b3c4d5e6f7a"
|
||||
]
|
||||
}
|
||||
@@ -856,6 +856,53 @@
|
||||
"subs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"const": "crosscode.identity-request/1"
|
||||
},
|
||||
"requestId": {
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"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)$"
|
||||
},
|
||||
"actor": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"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)$"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"const": "people.check"
|
||||
},
|
||||
"subs": {
|
||||
"minItems": 1,
|
||||
"maxItems": 500,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"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)$"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"schema",
|
||||
"requestId",
|
||||
"actor",
|
||||
"type",
|
||||
"subs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
{
|
||||
"$id": "https://c-git.crosscode.co.za/joshua/crosscode-platform/raw/branch/main/packages/contracts/schemas/people-check-reply.json",
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"const": "crosscode.identity-request/1"
|
||||
},
|
||||
"people": {
|
||||
"maxItems": 500,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"sub": {
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"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)$"
|
||||
},
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"active",
|
||||
"deactivated",
|
||||
"deleted",
|
||||
"unknown"
|
||||
]
|
||||
},
|
||||
"profile": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 200
|
||||
},
|
||||
"given_name": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"maxLength": 100
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"family_name": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"maxLength": 100
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"email": {
|
||||
"type": "string",
|
||||
"maxLength": 254,
|
||||
"format": "email",
|
||||
"pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
|
||||
},
|
||||
"email_verified": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"phone_number": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"pattern": "^\\+[1-9]\\d{6,14}$"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"phone_number_verified": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"news_consent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"whatsapp": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"email",
|
||||
"whatsapp"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"given_name",
|
||||
"family_name",
|
||||
"email",
|
||||
"email_verified",
|
||||
"phone_number",
|
||||
"phone_number_verified",
|
||||
"news_consent"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"sub",
|
||||
"status",
|
||||
"profile"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"schema",
|
||||
"people"
|
||||
]
|
||||
}
|
||||
@@ -67,6 +67,7 @@ function contracts(c) {
|
||||
"messaging-status-reply": c.messagingStatusReplySchema,
|
||||
"messaging-test-reply": c.messagingTestReplySchema,
|
||||
"people-remove-demo-reply": c.peopleRemoveDemoReplySchema,
|
||||
"people-check-reply": c.peopleCheckReplySchema,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
import { dateTimeSchema, emailSchema, idSchema, phoneSchema } from "./common";
|
||||
import { twoFactorMethodSchema } from "./identity";
|
||||
import { profileSchema, twoFactorMethodSchema } from "./identity";
|
||||
import { schemaName } from "./schema-name";
|
||||
|
||||
/**
|
||||
@@ -171,6 +171,33 @@ export const peopleRemoveDemoSchema = base.extend({
|
||||
subs: z.array(idSchema).max(REMOVE_DEMO_MAX),
|
||||
});
|
||||
|
||||
/** Subs per `people.check`. */
|
||||
export const PEOPLE_CHECK_MAX = 500;
|
||||
|
||||
/**
|
||||
* 1.14.0: the product's regular check that its copies of people are current (Cross Events does it
|
||||
* nightly), in case a `user.updated` or `user.deleted` never arrived. Accounts answers for each sub
|
||||
* with the current profile, or says the account was deleted, or that it doesn't know the person
|
||||
* through this product (`unknown`; never a reason to delete anything).
|
||||
*/
|
||||
export const peopleCheckSchema = base.extend({
|
||||
type: z.literal("people.check"),
|
||||
subs: z.array(idSchema).min(1).max(PEOPLE_CHECK_MAX),
|
||||
});
|
||||
|
||||
export const PEOPLE_CHECK_STATUSES = ["active", "deactivated", "deleted", "unknown"] as const;
|
||||
|
||||
export const peopleCheckReplySchema = z.object({
|
||||
schema: z.literal(IDENTITY_REQUEST_SCHEMA),
|
||||
people: z.array(z.object({
|
||||
sub: idSchema,
|
||||
status: z.enum(PEOPLE_CHECK_STATUSES),
|
||||
/** The profile as `user.updated` sends it; null for `deleted` and `unknown`. */
|
||||
profile: profileSchema.nullable(),
|
||||
})).max(PEOPLE_CHECK_MAX),
|
||||
});
|
||||
export type PeopleCheckReply = z.infer<typeof peopleCheckReplySchema>;
|
||||
|
||||
// ─── messaging.* (contracts 1.9.0) ───────────────────────────────────────────
|
||||
|
||||
/** SMTP settings as Cross Events and Accounts both keep them (`smtp_*`). `pass` sealed; null: keep the saved one. */
|
||||
@@ -216,7 +243,7 @@ export const churchBrandingSchema = base.extend({ type: z.literal("church.brandi
|
||||
export const identityRequestSchema = z.discriminatedUnion("type", [
|
||||
importBeginSchema, importBatchSchema, importFinishSchema, importAbortSchema,
|
||||
peopleEnsureSchema, peopleUpdateSchema, peopleResetTwoFactorSchema, peopleUnlockSchema, peopleSetActiveSchema, peopleNewsOffSchema,
|
||||
peopleRemoveDemoSchema, messagingStatusSchema, messagingTestSchema, messagingSetSchema, churchBrandingSchema,
|
||||
peopleRemoveDemoSchema, peopleCheckSchema, messagingStatusSchema, messagingTestSchema, messagingSetSchema, churchBrandingSchema,
|
||||
]);
|
||||
export type IdentityRequest = z.infer<typeof identityRequestSchema>;
|
||||
export type IdentityRequestType = IdentityRequest["type"];
|
||||
|
||||
@@ -50,6 +50,8 @@ const SAMPLE_SCHEMA: Record<string, string> = {
|
||||
"messaging-test-reply.json": "messaging-test-reply",
|
||||
"people-remove-demo.json": "identity-request",
|
||||
"people-remove-demo-reply.json": "people-remove-demo-reply",
|
||||
"people-check.json": "identity-request",
|
||||
"people-check-reply.json": "people-check-reply",
|
||||
};
|
||||
|
||||
describe("JSON Schema (schemas/)", () => {
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
importBatchReplySchema,
|
||||
peopleEnsureReplySchema,
|
||||
messagingTestReplySchema,
|
||||
peopleRemoveDemoReplySchema,
|
||||
peopleRemoveDemoReplySchema, peopleCheckReplySchema,
|
||||
userDeletedReplySchema,
|
||||
userExportReplySchema,
|
||||
} from "../src";
|
||||
@@ -59,6 +59,8 @@ const SCHEMAS: Record<string, z.ZodType> = {
|
||||
"messaging-test-reply.json": messagingTestReplySchema,
|
||||
"people-remove-demo.json": identityRequestSchema,
|
||||
"people-remove-demo-reply.json": peopleRemoveDemoReplySchema,
|
||||
"people-check.json": identityRequestSchema,
|
||||
"people-check-reply.json": peopleCheckReplySchema,
|
||||
};
|
||||
|
||||
describe("samples", () => {
|
||||
|
||||
Reference in New Issue
Block a user