Browse Source

added auxilium schemas as examples

pull/2/head
Cerys 1 week ago
parent
commit
87ad9590e3
  1. 97
      examples/Schemas/CaseSchema.php
  2. 15
      examples/Schemas/CollectionSchema.php
  3. 43
      examples/Schemas/DocumentSchema.php
  4. 14
      examples/Schemas/EnumSchema.php
  5. 24
      examples/Schemas/MessageSchema.php
  6. 36
      examples/Schemas/OrganisationSchema.php
  7. 169
      examples/Schemas/UserSchema.php

97
examples/Schemas/CaseSchema.php

@ -0,0 +1,97 @@
<?php
namespace Auxilium\Schemas;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField;
use Darksparrow\AuxiliumSchemaBuilder\Enumerators\SchemaFieldExistence;
#[SchemaDocument(
Name: "case",
Comment: "The case object itself SHOULD not have a value"
)]
class CaseSchema
{
#[SchemaDocumentField(
Name: "title",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be a short description of what the case is about",
MaxSize: 2048,
MimeType: "text/plain",
)]
public string $Title;
#[SchemaDocumentField(
Name: "clients",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all the clients involved in the case",
ValidSchemas: [
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentField(
Name: "clients",
Comment: "",
ValidSchemas: [
UserSchema::class,
]
),
)]
public array $Clients;
#[SchemaDocumentField(
Name: "workers",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all staff working on the case",
ValidSchemas: [
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentField(
Name: "workers",
Comment: "",
ValidSchemas: [
UserSchema::class,
OrganisationSchema::class,
]
),
)]
public array $Workers;
#[SchemaDocumentField(
Name: "documents",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all the case documents",
ValidSchemas: [
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentField(
Name: "documents",
Comment: "",
ValidSchemas: [
DocumentSchema::class,
]
),
)]
public array $Documents;
#[SchemaDocumentField(
Name: "messages",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all messages that relate to this case",
ValidSchemas: [
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentField(
Name: "messages",
Comment: "",
ValidSchemas: [
CollectionSchema::class,
]
),
)]
public array $Messages;
}

15
examples/Schemas/CollectionSchema.php

@ -0,0 +1,15 @@
<?php
namespace Auxilium\Schemas;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument;
#[SchemaDocument(
Name: "collection",
MaxSize: 0,
Comment: "This is intended as an inheritable schema used to signify to software that it SHOULD display the numeric properties of this node as an inlined list",
)]
class CollectionSchema
{
}

43
examples/Schemas/DocumentSchema.php

@ -0,0 +1,43 @@
<?php
namespace Auxilium\Schemas;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField;
use Darksparrow\AuxiliumSchemaBuilder\Enumerators\SchemaFieldExistence;
#[SchemaDocument(
Name: "document",
Comment: "Any given document SHOULD have metadata attached",
)]
class DocumentSchema
{
#[SchemaDocumentField(
Name: "file_name",
Existence: SchemaFieldExistence::SHOULD,
Comment: "The filename SHOULD NOT contain an extension, this SHOULD be added by the application based on the file's mime type",
MaxSize: 256,
MimeType: "text/plain",
)]
public string $FileName;
#[SchemaDocumentField(
Name: "created",
Existence: SchemaFieldExistence::MAY,
Comment: "The creation date, if supplied MUST be in ISO 8601 format",
MaxSize: 64,
MimeType: "text/plain",
)]
public string $Created;
#[SchemaDocumentField(
Name: "modified",
Existence: SchemaFieldExistence::MAY,
Comment: "The last modified date, if supplied MUST be in ISO 8601 format",
MaxSize: 64,
MimeType: "text/plain",
)]
public string $Modified;
}

14
examples/Schemas/EnumSchema.php

@ -0,0 +1,14 @@
<?php
namespace Auxilium\Schemas;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument;
#[SchemaDocument(
Name: "enum",
Comment: "This is intended as an inheritable schema used to signify to software that it SHOULD be interpreted as a enumerable choice value that can be decoded based on its schema",
)]
class EnumSchema
{
}

24
examples/Schemas/Message.php → examples/Schemas/MessageSchema.php

@ -1,25 +1,23 @@
<?php
namespace Darksparrow\AuxiliumSchemaBuilder\Examples\SchemaBuilder\Schemas;
require_once __DIR__ . "/../../vendor/autoload.php";
namespace Auxilium\Schemas;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentChildField;
use Darksparrow\AuxiliumSchemaBuilder\Enumerators\SchemaFieldExistence;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField;
use Darksparrow\AuxiliumSchemaBuilder\Enumerators\SchemaFieldExistence;
#[SchemaDocument(
Name: "message",
MimeType: "message/rfc822",
)]
class Message
class MessageSchema
{
#[SchemaDocumentField(
Name: "sender",
Existence: SchemaFieldExistence::SHOULD,
Comment: "The sender should be attached to a user object if known",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/user.json"
UserSchema::class,
],
)]
public string $Sender;
@ -29,13 +27,14 @@ class Message
Existence: SchemaFieldExistence::SHOULD,
Comment: "All direct recipients that are known should be attached",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/collection.json"
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentChildField(
Child: new SchemaDocumentField(
Name: "recipients",
Comment: "All direct recipients should be addressed",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/user.json"
UserSchema::class,
]
),
)]
@ -46,13 +45,14 @@ class Message
Existence: SchemaFieldExistence::SHOULD,
Comment: "All cc'd recipients that are known should be attached",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/collection.json"
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentChildField(
Child: new SchemaDocumentField(
Name: "indirect_recipients",
Comment: "All direct recipients should be addressed",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/user.json"
UserSchema::class,
]
),
)]

36
examples/Schemas/Organisation.php → examples/Schemas/OrganisationSchema.php

@ -1,10 +1,8 @@
<?php
namespace Darksparrow\AuxiliumSchemaBuilder\Examples\SchemaBuilder\Schemas;
require_once __DIR__ . "/../../vendor/autoload.php";
namespace Auxilium\Schemas;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentChildField;
use Darksparrow\AuxiliumSchemaBuilder\Enumerators\SchemaFieldExistence;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField;
@ -14,23 +12,22 @@ use Darksparrow\AuxiliumSchemaBuilder\Interfaces\SchemaDocumentInterface;
Name: "organisation",
MaxSize: 0,
Comment: "The organisation object itself SHOULD not have a value",
MimeType: "message/rfc822",
)]
class Organisation implements SchemaDocumentInterface
class OrganisationSchema
{
#[SchemaDocumentField(
Name: "name",
Existence: SchemaFieldExistence::MUST,
Comment: "This MUST be the organisation's name",
MaxSize: 2048,
MimeType: "test/plain",
MimeType: "text/plain",
Children: [
new SchemaDocumentField(
Name: "trading_as",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be the organisation's short trading name, or the abbreviation they would usually go by",
MaxSize: 256,
MIMEType: "text/plain",
Comment: "This SHOULD be the organisation's short trading name, or the abbreviation they would usually go by",
MimeType: "text/plain",
)
]
)]
@ -42,13 +39,14 @@ class Organisation implements SchemaDocumentInterface
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all sub-organisations if applicable",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/collection.json",
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentChildField(
Child: new SchemaDocumentField(
Name: "departments",
Comment: null,
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/organisation.json",
OrganisationSchema::class,
],
),
)]
@ -60,13 +58,14 @@ class Organisation implements SchemaDocumentInterface
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all the cases the organisation is either directly working on or the client of",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/collection.json",
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentChildField(
Child: new SchemaDocumentField(
Name: "cases",
Comment: null,
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/case.json",
CaseSchema::class,
],
),
)]
@ -76,12 +75,13 @@ class Organisation implements SchemaDocumentInterface
#[SchemaDocumentField(
Name: "staff",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all the staff that cannot be categorised into departments, or in the case of small organisations with no departments, all staff",
Comment: "This SHOULD be an 'array node' of all the staff that cannot be categorised into departments, or in the case of small organisations with no departments, all staff",
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/collection.json",
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentChildField(
Child: new SchemaDocumentField(
Name: "staff",
Comment: null,
ValidSchemas: [
"https://schemas.auxiliumsoftware.co.uk/v1/user.json",
@ -91,6 +91,7 @@ class Organisation implements SchemaDocumentInterface
public array $Staff;
/*
public function __construct(array $data)
{
$this->Name = $data["name"];
@ -98,4 +99,5 @@ class Organisation implements SchemaDocumentInterface
$this->Cases = $data["cases"];
$this->Staff = $data["staff"];
}
*/
}

169
examples/Schemas/UserSchema.php

@ -0,0 +1,169 @@
<?php
namespace Auxilium\Schemas;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument;
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocumentField;
use Darksparrow\AuxiliumSchemaBuilder\Enumerators\SchemaFieldExistence;
#[SchemaDocument(
Name: "user",
MaxSize: 0,
Comment: "The user object itself SHOULD not have a value",
)]
class UserSchema
{
#[SchemaDocumentField(
Name: "name",
Existence: SchemaFieldExistence::MUST,
Comment: "This MUST be the user's full name",
MaxSize: 2048,
MimeType: "text/plain",
)]
public string $Name;
#[SchemaDocumentField(
Name: "display_name",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be the user's first name or 'preferred' name used for UI",
MaxSize: 256,
MimeType: "text/plain",
)]
public string $DisplayName;
#[SchemaDocumentField(
Name: "contact_email",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD NOT be used for unverified user input",
MaxSize: 512,
MimeType: "text/plain",
)]
public string $ContactEmail;
#[SchemaDocumentField(
Name: "contact_email",
Existence: SchemaFieldExistence::MAY,
Comment: "This SHOULD be used for unverified user input instead of the 'contact_email' field",
ValidSchemas: [
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentField(
Name: "auxiliary_emails",
MaxSize: 512,
MimeType: "text/plain",
)
)]
public array $AuxiliaryEmails;
#[SchemaDocumentField(
Name: "contact_phone_number",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD include country code, and SHOULD NOT include spaces",
MaxSize: 64,
MimeType: "text/plain",
)]
public string $ContactPhoneNumber;
#[SchemaDocumentField(
Name: "auxiliary_phone_numbers",
Existence: SchemaFieldExistence::MAY,
Comment: "This SHOULD be used for phone numbers that need to be on record, but shouldn't be used for contact",
ValidSchemas: [
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentField(
Name: "auxiliary_phone_numbers",
Comment: "This SHOULD include country code, and SHOULD NOT include spaces",
MaxSize: 64,
MimeType: "text/plain",
)
)]
public array $AuxiliaryPhoneNumbers;
#[SchemaDocumentField(
Name: "contact_address",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be a full address, suitable for international postage",
MimeType: "text/plain",
)]
public string $ContactAddress;
#[SchemaDocumentField(
Name: "auxiliary_addresses",
Existence: SchemaFieldExistence::MAY,
Comment: "This SHOULD be used for addresses that need to be on record, but shouldn't be used for contact",
ValidSchemas: [
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentField(
Name: "auxiliary_addresses",
Comment: "This MAY be a full address, or a shortened address only suitable for local mail",
MimeType: "text/plain",
)
)]
public array $AuxiliaryAddresses;
#[SchemaDocumentField(
Name: "documents",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all the user's documents",
ValidSchemas: [
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentField(
Name: "documents",
ValidSchemas: [
DocumentSchema::class,
]
)
)]
public array $Documents;
#[SchemaDocumentField(
Name: "cases",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all the cases the user is either directly working on or the client of",
ValidSchemas: [
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentField(
Name: "cases",
ValidSchemas: [
CaseSchema::class,
]
)
)]
public array $Cases;
#[SchemaDocumentField(
Name: "messages",
Existence: SchemaFieldExistence::SHOULD,
Comment: "This SHOULD be an 'array node' of all the user's send and recieved messages",
ValidSchemas: [
CollectionSchema::class,
],
MaxSize: 0,
Child: new SchemaDocumentField(
Name: "messages",
ValidSchemas: [
MessageSchema::class,
]
)
)]
public array $Messages;
}
Loading…
Cancel
Save