Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import {schema} from '@feasibleone/blong';
export default schema(async ({lib: {type}}) => ({
/**
* Person profiles attached to core.resource records.
*
* The PK `personId` is a UUID FK to core.resource.resourceId, so every person
* corresponds to a resource entity. The `type.uuid()` default triggers
* auto-generation of a binary UUID in the knex `add` handler, which also
* creates the corresponding `core_resource` row.
*/
person: type.Object(
{
personId: type.uuid(),
firstName: type.stringNotNull(),
middleName: type.stringNull(),
lastName: type.stringNotNull(),
birthDate: type.dateNull(),
gender: type.stringNull({maxLength: 10}),
maritalStatus: type.stringNull({maxLength: 20}),
nationality: type.stringNull({maxLength: 100}),
occupation: type.stringNull(),
notes: type.stringNull(),
},
{
constraints: {
primaryKey: 'personId',
foreign: {
personId: 'core.resource.resourceId',
},
},
},
),
/**
* Organization profiles attached to core.resource records.
*
* Organizations are legal entities such as companies, banks, NGOs.
* The PK `organizationId` is a UUID FK to core.resource.resourceId.
*/
organization: type.Object(
{
organizationId: type.uuid(),
legalName: type.stringNotNull(),
tradingName: type.stringNull(),
registrationNumber: type.stringNull(),
taxId: type.stringNull(),
establishedDate: type.dateNull(),
industry: type.stringNull(),
website: type.stringNull(),
notes: type.stringNull(),
},
{
constraints: {
primaryKey: 'organizationId',
foreign: {
organizationId: 'core.resource.resourceId',
},
},
},
),
/**
* Organizational units — departments, branches, divisions, and teams.
*
* The PK `unitId` is a UUID FK to core.resource.resourceId. Hierarchy
* relationships (unit → organization, child → parent unit) are
* stored in core.triple with predicates "belongsTo" and "isPartOf".
*/
unit: type.Object(
{
unitId: type.uuid(),
unitName: type.stringNotNull(),
unitType: type.stringNull({maxLength: 20}),
notes: type.stringNull(),
},
{
constraints: {
primaryKey: 'unitId',
foreign: {
unitId: 'core.resource.resourceId',
},
},
},
),
/**
* Contact details — email addresses, phone numbers, etc.
*
* Linked to any party resource (person, organization, unit) via
* `partyResourceId` → core.resource.resourceId.
*/
contact: type.Object(
{
partyContactId: type.increment(),
partyResourceId: type.uidNotNull(),
contactType: type.stringNotNull({maxLength: 20}),
contactValue: type.stringNotNull(),
isPrimary: type.booleanNotNull(),
},
{
constraints: {
foreign: {
partyResourceId: 'core.resource.resourceId',
},
},
},
),
/**
* Addresses — physical locations for persons and organizations.
*
* Linked via `partyResourceId`. Supports multiple address types (home,
* work, billing, shipping) per party.
*/
address: type.Object(
{
partyAddressId: type.increment(),
partyResourceId: type.uidNotNull(),
addressType: type.stringNull({maxLength: 20}),
streetAddress: type.stringNull(),
city: type.stringNull(),
stateProvince: type.stringNull(),
postalCode: type.stringNull(),
countryId: type.uidNull(),
isPrimary: type.booleanNotNull(),
},
{
constraints: {
foreign: {
partyResourceId: 'core.resource.resourceId',
},
},
},
),
/**
* Identifiers — government-issued or official IDs for persons and organizations.
*
* Linked via `partyResourceId`. Examples: passport, national ID, tax ID,
* drivers license, social security number, business registration.
*/
identifier: type.Object(
{
partyIdentifierId: type.increment(),
partyResourceId: type.uidNotNull(),
identifierType: type.stringNotNull({maxLength: 30}),
identifierValue: type.stringNotNull(),
issuingAuthority: type.stringNull(),
issuedDate: type.dateNull(),
expiryDate: type.dateNull(),
},
{
constraints: {
foreign: {
partyResourceId: 'core.resource.resourceId',
},
},
},
),
}));
|