Format playground examples

This commit is contained in:
2026-07-09 18:54:29 +09:00
parent 0a8c261545
commit 09a84264ab
@@ -5,33 +5,33 @@ export const playgroundExamples = [
activePath: 'main.dcdl', activePath: 'main.dcdl',
files: { files: {
'main.dcdl': `let 'main.dcdl': `let
schema = import "./schemas/service.dcdl"; schema = import "./schemas/service.dcdl";
prod = import "./env/prod.dcdl"; prod = import "./env/prod.dcdl";
shared = import "./shared/tags.dcdl"; shared = import "./shared/tags.dcdl";
in in
schema.Service & prod.ServicePatch & { schema.Service & prod.ServicePatch & {
name = "api"; name = "api";
image = "registry.example.com/api:2026-06-24"; image = "registry.example.com/api:2026-06-24";
port = 9000 + 443; port = 9000 + 443;
public = prod.is_public && 9000 + 443 > 9000; public = prod.is_public && 9000 + 443 > 9000;
tags = shared.common ++ ["api", "edge"]; tags = shared.common ++ ["api", "edge"];
} }
`, `,
'schemas/service.dcdl': `Service = { 'schemas/service.dcdl': `Service = {
name = String; name = String;
image = String; image = String;
port = Int & > 443 default 8443; port = Int & > 443 default 8443;
replicas = Int & > 0 default 2; replicas = Int & > 0 default 2;
public = Bool default false; public = Bool default false;
feature.metrics = Bool default true; feature.metrics = Bool default true;
feature.tracing = Bool default false; feature.tracing = Bool default false;
}; };
`, `,
'env/prod.dcdl': `is_public = true; 'env/prod.dcdl': `is_public = true;
ServicePatch = { ServicePatch = {
replicas = 3; replicas = 3;
feature.tracing = true; feature.tracing = true;
}; };
`, `,
'shared/tags.dcdl': `common = ["decodal", "prod"]; 'shared/tags.dcdl': `common = ["decodal", "prod"];
@@ -44,24 +44,24 @@ ServicePatch = {
activePath: 'main.dcdl', activePath: 'main.dcdl',
files: { files: {
'main.dcdl': `let 'main.dcdl': `let
policy = import "./policy/base.dcdl"; policy = import "./policy/base.dcdl";
teams = import "./policy/teams.dcdl"; teams = import "./policy/teams.dcdl";
env = "prod"; env = "prod";
in in
{ {
service = "payments"; service = "payments";
readers = policy.defaultReaders ++ teams.observability; readers = policy.defaultReaders ++ teams.observability;
writers = policy.defaultWriters ++ teams.payments; writers = policy.defaultWriters ++ teams.payments;
admins = match env { admins = match env {
"prod": policy.breakglassAdmins; "prod": policy.breakglassAdmins;
_: teams.platform; _: teams.platform;
}; };
audit.required = env == "prod"; audit.required = env == "prod";
audit.retention_days = match env { audit.retention_days = match env {
"prod": 365; "prod": 365;
_: 30; _: 30;
}; };
} }
`, `,
'policy/base.dcdl': `defaultReaders = ["group:engineering", "group:support"]; 'policy/base.dcdl': `defaultReaders = ["group:engineering", "group:support"];
defaultWriters = ["group:platform"]; defaultWriters = ["group:platform"];
@@ -79,27 +79,27 @@ observability = ["group:observability"];
activePath: 'main.dcdl', activePath: 'main.dcdl',
files: { files: {
'main.dcdl': `let 'main.dcdl': `let
schema = import "./schemas/worker.dcdl"; schema = import "./schemas/worker.dcdl";
routes = import "./routes.dcdl"; routes = import "./routes.dcdl";
production = true; production = true;
in in
schema.Worker & { schema.Worker & {
name = "decodal-docs"; name = "decodal-docs";
compatibility_date = "2026-06-15"; compatibility_date = "2026-06-15";
workers_dev = !production; workers_dev = !production;
route.host = routes.primary_host; route.host = routes.primary_host;
route.paths = routes.docs_paths ++ routes.playground_paths; route.paths = routes.docs_paths ++ routes.playground_paths;
cache.ttl_seconds = 60 * 60; cache.ttl_seconds = 60 * 60;
cache.bypass = !production; cache.bypass = !production;
} }
`, `,
'schemas/worker.dcdl': `Worker = { 'schemas/worker.dcdl': `Worker = {
name = String; name = String;
compatibility_date = String; compatibility_date = String;
workers_dev = Bool default false; workers_dev = Bool default false;
route.host = String; route.host = String;
cache.ttl_seconds = Int & >= 0 default 300; cache.ttl_seconds = Int & >= 0 default 300;
cache.bypass = Bool default false; cache.bypass = Bool default false;
}; };
`, `,
'routes.dcdl': `primary_host = "decodal.example.com"; 'routes.dcdl': `primary_host = "decodal.example.com";
@@ -114,38 +114,38 @@ playground_paths = ["/playground/*"];
activePath: 'main.dcdl', activePath: 'main.dcdl',
files: { files: {
'main.dcdl': `let 'main.dcdl': `let
schema = import "./schemas/pipeline.dcdl"; schema = import "./schemas/pipeline.dcdl";
presets = import "./presets/batch.dcdl"; presets = import "./presets/batch.dcdl";
env = "staging"; env = "staging";
in in
schema.Pipeline & presets.Batch & { schema.Pipeline & presets.Batch & {
name = "events-rollup"; name = "events-rollup";
source.topic = "events.raw"; source.topic = "events.raw";
sink.table = "analytics.events_daily"; sink.table = "analytics.events_daily";
workers = match env { workers = match env {
"prod": 8; "prod": 8;
"staging": 3; "staging": 3;
_: 1; _: 1;
}; };
alerts.enabled = env != "dev"; alerts.enabled = env != "dev";
transforms = presets.standardTransforms ++ ["dedupe", "aggregate_daily"]; transforms = presets.standardTransforms ++ ["dedupe", "aggregate_daily"];
} }
`, `,
'schemas/pipeline.dcdl': `Pipeline = { 'schemas/pipeline.dcdl': `Pipeline = {
name = String; name = String;
source.topic = String; source.topic = String;
sink.table = String; sink.table = String;
workers = Int & > 0 default 1; workers = Int & > 0 default 1;
batch.size = Int & >= 100 default 1000; batch.size = Int & >= 100 default 1000;
batch.timeout_seconds = Int & > 0 default 60; batch.timeout_seconds = Int & > 0 default 60;
alerts.enabled = Bool default false; alerts.enabled = Bool default false;
}; };
`, `,
'presets/batch.dcdl': `standardTransforms = ["parse_json", "validate_schema", "enrich_metadata"]; 'presets/batch.dcdl': `standardTransforms = ["parse_json", "validate_schema", "enrich_metadata"];
Batch = { Batch = {
batch.size = 5000; batch.size = 5000;
batch.timeout_seconds = 30 + 30; batch.timeout_seconds = 30 + 30;
}; };
`, `,
}, },
@@ -156,17 +156,17 @@ Batch = {
activePath: 'main.dcdl', activePath: 'main.dcdl',
files: { files: {
'main.dcdl': `let 'main.dcdl': `let
schema = import "./schemas/service.dcdl"; schema = import "./schemas/service.dcdl";
in in
schema.Service & { schema.Service & {
name = "broken-api"; name = "broken-api";
port = 442; port = 442;
} }
`, `,
'schemas/service.dcdl': `Service = { 'schemas/service.dcdl': `Service = {
name = String; name = String;
port = Int & > 443 default 8443; port = Int & > 443 default 8443;
replicas = Int & > 0 default 2; replicas = Int & > 0 default 2;
}; };
`, `,
}, },