@pattern-stack/codegen 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/README.md +51 -0
- package/consumer-skills/codegen/SKILL.md +32 -0
- package/consumer-skills/entities/SKILL.md +2 -0
- package/consumer-skills/events/authoring-events.md +31 -0
- package/dist/{chunk-COGHTKXY.js → chunk-27ETSJ2X.js} +2 -2
- package/dist/{chunk-X6BP6LI5.js → chunk-3YCUIGPG.js} +10 -10
- package/dist/{chunk-BK5ICA2F.js → chunk-4MVGAMUA.js} +4 -4
- package/dist/{chunk-LQ6PYFU6.js → chunk-4OC5MSHO.js} +47 -1
- package/dist/chunk-4OC5MSHO.js.map +1 -0
- package/dist/{chunk-3A34R6CI.js → chunk-5LXOJGO2.js} +4 -4
- package/dist/{chunk-T6C4LFLC.js → chunk-7YGORYZD.js} +4 -4
- package/dist/{chunk-PKDS6QIJ.js → chunk-ATVGYF3D.js} +7 -7
- package/dist/{chunk-2TVVBC53.js → chunk-BORNCTH3.js} +2 -2
- package/dist/{chunk-7MMS36AN.js → chunk-CUSMC2KK.js} +10 -10
- package/dist/{chunk-V4AF6DI4.js → chunk-DUBZOXJC.js} +9 -2
- package/dist/{chunk-V4AF6DI4.js.map → chunk-DUBZOXJC.js.map} +1 -1
- package/dist/chunk-DUUCU77W.js +211 -0
- package/dist/chunk-DUUCU77W.js.map +1 -0
- package/dist/{chunk-OFRRBC7M.js → chunk-E2BRT5IB.js} +15 -1
- package/dist/chunk-E2BRT5IB.js.map +1 -0
- package/dist/{chunk-VQOAATIG.js → chunk-FLYF76CU.js} +4 -4
- package/dist/{chunk-43SBT72G.js → chunk-I6UXRJ3Q.js} +4 -4
- package/dist/{chunk-VHAR2BGH.js → chunk-INO47JXD.js} +5 -5
- package/dist/{chunk-BGULBWKJ.js → chunk-JOBQ6RUU.js} +1 -1
- package/dist/chunk-JOBQ6RUU.js.map +1 -0
- package/dist/{chunk-C5E7H553.js → chunk-KBO5OOON.js} +4 -4
- package/dist/{chunk-R4BPUUB5.js → chunk-KHQ72A5F.js} +54 -6
- package/dist/chunk-KHQ72A5F.js.map +1 -0
- package/dist/{chunk-CFFTPWHM.js → chunk-KK5A7B2T.js} +70 -5
- package/dist/chunk-KK5A7B2T.js.map +1 -0
- package/dist/{chunk-RKNW56RU.js → chunk-LARB26EI.js} +73 -6
- package/dist/chunk-LARB26EI.js.map +1 -0
- package/dist/{chunk-2VGVSL2D.js → chunk-LQXBQO72.js} +6 -6
- package/dist/{chunk-K2I6XIK5.js → chunk-MVKW2BCR.js} +2 -2
- package/dist/{chunk-EWYI5GGJ.js → chunk-NYJYK6J4.js} +15 -15
- package/dist/{chunk-IN3EWFB4.js → chunk-QSJ3J4HE.js} +6 -6
- package/dist/{chunk-TBGTMALE.js → chunk-SGSWVNNB.js} +4 -4
- package/dist/chunk-SYVZ4MD2.js +1 -0
- package/dist/{chunk-NXHL5YII.js → chunk-T6SCOJF4.js} +4 -4
- package/dist/{chunk-YZLBU6O2.js → chunk-WKNOEVWQ.js} +5 -5
- package/dist/runtime/base-classes/index.js +17 -17
- package/dist/runtime/subsystems/auth/auth.module.js +3 -3
- package/dist/runtime/subsystems/auth/index.js +10 -10
- package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js +2 -2
- package/dist/runtime/subsystems/bridge/bridge-delivery.drizzle-backend.js +3 -3
- package/dist/runtime/subsystems/bridge/bridge-delivery.schema.js +2 -2
- package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js +6 -6
- package/dist/runtime/subsystems/bridge/bridge.module.js +18 -18
- package/dist/runtime/subsystems/bridge/index.js +21 -21
- package/dist/runtime/subsystems/cache/cache.drizzle-backend.js +2 -2
- package/dist/runtime/subsystems/cache/cache.module.js +3 -3
- package/dist/runtime/subsystems/cache/index.js +5 -5
- package/dist/runtime/subsystems/events/domain-events.schema.js +1 -1
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.d.ts +19 -32
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +3 -3
- package/dist/runtime/subsystems/events/event-bus.memory-backend.d.ts +18 -1
- package/dist/runtime/subsystems/events/event-bus.memory-backend.js +1 -1
- package/dist/runtime/subsystems/events/event-bus.protocol.d.ts +45 -1
- package/dist/runtime/subsystems/events/event-scheduler.d.ts +96 -0
- package/dist/runtime/subsystems/events/event-scheduler.js +25 -0
- package/dist/runtime/subsystems/events/event-scheduler.js.map +1 -0
- package/dist/runtime/subsystems/events/events-errors.d.ts +12 -1
- package/dist/runtime/subsystems/events/events-errors.js +5 -3
- package/dist/runtime/subsystems/events/events.module.d.ts +41 -2
- package/dist/runtime/subsystems/events/events.module.js +11 -8
- package/dist/runtime/subsystems/events/generated/bus.js +3 -3
- package/dist/runtime/subsystems/events/generated/index.js +3 -3
- package/dist/runtime/subsystems/events/generated/registry.d.ts +6 -0
- package/dist/runtime/subsystems/events/generated/registry.js +1 -1
- package/dist/runtime/subsystems/events/index.d.ts +4 -3
- package/dist/runtime/subsystems/events/index.js +38 -14
- package/dist/runtime/subsystems/index.d.ts +1 -0
- package/dist/runtime/subsystems/index.js +117 -116
- package/dist/runtime/subsystems/integration/build-change-source.js +2 -2
- package/dist/runtime/subsystems/integration/index.js +36 -36
- package/dist/runtime/subsystems/integration/integration.module.js +4 -4
- package/dist/runtime/subsystems/jobs/index.js +33 -33
- package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js +5 -5
- package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js +3 -3
- package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +2 -2
- package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js +2 -2
- package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +3 -3
- package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js +3 -3
- package/dist/runtime/subsystems/jobs/job-worker.js +2 -2
- package/dist/runtime/subsystems/jobs/job-worker.module.js +11 -11
- package/dist/runtime/subsystems/jobs/jobs-domain.module.js +9 -9
- package/dist/runtime/subsystems/storage/index.js +4 -4
- package/dist/runtime/subsystems/storage/storage.module.js +2 -2
- package/dist/src/cli/index.js +168 -22
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/index.js +12 -12
- package/package.json +1 -1
- package/runtime/subsystems/events/domain-events.schema.ts +16 -0
- package/runtime/subsystems/events/event-bus.drizzle-backend.ts +103 -1
- package/runtime/subsystems/events/event-bus.memory-backend.ts +57 -1
- package/runtime/subsystems/events/event-bus.protocol.ts +47 -0
- package/runtime/subsystems/events/event-scheduler.ts +351 -0
- package/runtime/subsystems/events/events-errors.ts +14 -0
- package/runtime/subsystems/events/events.module.ts +78 -1
- package/runtime/subsystems/events/generated/registry.ts +1 -0
- package/runtime/subsystems/events/index.ts +25 -3
- package/dist/chunk-BGULBWKJ.js.map +0 -1
- package/dist/chunk-CFFTPWHM.js.map +0 -1
- package/dist/chunk-FN2PYDPP.js +0 -1
- package/dist/chunk-LQ6PYFU6.js.map +0 -1
- package/dist/chunk-OFRRBC7M.js.map +0 -1
- package/dist/chunk-R4BPUUB5.js.map +0 -1
- package/dist/chunk-RKNW56RU.js.map +0 -1
- /package/dist/{chunk-COGHTKXY.js.map → chunk-27ETSJ2X.js.map} +0 -0
- /package/dist/{chunk-X6BP6LI5.js.map → chunk-3YCUIGPG.js.map} +0 -0
- /package/dist/{chunk-BK5ICA2F.js.map → chunk-4MVGAMUA.js.map} +0 -0
- /package/dist/{chunk-3A34R6CI.js.map → chunk-5LXOJGO2.js.map} +0 -0
- /package/dist/{chunk-T6C4LFLC.js.map → chunk-7YGORYZD.js.map} +0 -0
- /package/dist/{chunk-PKDS6QIJ.js.map → chunk-ATVGYF3D.js.map} +0 -0
- /package/dist/{chunk-2TVVBC53.js.map → chunk-BORNCTH3.js.map} +0 -0
- /package/dist/{chunk-7MMS36AN.js.map → chunk-CUSMC2KK.js.map} +0 -0
- /package/dist/{chunk-VQOAATIG.js.map → chunk-FLYF76CU.js.map} +0 -0
- /package/dist/{chunk-43SBT72G.js.map → chunk-I6UXRJ3Q.js.map} +0 -0
- /package/dist/{chunk-VHAR2BGH.js.map → chunk-INO47JXD.js.map} +0 -0
- /package/dist/{chunk-C5E7H553.js.map → chunk-KBO5OOON.js.map} +0 -0
- /package/dist/{chunk-2VGVSL2D.js.map → chunk-LQXBQO72.js.map} +0 -0
- /package/dist/{chunk-K2I6XIK5.js.map → chunk-MVKW2BCR.js.map} +0 -0
- /package/dist/{chunk-EWYI5GGJ.js.map → chunk-NYJYK6J4.js.map} +0 -0
- /package/dist/{chunk-IN3EWFB4.js.map → chunk-QSJ3J4HE.js.map} +0 -0
- /package/dist/{chunk-TBGTMALE.js.map → chunk-SGSWVNNB.js.map} +0 -0
- /package/dist/{chunk-FN2PYDPP.js.map → chunk-SYVZ4MD2.js.map} +0 -0
- /package/dist/{chunk-NXHL5YII.js.map → chunk-T6SCOJF4.js.map} +0 -0
- /package/dist/{chunk-YZLBU6O2.js.map → chunk-WKNOEVWQ.js.map} +0 -0
|
@@ -625,6 +625,22 @@ var RetrySchema = z2.object({
|
|
|
625
625
|
attempts: z2.number().int().min(0).max(20),
|
|
626
626
|
backoff: z2.enum(EVENT_BACKOFF_STRATEGIES)
|
|
627
627
|
}).strict();
|
|
628
|
+
var DURATION_RE = /^\s*[0-9]*\.?[0-9]+\s*(ms|s|m|h|d)\s*$/;
|
|
629
|
+
var ScheduleSchema = z2.object({
|
|
630
|
+
every: z2.union([
|
|
631
|
+
z2.string().regex(
|
|
632
|
+
DURATION_RE,
|
|
633
|
+
"schedule.every must be a duration like '1h', '30m', '15s', '500ms', '1d'"
|
|
634
|
+
),
|
|
635
|
+
z2.number().positive().finite()
|
|
636
|
+
]),
|
|
637
|
+
/** Epoch-anchored slot boundaries (default true). */
|
|
638
|
+
align: z2.boolean().optional().default(true),
|
|
639
|
+
/** Backfill missed slots on recovery (default false → run once). */
|
|
640
|
+
catchUp: z2.boolean().optional().default(false),
|
|
641
|
+
/** Upper bound on `catchUp` backfill (default 1000). */
|
|
642
|
+
maxCatchUpSlots: z2.number().int().positive().optional().default(1e3)
|
|
643
|
+
}).strict();
|
|
628
644
|
var SNAKE_CASE_RE = /^[a-z][a-z0-9_]*$/;
|
|
629
645
|
var EventDefinitionSchemaCore = z2.object({
|
|
630
646
|
type: z2.string().regex(
|
|
@@ -645,6 +661,9 @@ var EventDefinitionSchemaCore = z2.object({
|
|
|
645
661
|
attempts: 3,
|
|
646
662
|
backoff: "exponential"
|
|
647
663
|
}),
|
|
664
|
+
// ADR-039 — declarative time-based emission. Optional; when present the
|
|
665
|
+
// platform emits this event on the given cadence (see ScheduleSchema).
|
|
666
|
+
schedule: ScheduleSchema.optional(),
|
|
648
667
|
version: z2.number().int().min(1).optional().default(1),
|
|
649
668
|
description: z2.string().optional()
|
|
650
669
|
}).strict();
|
|
@@ -665,6 +684,13 @@ var EventDefinitionSchemaRefined = EventDefinitionSchemaCore.superRefine(
|
|
|
665
684
|
path: ["direction"]
|
|
666
685
|
});
|
|
667
686
|
}
|
|
687
|
+
if (data.schedule !== void 0) {
|
|
688
|
+
ctx.addIssue({
|
|
689
|
+
code: z2.ZodIssueCode.custom,
|
|
690
|
+
message: `Event '${data.type}' is tier:audit; 'schedule' is not allowed on audit events (they route to no pool and cannot drive the bridge). Make it a domain event with a direction. See ADR-039.`,
|
|
691
|
+
path: ["schedule"]
|
|
692
|
+
});
|
|
693
|
+
}
|
|
668
694
|
return;
|
|
669
695
|
}
|
|
670
696
|
if (data.direction === void 0) {
|
|
@@ -1011,6 +1037,12 @@ var ClientSchema = z5.object({
|
|
|
1011
1037
|
class: ImportRefSchema,
|
|
1012
1038
|
base_url: z5.string().url("client.base_url must be an absolute URL")
|
|
1013
1039
|
}).strict();
|
|
1040
|
+
var DisplaySchema = z5.object({
|
|
1041
|
+
category: z5.string().optional(),
|
|
1042
|
+
blurb: z5.string().optional(),
|
|
1043
|
+
// Sub-line shown on an unconnected ("available") tile.
|
|
1044
|
+
hint: z5.string().optional()
|
|
1045
|
+
}).strict();
|
|
1014
1046
|
var ProviderDefinitionSchema = z5.object({
|
|
1015
1047
|
// Provider id — the canonical string used as detection: keys, audit rows,
|
|
1016
1048
|
// subscription rows. kebab/lower; unique across definitions/providers/
|
|
@@ -1020,19 +1052,49 @@ var ProviderDefinitionSchema = z5.object({
|
|
|
1020
1052
|
"slug must be kebab-case lower (e.g. 'google', 'hubspot')"
|
|
1021
1053
|
),
|
|
1022
1054
|
display_name: z5.string().optional(),
|
|
1023
|
-
|
|
1024
|
-
client
|
|
1055
|
+
// Lifecycle: 'active' providers drive backend provider/adapter emission
|
|
1056
|
+
// and require auth + client. 'planned' providers are roadmap stubs — they
|
|
1057
|
+
// appear in the frontend catalog (as unconnectable tiles) but are skipped
|
|
1058
|
+
// by all backend emission and by the surface/import cross-checks, so a
|
|
1059
|
+
// stub can exist before its surface has entities or its strategy/client
|
|
1060
|
+
// are written.
|
|
1061
|
+
status: z5.enum(["active", "planned"]).default("active"),
|
|
1062
|
+
// Frontend catalog presentation (see DisplaySchema).
|
|
1063
|
+
display: DisplaySchema.optional(),
|
|
1064
|
+
// Required iff status === 'active'; see superRefine below.
|
|
1065
|
+
auth: AuthSchema.optional(),
|
|
1066
|
+
client: ClientSchema.optional(),
|
|
1025
1067
|
// Surfaces this provider serves (ADR-0006: surfaces span contexts — one
|
|
1026
1068
|
// Google OAuth feeds calendar+mail+transcript). Each must reference a real
|
|
1027
1069
|
// `surface:` declared on some entity; that cross-check is in
|
|
1028
|
-
// validate-providers.ts. Non-empty enforced here.
|
|
1070
|
+
// validate-providers.ts (skipped for 'planned'). Non-empty enforced here.
|
|
1029
1071
|
surfaces: z5.array(z5.string()).min(1, "surfaces must list at least one surface"),
|
|
1030
1072
|
// Optional auth lifecycle hints consumed by provider-module emission (D2).
|
|
1031
1073
|
// `refresh_behavior` is left as a free string in D1 — its domain firms up
|
|
1032
1074
|
// when D2 consumes it; carrying it now keeps the YAML lossless.
|
|
1033
1075
|
token_lifetime: z5.number().int().positive().optional(),
|
|
1034
1076
|
refresh_behavior: z5.string().optional()
|
|
1035
|
-
}).strict()
|
|
1077
|
+
}).strict().superRefine((def, ctx) => {
|
|
1078
|
+
if (def.status === "active") {
|
|
1079
|
+
if (!def.auth) {
|
|
1080
|
+
ctx.addIssue({
|
|
1081
|
+
code: z5.ZodIssueCode.custom,
|
|
1082
|
+
message: "auth is required when status is 'active'",
|
|
1083
|
+
path: ["auth"]
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
if (!def.client) {
|
|
1087
|
+
ctx.addIssue({
|
|
1088
|
+
code: z5.ZodIssueCode.custom,
|
|
1089
|
+
message: "client is required when status is 'active'",
|
|
1090
|
+
path: ["client"]
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
function isActiveProvider(def) {
|
|
1096
|
+
return def.status !== "planned";
|
|
1097
|
+
}
|
|
1036
1098
|
|
|
1037
1099
|
// src/utils/yaml-loader.ts
|
|
1038
1100
|
function loadEntityFromYaml(filePath) {
|
|
@@ -1843,6 +1905,7 @@ function validateProviders(providers, opts) {
|
|
|
1843
1905
|
}
|
|
1844
1906
|
for (const { definition, filePath } of providers) {
|
|
1845
1907
|
const { slug } = definition;
|
|
1908
|
+
if (definition.status === "planned") continue;
|
|
1846
1909
|
for (const surface of definition.surfaces) {
|
|
1847
1910
|
if (!knownSurfaces.has(surface)) {
|
|
1848
1911
|
const known = [...knownSurfaces].sort().join(", ") || "(none declared)";
|
|
@@ -1864,6 +1927,7 @@ function validateProviders(providers, opts) {
|
|
|
1864
1927
|
sourceRoot: opts.sourceRoot,
|
|
1865
1928
|
aliases: opts.aliases
|
|
1866
1929
|
};
|
|
1930
|
+
if (!isActiveProvider(definition)) continue;
|
|
1867
1931
|
const refs = [
|
|
1868
1932
|
{ field: "auth.strategy", ref: definition.auth.strategy },
|
|
1869
1933
|
{ field: "client.class", ref: definition.client.class }
|
|
@@ -4064,6 +4128,7 @@ export {
|
|
|
4064
4128
|
validateJunctionDefinition,
|
|
4065
4129
|
safeValidateJunctionDefinition,
|
|
4066
4130
|
parseImportRef,
|
|
4131
|
+
isActiveProvider,
|
|
4067
4132
|
loadEntityFromYaml,
|
|
4068
4133
|
loadEntitiesFromYaml,
|
|
4069
4134
|
loadRelationshipFromYaml,
|
|
@@ -4124,4 +4189,4 @@ export {
|
|
|
4124
4189
|
analyzeDomain,
|
|
4125
4190
|
validateEntities
|
|
4126
4191
|
};
|
|
4127
|
-
//# sourceMappingURL=chunk-
|
|
4192
|
+
//# sourceMappingURL=chunk-KK5A7B2T.js.map
|