Add the canonical data product template
Moves the data product template from semprini-blog-dataproducts, as adapted to the semprini-data domain platform, into canonical_data_product/. Its worked example passed 9 of 9 checks on the domain platform on 2026-09-17. Adds agent-canonical-product, the blog's agent-product adapted to generate a product into a domain repository from a declaration in the domain's model repository, and README/CLAUDE.md describing the template catalogue, the product contract with the domain platform, and team ownership. Source-aligned and experience templates are planned. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
commit
62a3714562
30 files changed
+1529
No files matched your search
@@ -0,0 +1,13 @@
|
||||
-- Example Address: operational data store schema (runs on the postgres service).
|
||||
|
||||
CREATE SCHEMA example_address;
|
||||
|
||||
COMMENT ON SCHEMA example_address IS E'@graphql({"inflect_names": true, "introspection": true, "max_rows": 100})';
|
||||
|
||||
CREATE FUNCTION example_address.set_updated_at() RETURNS trigger
|
||||
LANGUAGE plpgsql AS $$
|
||||
BEGIN
|
||||
NEW.updated_at := now();
|
||||
RETURN NEW;
|
||||
END
|
||||
$$;
|
||||
@@ -0,0 +1,33 @@
|
||||
-- Example Address: operational tables (PostgreSQL 17).
|
||||
-- Source: entities/address.md (existence: independent, mutability: reference).
|
||||
|
||||
CREATE TABLE example_address.address (
|
||||
address_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
address_type text CHECK (address_type IN ('Street Address', 'PO Box', 'Registered Office', 'Overseas Address')), -- enum:Address Type
|
||||
address_line_1 text,
|
||||
address_line_2 text,
|
||||
suburb text,
|
||||
city text,
|
||||
state_or_region text,
|
||||
postcode text,
|
||||
country text NOT NULL, -- constraint: Country Required
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
CONSTRAINT street_address_requires_address_line_1 -- constraint of the same name in the model
|
||||
CHECK (address_type <> 'Street Address' OR address_line_1 IS NOT NULL)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE example_address.address IS 'The canonical record of a physical or postal location. Reference data shared across parties: a single Address record is referenced by all Contact Addresses at that location.';
|
||||
COMMENT ON COLUMN example_address.address.address_id IS 'Globally unique surrogate identifier for this physical location record. Immutable once assigned.';
|
||||
COMMENT ON COLUMN example_address.address.address_type IS 'The structural type of the address. Determines which fields are applicable.';
|
||||
COMMENT ON COLUMN example_address.address.address_line_1 IS 'The primary street address line, typically including street number and street name. For PO Box addresses, the PO Box number.';
|
||||
COMMENT ON COLUMN example_address.address.address_line_2 IS 'Secondary address line for suite, level, unit, or building name where applicable.';
|
||||
COMMENT ON COLUMN example_address.address.suburb IS 'The suburb or locality component of the address.';
|
||||
COMMENT ON COLUMN example_address.address.city IS 'The city or town.';
|
||||
COMMENT ON COLUMN example_address.address.state_or_region IS 'The state, territory, or region.';
|
||||
COMMENT ON COLUMN example_address.address.postcode IS 'The postal code, stored as a string to preserve leading zeros and support international formats.';
|
||||
COMMENT ON COLUMN example_address.address.country IS 'The country in which the address is located, as an ISO 3166-1 alpha-2 country code.';
|
||||
|
||||
CREATE TRIGGER address_set_updated_at
|
||||
BEFORE UPDATE ON example_address.address
|
||||
FOR EACH ROW EXECUTE FUNCTION example_address.set_updated_at();
|
||||
@@ -0,0 +1,26 @@
|
||||
-- Example Address: API surface (runs on the postgres service).
|
||||
|
||||
GRANT USAGE ON SCHEMA example_address TO anon;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA example_address TO anon;
|
||||
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA example_address TO anon;
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA example_address GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO anon;
|
||||
|
||||
-- The product's GraphQL endpoint: POST /rpc/example_address_graphql through PostgREST.
|
||||
-- pg_graphql reflects the schemas on the search_path, so the SET clause scopes the
|
||||
-- endpoint to this product's tables.
|
||||
CREATE FUNCTION api.example_address_graphql(
|
||||
query text,
|
||||
variables jsonb DEFAULT '{}'::jsonb,
|
||||
"operationName" text DEFAULT NULL,
|
||||
extensions jsonb DEFAULT NULL
|
||||
) RETURNS jsonb
|
||||
LANGUAGE sql
|
||||
SECURITY INVOKER
|
||||
SET search_path = example_address, graphql
|
||||
AS $$
|
||||
SELECT graphql.resolve(query, variables, "operationName", extensions);
|
||||
$$;
|
||||
|
||||
GRANT EXECUTE ON FUNCTION api.example_address_graphql(text, jsonb, text, jsonb) TO anon;
|
||||
|
||||
NOTIFY pgrst, 'reload schema';
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Example Address: sample rows (runs on the postgres service).
|
||||
|
||||
INSERT INTO example_address.address
|
||||
(address_id, address_type, address_line_1, address_line_2, suburb, city, state_or_region, postcode, country)
|
||||
VALUES
|
||||
('2f4c1a3e-0001-4a7b-9c11-000000000001', 'Street Address', '1 Queen Street', NULL, 'Auckland Central', 'Auckland', 'Auckland', '1010', 'NZ'),
|
||||
('2f4c1a3e-0001-4a7b-9c11-000000000002', 'PO Box', 'PO Box 123', NULL, NULL, 'Wellington', 'Wellington', '6140', 'NZ'),
|
||||
('2f4c1a3e-0001-4a7b-9c11-000000000003', 'Registered Office', 'Level 5, 100 Collins Street', NULL, NULL, 'Melbourne', 'VIC', '3000', 'AU');
|
||||
Reference in new issue
Block a user