@geekmidas/manifest 9.3.0 → 9.4.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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # @geekmidas/manifest
2
2
 
3
+ ## 9.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#334](https://github.com/geekmidas/toolbox/pull/334) [`b03c43d`](https://github.com/geekmidas/toolbox/commit/b03c43dfd2c86b1daa7f0a47f43e5fb2e518518b) Thanks [@geekmidas](https://github.com/geekmidas)! - Crons report to an uptime monitor with `.uptime()`, which replaces `.monitor()`
8
+
9
+ **Breaking:** `.monitor()` is removed from functions, crons, endpoints and `EndpointFactory`, along with the monitor hooks in the endpoint adaptors. The manifest's `monitoring` field is removed from routes, functions and crons.
10
+
11
+ A monitor only adds something a cron can't report itself: that it didn't run. A function or endpoint runs when it's called, so no ping is ever due, and its failures are already logged where they happen. So uptime is now set on crons alone:
12
+
13
+ ```ts
14
+ export const nightlyReport = c
15
+ .schedule("cron(0 8 * * MON-FRI)")
16
+ .uptime(heartbeat.betterStack("MONITORING_URL"))
17
+ .handle(async () => {});
18
+ ```
19
+
20
+ Calling `.uptime()` again replaces the monitor. `gkm build` records it on the cron's manifest entry as `uptime`, with the period the heartbeat should expect, derived from the schedule by `cronPeriod`:
21
+
22
+ ```ts
23
+ uptime: { type: 'heartbeat', provider: 'betterStack', env: 'MONITORING_URL', period: 259200 }
24
+ ```
25
+
26
+ `MonitorInfo` in `@geekmidas/manifest` is replaced by `UptimeInfo`.
27
+
3
28
  ## 9.3.0
4
29
 
5
30
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["field: ManifestField<T> | undefined"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Deployment manifest types — the build output of `gkm build` that enumerates a\n * project's deployable units (routes, functions, crons, subscribers, queues)\n * with the metadata an infrastructure layer needs to provision them.\n *\n * `gkm build` writes a single TypeScript module per provider\n * (`<out>/manifest/aws.ts`) of the form:\n *\n * ```ts\n * export const manifest = { routes: [...], functions: [...], ... } as const;\n * export type Route = (typeof manifest.routes)[number];\n * // ...derived types\n * ```\n *\n * This is the dependency-free data contract shared between the producer\n * (`@geekmidas/cli`) and consumers (e.g. `@geekmidas/cloud/sst`'s `fromManifest`\n * integrators).\n */\n\n/**\n * A manifest field is either a flat list or, when the build is partitioned\n * (e.g. by authorizer), an object keyed by partition name. Readonly-tolerant so\n * the `as const` generated manifest assigns cleanly.\n */\nexport type ManifestField<T> =\n\t| readonly T[]\n\t| Readonly<Record<string, readonly T[]>>;\n\n/** Flatten a manifest field (array or partitioned) into a plain array. */\nexport function flattenManifestField<T>(\n\tfield: ManifestField<T> | undefined,\n): T[] {\n\tif (!field) return [];\n\treturn Array.isArray(field)\n\t\t? [...field]\n\t\t: Object.values(field as Record<string, readonly T[]>).flat();\n}\n\n/**\n * A monitor set with `.monitor()`, so infrastructure can provision what it\n * reports to, e.g. create a heartbeat and set its URL in `env`.\n */\nexport interface MonitorInfo {\n\t/** The kind of monitor, e.g. `heartbeat`. */\n\ttype: string;\n\t/** The service it reports to, e.g. `betterStack`. Absent for a custom one. */\n\tprovider?: string;\n\t/** The environment variable it reads its target from. */\n\tenv?: string;\n}\n\n/** A single HTTP route. */\nexport interface RouteInfo {\n\t/** Route path, e.g. `/users/{id}`. */\n\tpath: string;\n\t/** HTTP method, e.g. `GET`. */\n\tmethod: string;\n\t/** Bundled handler entrypoint. */\n\thandler: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\t/** Required environment variables (a trailing `?` marks an optional var). */\n\tenvironment?: readonly string[];\n\t/** Authorizer name: `none`, `iam`, or a declared authorizer. */\n\tauthorizer: string;\n\t/** Monitors set with `.monitor()`; absent when there are none. */\n\tmonitoring?: readonly MonitorInfo[];\n}\n\n/** A standalone Lambda function. */\nexport interface FunctionInfo {\n\tname: string;\n\thandler: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n\t/** Monitors set with `.monitor()`; absent when there are none. */\n\tmonitoring?: readonly MonitorInfo[];\n}\n\n/** A scheduled (cron) function. */\nexport interface CronInfo {\n\tname: string;\n\thandler: string;\n\t/** Schedule expression, e.g. `rate(1 day)` or `cron(0 12 * * ? *)`. */\n\tschedule: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n\t/** Monitors set with `.monitor()`; absent when there are none. */\n\tmonitoring?: readonly MonitorInfo[];\n}\n\n/** An event subscriber function (topic/queue resolved by `transport`). */\nexport interface SubscriberInfo {\n\tname: string;\n\thandler: string;\n\tsubscribedEvents: readonly string[];\n\t/** Delivery transport — `topic` (SNS fan-out) or `queue` (SQS). */\n\ttransport?: 'topic' | 'queue';\n\t/** The {@link TopicInfo.name} this subscriber binds to (via `s.topic(topic)`). */\n\ttopic?: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n}\n\n/**\n * A pub/sub topic — fan-out. A *resource* (no handler): it declares the event\n * contract; producers publish via the derived publisher and {@link SubscriberInfo}s\n * bind to it. Infra provisions an SNS topic.\n */\nexport interface TopicInfo {\n\tname: string;\n\t/** The event type names this topic carries. */\n\tevents: readonly string[];\n\t/** Whether the topic is FIFO. */\n\tfifo?: boolean;\n}\n\n/** A queue worker — a queue and its single consumer. */\nexport interface QueueInfo {\n\tname: string;\n\thandler: string;\n\t/** SQS event-source batch size. */\n\tbatchSize?: number;\n\t/** Whether the queue is FIFO. */\n\tfifo?: boolean;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n}\n\n/**\n * The full deployment manifest — the shape of `export const manifest` in a\n * generated `manifest/<provider>.ts`. Each field is a {@link ManifestField}\n * (flat or partitioned).\n */\nexport interface Manifest {\n\troutes: ManifestField<RouteInfo>;\n\tfunctions?: ManifestField<FunctionInfo>;\n\tcrons?: ManifestField<CronInfo>;\n\tsubscribers?: ManifestField<SubscriberInfo>;\n\tqueues?: ManifestField<QueueInfo>;\n\ttopics?: ManifestField<TopicInfo>;\n}\n\nexport * from './cron';\n"],"mappings":";;;;AA6BA,SAAgB,qBACfA,OACM;AACN,MAAK,MAAO,QAAO,CAAE;AACrB,QAAO,MAAM,QAAQ,MAAM,GACxB,CAAC,GAAG,KAAM,IACV,OAAO,OAAO,MAAsC,CAAC,MAAM;AAC9D"}
1
+ {"version":3,"file":"index.cjs","names":["field: ManifestField<T> | undefined"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Deployment manifest types — the build output of `gkm build` that enumerates a\n * project's deployable units (routes, functions, crons, subscribers, queues)\n * with the metadata an infrastructure layer needs to provision them.\n *\n * `gkm build` writes a single TypeScript module per provider\n * (`<out>/manifest/aws.ts`) of the form:\n *\n * ```ts\n * export const manifest = { routes: [...], functions: [...], ... } as const;\n * export type Route = (typeof manifest.routes)[number];\n * // ...derived types\n * ```\n *\n * This is the dependency-free data contract shared between the producer\n * (`@geekmidas/cli`) and consumers (e.g. `@geekmidas/cloud/sst`'s `fromManifest`\n * integrators).\n */\n\n/**\n * A manifest field is either a flat list or, when the build is partitioned\n * (e.g. by authorizer), an object keyed by partition name. Readonly-tolerant so\n * the `as const` generated manifest assigns cleanly.\n */\nexport type ManifestField<T> =\n\t| readonly T[]\n\t| Readonly<Record<string, readonly T[]>>;\n\n/** Flatten a manifest field (array or partitioned) into a plain array. */\nexport function flattenManifestField<T>(\n\tfield: ManifestField<T> | undefined,\n): T[] {\n\tif (!field) return [];\n\treturn Array.isArray(field)\n\t\t? [...field]\n\t\t: Object.values(field as Record<string, readonly T[]>).flat();\n}\n\n/**\n * A cron's uptime monitor, set with `.uptime()`, so infrastructure can create\n * what it reports to, e.g. a heartbeat whose URL it sets in `env`.\n */\nexport interface UptimeInfo {\n\t/** The kind of monitor, e.g. `heartbeat`. */\n\ttype: string;\n\t/** The service it reports to, e.g. `betterStack`. Absent for a custom one. */\n\tprovider?: string;\n\t/** The environment variable it reads its target from. */\n\tenv?: string;\n\t/**\n\t * The longest gap between runs of the cron's schedule, in seconds: how\n\t * often the monitor should expect to hear from it (see `cronPeriod`).\n\t */\n\tperiod: number;\n}\n\n/** A single HTTP route. */\nexport interface RouteInfo {\n\t/** Route path, e.g. `/users/{id}`. */\n\tpath: string;\n\t/** HTTP method, e.g. `GET`. */\n\tmethod: string;\n\t/** Bundled handler entrypoint. */\n\thandler: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\t/** Required environment variables (a trailing `?` marks an optional var). */\n\tenvironment?: readonly string[];\n\t/** Authorizer name: `none`, `iam`, or a declared authorizer. */\n\tauthorizer: string;\n}\n\n/** A standalone Lambda function. */\nexport interface FunctionInfo {\n\tname: string;\n\thandler: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n}\n\n/** A scheduled (cron) function. */\nexport interface CronInfo {\n\tname: string;\n\thandler: string;\n\t/** Schedule, always the six-field AWS form, e.g. `cron(0 12 * * ? *)`. */\n\tschedule: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n\t/** Set with `.uptime()`; absent when the cron has none. */\n\tuptime?: UptimeInfo;\n}\n\n/** An event subscriber function (topic/queue resolved by `transport`). */\nexport interface SubscriberInfo {\n\tname: string;\n\thandler: string;\n\tsubscribedEvents: readonly string[];\n\t/** Delivery transport — `topic` (SNS fan-out) or `queue` (SQS). */\n\ttransport?: 'topic' | 'queue';\n\t/** The {@link TopicInfo.name} this subscriber binds to (via `s.topic(topic)`). */\n\ttopic?: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n}\n\n/**\n * A pub/sub topic — fan-out. A *resource* (no handler): it declares the event\n * contract; producers publish via the derived publisher and {@link SubscriberInfo}s\n * bind to it. Infra provisions an SNS topic.\n */\nexport interface TopicInfo {\n\tname: string;\n\t/** The event type names this topic carries. */\n\tevents: readonly string[];\n\t/** Whether the topic is FIFO. */\n\tfifo?: boolean;\n}\n\n/** A queue worker — a queue and its single consumer. */\nexport interface QueueInfo {\n\tname: string;\n\thandler: string;\n\t/** SQS event-source batch size. */\n\tbatchSize?: number;\n\t/** Whether the queue is FIFO. */\n\tfifo?: boolean;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n}\n\n/**\n * The full deployment manifest — the shape of `export const manifest` in a\n * generated `manifest/<provider>.ts`. Each field is a {@link ManifestField}\n * (flat or partitioned).\n */\nexport interface Manifest {\n\troutes: ManifestField<RouteInfo>;\n\tfunctions?: ManifestField<FunctionInfo>;\n\tcrons?: ManifestField<CronInfo>;\n\tsubscribers?: ManifestField<SubscriberInfo>;\n\tqueues?: ManifestField<QueueInfo>;\n\ttopics?: ManifestField<TopicInfo>;\n}\n\nexport * from './cron';\n"],"mappings":";;;;AA6BA,SAAgB,qBACfA,OACM;AACN,MAAK,MAAO,QAAO,CAAE;AACrB,QAAO,MAAM,QAAQ,MAAM,GACxB,CAAC,GAAG,KAAM,IACV,OAAO,OAAO,MAAsC,CAAC,MAAM;AAC9D"}
package/dist/index.d.cts CHANGED
@@ -29,16 +29,21 @@ type ManifestField<T> = readonly T[] | Readonly<Record<string, readonly T[]>>;
29
29
  /** Flatten a manifest field (array or partitioned) into a plain array. */
30
30
  declare function flattenManifestField<T>(field: ManifestField<T> | undefined): T[];
31
31
  /**
32
- * A monitor set with `.monitor()`, so infrastructure can provision what it
33
- * reports to, e.g. create a heartbeat and set its URL in `env`.
32
+ * A cron's uptime monitor, set with `.uptime()`, so infrastructure can create
33
+ * what it reports to, e.g. a heartbeat whose URL it sets in `env`.
34
34
  */
35
- interface MonitorInfo {
35
+ interface UptimeInfo {
36
36
  /** The kind of monitor, e.g. `heartbeat`. */
37
37
  type: string;
38
38
  /** The service it reports to, e.g. `betterStack`. Absent for a custom one. */
39
39
  provider?: string;
40
40
  /** The environment variable it reads its target from. */
41
41
  env?: string;
42
+ /**
43
+ * The longest gap between runs of the cron's schedule, in seconds: how
44
+ * often the monitor should expect to hear from it (see `cronPeriod`).
45
+ */
46
+ period: number;
42
47
  }
43
48
  /** A single HTTP route. */
44
49
  interface RouteInfo {
@@ -54,8 +59,6 @@ interface RouteInfo {
54
59
  environment?: readonly string[];
55
60
  /** Authorizer name: `none`, `iam`, or a declared authorizer. */
56
61
  authorizer: string;
57
- /** Monitors set with `.monitor()`; absent when there are none. */
58
- monitoring?: readonly MonitorInfo[];
59
62
  }
60
63
  /** A standalone Lambda function. */
61
64
  interface FunctionInfo {
@@ -64,20 +67,18 @@ interface FunctionInfo {
64
67
  timeout?: number;
65
68
  memorySize?: number;
66
69
  environment?: readonly string[];
67
- /** Monitors set with `.monitor()`; absent when there are none. */
68
- monitoring?: readonly MonitorInfo[];
69
70
  }
70
71
  /** A scheduled (cron) function. */
71
72
  interface CronInfo {
72
73
  name: string;
73
74
  handler: string;
74
- /** Schedule expression, e.g. `rate(1 day)` or `cron(0 12 * * ? *)`. */
75
+ /** Schedule, always the six-field AWS form, e.g. `cron(0 12 * * ? *)`. */
75
76
  schedule: string;
76
77
  timeout?: number;
77
78
  memorySize?: number;
78
79
  environment?: readonly string[];
79
- /** Monitors set with `.monitor()`; absent when there are none. */
80
- monitoring?: readonly MonitorInfo[];
80
+ /** Set with `.uptime()`; absent when the cron has none. */
81
+ uptime?: UptimeInfo;
81
82
  }
82
83
  /** An event subscriber function (topic/queue resolved by `transport`). */
83
84
  interface SubscriberInfo {
@@ -130,5 +131,5 @@ interface Manifest {
130
131
  topics?: ManifestField<TopicInfo>;
131
132
  }
132
133
  //#endregion
133
- export { CronConversion, CronConversionWarning, CronDialect, CronField, CronInfo, CronPeriodError, FunctionInfo, InvalidCronExpressionError, Manifest, ManifestField, MonitorInfo, ParsedCron, QueueInfo, RouteInfo, SubscriberInfo, TopicInfo, UnconvertibleCronExpressionError, cronPeriod, flattenManifestField, parseCron, toAwsCron, toUnixCron };
134
+ export { CronConversion, CronConversionWarning, CronDialect, CronField, CronInfo, CronPeriodError, FunctionInfo, InvalidCronExpressionError, Manifest, ManifestField, ParsedCron, QueueInfo, RouteInfo, SubscriberInfo, TopicInfo, UnconvertibleCronExpressionError, UptimeInfo, cronPeriod, flattenManifestField, parseCron, toAwsCron, toUnixCron };
134
135
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AAwBA;;;;;;AAEW;AAGX;;;;;AAEI;AAWJ;AAUA;AAkBA;AAWA;AAaA;AAkBA;AASA;AAiBiB,KAlHL,aAkHa,CAAA,CAAA,CAAA,GAAA,SAjHb,CAiHa,EAAA,GAhHtB,QAgHsB,CAhHb,MAgHa,CAAA,MAAA,EAAA,SAhHW,CAgHX,EAAA,CAAA,CAAA;;AACF,iBA9GP,oBA8GO,CAAA,CAAA,CAAA,CAAA,KAAA,EA7Gf,aA6Ge,CA7GD,CA6GC,CAAA,GAAA,SAAA,CAAA,EA5GpB,CA4GoB,EAAA;;;;;AAEd,UAnGQ,WAAA,CAmGR;EAAa;EACqB,IAA5B,EAAA,MAAA;EAAa;EACK,QAAvB,CAAA,EAAA,MAAA;EAAa;EACU,GAAvB,CAAA,EAAA,MAAA;AAAa;;UA5FN,SAAA;;;;;;;;;;;;;;wBAcM;;;UAIN,YAAA;;;;;;;wBAOM;;;UAIN,QAAA;;;;;;;;;wBASM;;;UAIN,cAAA;;;;;;;;;;;;;;;;;UAkBA,SAAA;;;;;;;;UASA,SAAA;;;;;;;;;;;;;;;;UAiBA,QAAA;UACR,cAAc;cACV,cAAc;UAClB,cAAc;gBACR,cAAc;WACnB,cAAc;WACd,cAAc"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AAwBA;;;;;;AAEW;AAGX;;;;;AAEI;AAWJ;AAeA;AAgBA;AASA;AAaA;AAkBA;AASA;AAiBiB,KAnHL,aAmHa,CAAA,CAAA,CAAA,GAAA,SAlHb,CAkHa,EAAA,GAjHtB,QAiHsB,CAjHb,MAiHa,CAAA,MAAA,EAAA,SAjHW,CAiHX,EAAA,CAAA,CAAA;;AACF,iBA/GP,oBA+GO,CAAA,CAAA,CAAA,CAAA,KAAA,EA9Gf,aA8Ge,CA9GD,CA8GC,CAAA,GAAA,SAAA,CAAA,EA7GpB,CA6GoB,EAAA;;;;;AAEd,UApGQ,UAAA,CAoGR;EAAa;EACqB,IAA5B,EAAA,MAAA;EAAa;EACK,QAAvB,CAAA,EAAA,MAAA;EAAa;EACU,GAAvB,CAAA,EAAA,MAAA;EAAa;;;;;;;UAxFN,SAAA;;;;;;;;;;;;;;;UAgBA,YAAA;;;;;;;;UASA,QAAA;;;;;;;;;WASP;;;UAIO,cAAA;;;;;;;;;;;;;;;;;UAkBA,SAAA;;;;;;;;UASA,SAAA;;;;;;;;;;;;;;;;UAiBA,QAAA;UACR,cAAc;cACV,cAAc;UAClB,cAAc;gBACR,cAAc;WACnB,cAAc;WACd,cAAc"}
package/dist/index.d.mts CHANGED
@@ -29,16 +29,21 @@ type ManifestField<T> = readonly T[] | Readonly<Record<string, readonly T[]>>;
29
29
  /** Flatten a manifest field (array or partitioned) into a plain array. */
30
30
  declare function flattenManifestField<T>(field: ManifestField<T> | undefined): T[];
31
31
  /**
32
- * A monitor set with `.monitor()`, so infrastructure can provision what it
33
- * reports to, e.g. create a heartbeat and set its URL in `env`.
32
+ * A cron's uptime monitor, set with `.uptime()`, so infrastructure can create
33
+ * what it reports to, e.g. a heartbeat whose URL it sets in `env`.
34
34
  */
35
- interface MonitorInfo {
35
+ interface UptimeInfo {
36
36
  /** The kind of monitor, e.g. `heartbeat`. */
37
37
  type: string;
38
38
  /** The service it reports to, e.g. `betterStack`. Absent for a custom one. */
39
39
  provider?: string;
40
40
  /** The environment variable it reads its target from. */
41
41
  env?: string;
42
+ /**
43
+ * The longest gap between runs of the cron's schedule, in seconds: how
44
+ * often the monitor should expect to hear from it (see `cronPeriod`).
45
+ */
46
+ period: number;
42
47
  }
43
48
  /** A single HTTP route. */
44
49
  interface RouteInfo {
@@ -54,8 +59,6 @@ interface RouteInfo {
54
59
  environment?: readonly string[];
55
60
  /** Authorizer name: `none`, `iam`, or a declared authorizer. */
56
61
  authorizer: string;
57
- /** Monitors set with `.monitor()`; absent when there are none. */
58
- monitoring?: readonly MonitorInfo[];
59
62
  }
60
63
  /** A standalone Lambda function. */
61
64
  interface FunctionInfo {
@@ -64,20 +67,18 @@ interface FunctionInfo {
64
67
  timeout?: number;
65
68
  memorySize?: number;
66
69
  environment?: readonly string[];
67
- /** Monitors set with `.monitor()`; absent when there are none. */
68
- monitoring?: readonly MonitorInfo[];
69
70
  }
70
71
  /** A scheduled (cron) function. */
71
72
  interface CronInfo {
72
73
  name: string;
73
74
  handler: string;
74
- /** Schedule expression, e.g. `rate(1 day)` or `cron(0 12 * * ? *)`. */
75
+ /** Schedule, always the six-field AWS form, e.g. `cron(0 12 * * ? *)`. */
75
76
  schedule: string;
76
77
  timeout?: number;
77
78
  memorySize?: number;
78
79
  environment?: readonly string[];
79
- /** Monitors set with `.monitor()`; absent when there are none. */
80
- monitoring?: readonly MonitorInfo[];
80
+ /** Set with `.uptime()`; absent when the cron has none. */
81
+ uptime?: UptimeInfo;
81
82
  }
82
83
  /** An event subscriber function (topic/queue resolved by `transport`). */
83
84
  interface SubscriberInfo {
@@ -130,5 +131,5 @@ interface Manifest {
130
131
  topics?: ManifestField<TopicInfo>;
131
132
  }
132
133
  //#endregion
133
- export { CronConversion, CronConversionWarning, CronDialect, CronField, CronInfo, CronPeriodError, FunctionInfo, InvalidCronExpressionError, Manifest, ManifestField, MonitorInfo, ParsedCron, QueueInfo, RouteInfo, SubscriberInfo, TopicInfo, UnconvertibleCronExpressionError, cronPeriod, flattenManifestField, parseCron, toAwsCron, toUnixCron };
134
+ export { CronConversion, CronConversionWarning, CronDialect, CronField, CronInfo, CronPeriodError, FunctionInfo, InvalidCronExpressionError, Manifest, ManifestField, ParsedCron, QueueInfo, RouteInfo, SubscriberInfo, TopicInfo, UnconvertibleCronExpressionError, UptimeInfo, cronPeriod, flattenManifestField, parseCron, toAwsCron, toUnixCron };
134
135
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AAwBA;;;;;;AAEW;AAGX;;;;;AAEI;AAWJ;AAUA;AAkBA;AAWA;AAaA;AAkBA;AASA;AAiBiB,KAlHL,aAkHa,CAAA,CAAA,CAAA,GAAA,SAjHb,CAiHa,EAAA,GAhHtB,QAgHsB,CAhHb,MAgHa,CAAA,MAAA,EAAA,SAhHW,CAgHX,EAAA,CAAA,CAAA;;AACF,iBA9GP,oBA8GO,CAAA,CAAA,CAAA,CAAA,KAAA,EA7Gf,aA6Ge,CA7GD,CA6GC,CAAA,GAAA,SAAA,CAAA,EA5GpB,CA4GoB,EAAA;;;;;AAEd,UAnGQ,WAAA,CAmGR;EAAa;EACqB,IAA5B,EAAA,MAAA;EAAa;EACK,QAAvB,CAAA,EAAA,MAAA;EAAa;EACU,GAAvB,CAAA,EAAA,MAAA;AAAa;;UA5FN,SAAA;;;;;;;;;;;;;;wBAcM;;;UAIN,YAAA;;;;;;;wBAOM;;;UAIN,QAAA;;;;;;;;;wBASM;;;UAIN,cAAA;;;;;;;;;;;;;;;;;UAkBA,SAAA;;;;;;;;UASA,SAAA;;;;;;;;;;;;;;;;UAiBA,QAAA;UACR,cAAc;cACV,cAAc;UAClB,cAAc;gBACR,cAAc;WACnB,cAAc;WACd,cAAc"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;AAwBA;;;;;;AAEW;AAGX;;;;;AAEI;AAWJ;AAeA;AAgBA;AASA;AAaA;AAkBA;AASA;AAiBiB,KAnHL,aAmHa,CAAA,CAAA,CAAA,GAAA,SAlHb,CAkHa,EAAA,GAjHtB,QAiHsB,CAjHb,MAiHa,CAAA,MAAA,EAAA,SAjHW,CAiHX,EAAA,CAAA,CAAA;;AACF,iBA/GP,oBA+GO,CAAA,CAAA,CAAA,CAAA,KAAA,EA9Gf,aA8Ge,CA9GD,CA8GC,CAAA,GAAA,SAAA,CAAA,EA7GpB,CA6GoB,EAAA;;;;;AAEd,UApGQ,UAAA,CAoGR;EAAa;EACqB,IAA5B,EAAA,MAAA;EAAa;EACK,QAAvB,CAAA,EAAA,MAAA;EAAa;EACU,GAAvB,CAAA,EAAA,MAAA;EAAa;;;;;;;UAxFN,SAAA;;;;;;;;;;;;;;;UAgBA,YAAA;;;;;;;;UASA,QAAA;;;;;;;;;WASP;;;UAIO,cAAA;;;;;;;;;;;;;;;;;UAkBA,SAAA;;;;;;;;UASA,SAAA;;;;;;;;;;;;;;;;UAiBA,QAAA;UACR,cAAc;cACV,cAAc;UAClB,cAAc;gBACR,cAAc;WACnB,cAAc;WACd,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["field: ManifestField<T> | undefined"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Deployment manifest types — the build output of `gkm build` that enumerates a\n * project's deployable units (routes, functions, crons, subscribers, queues)\n * with the metadata an infrastructure layer needs to provision them.\n *\n * `gkm build` writes a single TypeScript module per provider\n * (`<out>/manifest/aws.ts`) of the form:\n *\n * ```ts\n * export const manifest = { routes: [...], functions: [...], ... } as const;\n * export type Route = (typeof manifest.routes)[number];\n * // ...derived types\n * ```\n *\n * This is the dependency-free data contract shared between the producer\n * (`@geekmidas/cli`) and consumers (e.g. `@geekmidas/cloud/sst`'s `fromManifest`\n * integrators).\n */\n\n/**\n * A manifest field is either a flat list or, when the build is partitioned\n * (e.g. by authorizer), an object keyed by partition name. Readonly-tolerant so\n * the `as const` generated manifest assigns cleanly.\n */\nexport type ManifestField<T> =\n\t| readonly T[]\n\t| Readonly<Record<string, readonly T[]>>;\n\n/** Flatten a manifest field (array or partitioned) into a plain array. */\nexport function flattenManifestField<T>(\n\tfield: ManifestField<T> | undefined,\n): T[] {\n\tif (!field) return [];\n\treturn Array.isArray(field)\n\t\t? [...field]\n\t\t: Object.values(field as Record<string, readonly T[]>).flat();\n}\n\n/**\n * A monitor set with `.monitor()`, so infrastructure can provision what it\n * reports to, e.g. create a heartbeat and set its URL in `env`.\n */\nexport interface MonitorInfo {\n\t/** The kind of monitor, e.g. `heartbeat`. */\n\ttype: string;\n\t/** The service it reports to, e.g. `betterStack`. Absent for a custom one. */\n\tprovider?: string;\n\t/** The environment variable it reads its target from. */\n\tenv?: string;\n}\n\n/** A single HTTP route. */\nexport interface RouteInfo {\n\t/** Route path, e.g. `/users/{id}`. */\n\tpath: string;\n\t/** HTTP method, e.g. `GET`. */\n\tmethod: string;\n\t/** Bundled handler entrypoint. */\n\thandler: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\t/** Required environment variables (a trailing `?` marks an optional var). */\n\tenvironment?: readonly string[];\n\t/** Authorizer name: `none`, `iam`, or a declared authorizer. */\n\tauthorizer: string;\n\t/** Monitors set with `.monitor()`; absent when there are none. */\n\tmonitoring?: readonly MonitorInfo[];\n}\n\n/** A standalone Lambda function. */\nexport interface FunctionInfo {\n\tname: string;\n\thandler: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n\t/** Monitors set with `.monitor()`; absent when there are none. */\n\tmonitoring?: readonly MonitorInfo[];\n}\n\n/** A scheduled (cron) function. */\nexport interface CronInfo {\n\tname: string;\n\thandler: string;\n\t/** Schedule expression, e.g. `rate(1 day)` or `cron(0 12 * * ? *)`. */\n\tschedule: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n\t/** Monitors set with `.monitor()`; absent when there are none. */\n\tmonitoring?: readonly MonitorInfo[];\n}\n\n/** An event subscriber function (topic/queue resolved by `transport`). */\nexport interface SubscriberInfo {\n\tname: string;\n\thandler: string;\n\tsubscribedEvents: readonly string[];\n\t/** Delivery transport — `topic` (SNS fan-out) or `queue` (SQS). */\n\ttransport?: 'topic' | 'queue';\n\t/** The {@link TopicInfo.name} this subscriber binds to (via `s.topic(topic)`). */\n\ttopic?: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n}\n\n/**\n * A pub/sub topic — fan-out. A *resource* (no handler): it declares the event\n * contract; producers publish via the derived publisher and {@link SubscriberInfo}s\n * bind to it. Infra provisions an SNS topic.\n */\nexport interface TopicInfo {\n\tname: string;\n\t/** The event type names this topic carries. */\n\tevents: readonly string[];\n\t/** Whether the topic is FIFO. */\n\tfifo?: boolean;\n}\n\n/** A queue worker — a queue and its single consumer. */\nexport interface QueueInfo {\n\tname: string;\n\thandler: string;\n\t/** SQS event-source batch size. */\n\tbatchSize?: number;\n\t/** Whether the queue is FIFO. */\n\tfifo?: boolean;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n}\n\n/**\n * The full deployment manifest — the shape of `export const manifest` in a\n * generated `manifest/<provider>.ts`. Each field is a {@link ManifestField}\n * (flat or partitioned).\n */\nexport interface Manifest {\n\troutes: ManifestField<RouteInfo>;\n\tfunctions?: ManifestField<FunctionInfo>;\n\tcrons?: ManifestField<CronInfo>;\n\tsubscribers?: ManifestField<SubscriberInfo>;\n\tqueues?: ManifestField<QueueInfo>;\n\ttopics?: ManifestField<TopicInfo>;\n}\n\nexport * from './cron';\n"],"mappings":";;;;AA6BA,SAAgB,qBACfA,OACM;AACN,MAAK,MAAO,QAAO,CAAE;AACrB,QAAO,MAAM,QAAQ,MAAM,GACxB,CAAC,GAAG,KAAM,IACV,OAAO,OAAO,MAAsC,CAAC,MAAM;AAC9D"}
1
+ {"version":3,"file":"index.mjs","names":["field: ManifestField<T> | undefined"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Deployment manifest types — the build output of `gkm build` that enumerates a\n * project's deployable units (routes, functions, crons, subscribers, queues)\n * with the metadata an infrastructure layer needs to provision them.\n *\n * `gkm build` writes a single TypeScript module per provider\n * (`<out>/manifest/aws.ts`) of the form:\n *\n * ```ts\n * export const manifest = { routes: [...], functions: [...], ... } as const;\n * export type Route = (typeof manifest.routes)[number];\n * // ...derived types\n * ```\n *\n * This is the dependency-free data contract shared between the producer\n * (`@geekmidas/cli`) and consumers (e.g. `@geekmidas/cloud/sst`'s `fromManifest`\n * integrators).\n */\n\n/**\n * A manifest field is either a flat list or, when the build is partitioned\n * (e.g. by authorizer), an object keyed by partition name. Readonly-tolerant so\n * the `as const` generated manifest assigns cleanly.\n */\nexport type ManifestField<T> =\n\t| readonly T[]\n\t| Readonly<Record<string, readonly T[]>>;\n\n/** Flatten a manifest field (array or partitioned) into a plain array. */\nexport function flattenManifestField<T>(\n\tfield: ManifestField<T> | undefined,\n): T[] {\n\tif (!field) return [];\n\treturn Array.isArray(field)\n\t\t? [...field]\n\t\t: Object.values(field as Record<string, readonly T[]>).flat();\n}\n\n/**\n * A cron's uptime monitor, set with `.uptime()`, so infrastructure can create\n * what it reports to, e.g. a heartbeat whose URL it sets in `env`.\n */\nexport interface UptimeInfo {\n\t/** The kind of monitor, e.g. `heartbeat`. */\n\ttype: string;\n\t/** The service it reports to, e.g. `betterStack`. Absent for a custom one. */\n\tprovider?: string;\n\t/** The environment variable it reads its target from. */\n\tenv?: string;\n\t/**\n\t * The longest gap between runs of the cron's schedule, in seconds: how\n\t * often the monitor should expect to hear from it (see `cronPeriod`).\n\t */\n\tperiod: number;\n}\n\n/** A single HTTP route. */\nexport interface RouteInfo {\n\t/** Route path, e.g. `/users/{id}`. */\n\tpath: string;\n\t/** HTTP method, e.g. `GET`. */\n\tmethod: string;\n\t/** Bundled handler entrypoint. */\n\thandler: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\t/** Required environment variables (a trailing `?` marks an optional var). */\n\tenvironment?: readonly string[];\n\t/** Authorizer name: `none`, `iam`, or a declared authorizer. */\n\tauthorizer: string;\n}\n\n/** A standalone Lambda function. */\nexport interface FunctionInfo {\n\tname: string;\n\thandler: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n}\n\n/** A scheduled (cron) function. */\nexport interface CronInfo {\n\tname: string;\n\thandler: string;\n\t/** Schedule, always the six-field AWS form, e.g. `cron(0 12 * * ? *)`. */\n\tschedule: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n\t/** Set with `.uptime()`; absent when the cron has none. */\n\tuptime?: UptimeInfo;\n}\n\n/** An event subscriber function (topic/queue resolved by `transport`). */\nexport interface SubscriberInfo {\n\tname: string;\n\thandler: string;\n\tsubscribedEvents: readonly string[];\n\t/** Delivery transport — `topic` (SNS fan-out) or `queue` (SQS). */\n\ttransport?: 'topic' | 'queue';\n\t/** The {@link TopicInfo.name} this subscriber binds to (via `s.topic(topic)`). */\n\ttopic?: string;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n}\n\n/**\n * A pub/sub topic — fan-out. A *resource* (no handler): it declares the event\n * contract; producers publish via the derived publisher and {@link SubscriberInfo}s\n * bind to it. Infra provisions an SNS topic.\n */\nexport interface TopicInfo {\n\tname: string;\n\t/** The event type names this topic carries. */\n\tevents: readonly string[];\n\t/** Whether the topic is FIFO. */\n\tfifo?: boolean;\n}\n\n/** A queue worker — a queue and its single consumer. */\nexport interface QueueInfo {\n\tname: string;\n\thandler: string;\n\t/** SQS event-source batch size. */\n\tbatchSize?: number;\n\t/** Whether the queue is FIFO. */\n\tfifo?: boolean;\n\ttimeout?: number;\n\tmemorySize?: number;\n\tenvironment?: readonly string[];\n}\n\n/**\n * The full deployment manifest — the shape of `export const manifest` in a\n * generated `manifest/<provider>.ts`. Each field is a {@link ManifestField}\n * (flat or partitioned).\n */\nexport interface Manifest {\n\troutes: ManifestField<RouteInfo>;\n\tfunctions?: ManifestField<FunctionInfo>;\n\tcrons?: ManifestField<CronInfo>;\n\tsubscribers?: ManifestField<SubscriberInfo>;\n\tqueues?: ManifestField<QueueInfo>;\n\ttopics?: ManifestField<TopicInfo>;\n}\n\nexport * from './cron';\n"],"mappings":";;;;AA6BA,SAAgB,qBACfA,OACM;AACN,MAAK,MAAO,QAAO,CAAE;AACrB,QAAO,MAAM,QAAQ,MAAM,GACxB,CAAC,GAAG,KAAM,IACV,OAAO,OAAO,MAAsC,CAAC,MAAM;AAC9D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/manifest",
3
- "version": "9.3.0",
3
+ "version": "9.4.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/src/index.ts CHANGED
@@ -37,16 +37,21 @@ export function flattenManifestField<T>(
37
37
  }
38
38
 
39
39
  /**
40
- * A monitor set with `.monitor()`, so infrastructure can provision what it
41
- * reports to, e.g. create a heartbeat and set its URL in `env`.
40
+ * A cron's uptime monitor, set with `.uptime()`, so infrastructure can create
41
+ * what it reports to, e.g. a heartbeat whose URL it sets in `env`.
42
42
  */
43
- export interface MonitorInfo {
43
+ export interface UptimeInfo {
44
44
  /** The kind of monitor, e.g. `heartbeat`. */
45
45
  type: string;
46
46
  /** The service it reports to, e.g. `betterStack`. Absent for a custom one. */
47
47
  provider?: string;
48
48
  /** The environment variable it reads its target from. */
49
49
  env?: string;
50
+ /**
51
+ * The longest gap between runs of the cron's schedule, in seconds: how
52
+ * often the monitor should expect to hear from it (see `cronPeriod`).
53
+ */
54
+ period: number;
50
55
  }
51
56
 
52
57
  /** A single HTTP route. */
@@ -63,8 +68,6 @@ export interface RouteInfo {
63
68
  environment?: readonly string[];
64
69
  /** Authorizer name: `none`, `iam`, or a declared authorizer. */
65
70
  authorizer: string;
66
- /** Monitors set with `.monitor()`; absent when there are none. */
67
- monitoring?: readonly MonitorInfo[];
68
71
  }
69
72
 
70
73
  /** A standalone Lambda function. */
@@ -74,21 +77,19 @@ export interface FunctionInfo {
74
77
  timeout?: number;
75
78
  memorySize?: number;
76
79
  environment?: readonly string[];
77
- /** Monitors set with `.monitor()`; absent when there are none. */
78
- monitoring?: readonly MonitorInfo[];
79
80
  }
80
81
 
81
82
  /** A scheduled (cron) function. */
82
83
  export interface CronInfo {
83
84
  name: string;
84
85
  handler: string;
85
- /** Schedule expression, e.g. `rate(1 day)` or `cron(0 12 * * ? *)`. */
86
+ /** Schedule, always the six-field AWS form, e.g. `cron(0 12 * * ? *)`. */
86
87
  schedule: string;
87
88
  timeout?: number;
88
89
  memorySize?: number;
89
90
  environment?: readonly string[];
90
- /** Monitors set with `.monitor()`; absent when there are none. */
91
- monitoring?: readonly MonitorInfo[];
91
+ /** Set with `.uptime()`; absent when the cron has none. */
92
+ uptime?: UptimeInfo;
92
93
  }
93
94
 
94
95
  /** An event subscriber function (topic/queue resolved by `transport`). */