@usine/orchestrator 0.0.1 → 0.2.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.
Files changed (114) hide show
  1. package/README.md +146 -2
  2. package/dist/board/items.d.ts +18 -0
  3. package/dist/board/items.d.ts.map +1 -0
  4. package/dist/board/items.js +46 -0
  5. package/dist/board/items.js.map +1 -0
  6. package/dist/board/projection.d.ts +9 -0
  7. package/dist/board/projection.d.ts.map +1 -0
  8. package/dist/board/projection.js +111 -0
  9. package/dist/board/projection.js.map +1 -0
  10. package/dist/board/tasks.d.ts +8 -0
  11. package/dist/board/tasks.d.ts.map +1 -0
  12. package/dist/board/tasks.js +86 -0
  13. package/dist/board/tasks.js.map +1 -0
  14. package/dist/credentials.d.ts +12 -0
  15. package/dist/credentials.d.ts.map +1 -0
  16. package/dist/credentials.js +62 -0
  17. package/dist/credentials.js.map +1 -0
  18. package/dist/exe-dev.d.ts +8 -0
  19. package/dist/exe-dev.d.ts.map +1 -0
  20. package/dist/exe-dev.js +17 -0
  21. package/dist/exe-dev.js.map +1 -0
  22. package/dist/idle-triggers.d.ts +6 -0
  23. package/dist/idle-triggers.d.ts.map +1 -0
  24. package/dist/idle-triggers.js +31 -0
  25. package/dist/idle-triggers.js.map +1 -0
  26. package/dist/label-reconciler.d.ts +30 -0
  27. package/dist/label-reconciler.d.ts.map +1 -0
  28. package/dist/label-reconciler.js +119 -0
  29. package/dist/label-reconciler.js.map +1 -0
  30. package/dist/local.d.ts +25 -0
  31. package/dist/local.d.ts.map +1 -0
  32. package/dist/local.js +53 -0
  33. package/dist/local.js.map +1 -0
  34. package/dist/operator/attempt.d.ts +66 -0
  35. package/dist/operator/attempt.d.ts.map +1 -0
  36. package/dist/operator/attempt.js +58 -0
  37. package/dist/operator/attempt.js.map +1 -0
  38. package/dist/operator/board.d.ts +119 -0
  39. package/dist/operator/board.d.ts.map +1 -0
  40. package/dist/operator/board.js +101 -0
  41. package/dist/operator/board.js.map +1 -0
  42. package/dist/operator/http.d.ts +114 -0
  43. package/dist/operator/http.d.ts.map +1 -0
  44. package/dist/operator/http.js +139 -0
  45. package/dist/operator/http.js.map +1 -0
  46. package/dist/operator/need.d.ts +66 -0
  47. package/dist/operator/need.d.ts.map +1 -0
  48. package/dist/operator/need.js +70 -0
  49. package/dist/operator/need.js.map +1 -0
  50. package/dist/operator/operator.d.ts +64 -0
  51. package/dist/operator/operator.d.ts.map +1 -0
  52. package/dist/operator/operator.js +363 -0
  53. package/dist/operator/operator.js.map +1 -0
  54. package/dist/operator/overview.d.ts +51 -0
  55. package/dist/operator/overview.d.ts.map +1 -0
  56. package/dist/operator/overview.js +48 -0
  57. package/dist/operator/overview.js.map +1 -0
  58. package/dist/operator/projection.d.ts +17 -0
  59. package/dist/operator/projection.d.ts.map +1 -0
  60. package/dist/operator/projection.js +138 -0
  61. package/dist/operator/projection.js.map +1 -0
  62. package/dist/operator/run.d.ts +38 -0
  63. package/dist/operator/run.d.ts.map +1 -0
  64. package/dist/operator/run.js +41 -0
  65. package/dist/operator/run.js.map +1 -0
  66. package/dist/operator/transcript.d.ts +57 -0
  67. package/dist/operator/transcript.d.ts.map +1 -0
  68. package/dist/operator/transcript.js +59 -0
  69. package/dist/operator/transcript.js.map +1 -0
  70. package/dist/orchestrator.d.ts +14 -0
  71. package/dist/orchestrator.d.ts.map +1 -0
  72. package/dist/orchestrator.js +14 -0
  73. package/dist/orchestrator.js.map +1 -0
  74. package/dist/polling/cycle.d.ts +51 -0
  75. package/dist/polling/cycle.d.ts.map +1 -0
  76. package/dist/polling/cycle.js +44 -0
  77. package/dist/polling/cycle.js.map +1 -0
  78. package/dist/polling/hints.d.ts +20 -0
  79. package/dist/polling/hints.d.ts.map +1 -0
  80. package/dist/polling/hints.js +54 -0
  81. package/dist/polling/hints.js.map +1 -0
  82. package/dist/polling/loop-evaluation.d.ts +21 -0
  83. package/dist/polling/loop-evaluation.d.ts.map +1 -0
  84. package/dist/polling/loop-evaluation.js +131 -0
  85. package/dist/polling/loop-evaluation.js.map +1 -0
  86. package/dist/polling/polling.d.ts +36 -0
  87. package/dist/polling/polling.d.ts.map +1 -0
  88. package/dist/polling/polling.js +296 -0
  89. package/dist/polling/polling.js.map +1 -0
  90. package/dist/polling/repository-sync.d.ts +45 -0
  91. package/dist/polling/repository-sync.d.ts.map +1 -0
  92. package/dist/polling/repository-sync.js +169 -0
  93. package/dist/polling/repository-sync.js.map +1 -0
  94. package/dist/polling-triggers.d.ts +4 -0
  95. package/dist/polling-triggers.d.ts.map +1 -0
  96. package/dist/polling-triggers.js +4 -0
  97. package/dist/polling-triggers.js.map +1 -0
  98. package/dist/schedule-triggers.d.ts +67 -0
  99. package/dist/schedule-triggers.d.ts.map +1 -0
  100. package/dist/schedule-triggers.js +401 -0
  101. package/dist/schedule-triggers.js.map +1 -0
  102. package/dist/scheduler.d.ts +15 -0
  103. package/dist/scheduler.d.ts.map +1 -0
  104. package/dist/scheduler.js +107 -0
  105. package/dist/scheduler.js.map +1 -0
  106. package/dist/trigger-submission.d.ts +69 -0
  107. package/dist/trigger-submission.d.ts.map +1 -0
  108. package/dist/trigger-submission.js +108 -0
  109. package/dist/trigger-submission.js.map +1 -0
  110. package/package.json +67 -5
  111. package/dist/index.d.ts +0 -8
  112. package/dist/index.d.ts.map +0 -1
  113. package/dist/index.js +0 -8
  114. package/dist/index.js.map +0 -1
@@ -0,0 +1,169 @@
1
+ import { CycleGeneration } from "@usine/core/cycle-budget";
2
+ import { CycleBudgets } from "@usine/engine/cycle-budget";
3
+ import { ItemKey, ItemNumber } from "@usine/core/item";
4
+ import { RepositoryName, canonicalRepositoryName } from "@usine/core/repository";
5
+ import { ItemContentHash, ItemProjection, ItemProjectionSource, ItemProjectionWriter, } from "@usine/engine/item-projection";
6
+ import { RepositoryLabel, RepositoryLabelProjection, RepositoryLabelProjectionReader, RepositoryLabelProjectionWriter, } from "@usine/engine/repository-label-projection";
7
+ import { EntityTag, GitHubPolling, RepositoryLabelCatalog, } from "@usine/github/polling";
8
+ import { DateTime, Effect, Option, Result, Schema } from "effect";
9
+ import { LabelReconciler } from "../label-reconciler.js";
10
+ import { latestPollAt, RepositoryPollFailure, repositoryFailureLogFields, } from "./cycle.js";
11
+ /**
12
+ * Identifies one GitHub issue or pull request across its changing snapshots.
13
+ * Encoding uses the canonical repository name and Item number; decoding lets
14
+ * Board consumers locate the Item associated with a Run. Schedule Runs identify
15
+ * the repository alone and do not decode as an Item.
16
+ */
17
+ export const GitHubItemKey = Schema.toType(ItemKey).pipe(Schema.decodeTo(Schema.fromJsonString(Schema.Tuple([Schema.Literal("github"), RepositoryName, ItemNumber]))));
18
+ // `toType` preserves the ItemKey brand on the encoded side, so the encoder
19
+ // produces the identity accepted by both the Board projection and Run engine.
20
+ const encodeGitHubItemKey = Schema.encodeSync(GitHubItemKey);
21
+ /** The reconciliation result when the cycle had no confirmed catalog to compare against. */
22
+ const DEFERRED_RECONCILIATION = {
23
+ labels: [],
24
+ findings: [],
25
+ catalogChanged: false,
26
+ nextPollAt: Option.none(),
27
+ };
28
+ /**
29
+ * Refreshes the stored label catalog that the Board and the label
30
+ * preflight read. A failed request keeps the stored catalog and ETag and
31
+ * defers provisioning; trigger evaluation runs from the change poll alone.
32
+ */
33
+ const applyLabelCatalog = Effect.fn("PollingTriggers.applyLabelCatalog")(function* (repository, labelEntityTag, result) {
34
+ yield* Effect.annotateCurrentSpan({ repository });
35
+ const repositoryLabelReader = yield* RepositoryLabelProjectionReader;
36
+ const repositoryLabelWriter = yield* RepositoryLabelProjectionWriter;
37
+ const unchanged = {
38
+ labelEntityTag,
39
+ entityTagChanged: false,
40
+ confirmedLabels: Option.none(),
41
+ failures: [],
42
+ nextPollAt: Option.none(),
43
+ };
44
+ if (Result.isFailure(result)) {
45
+ const error = result.failure;
46
+ if (error._tag === "GitHubRateLimitError") {
47
+ yield* Effect.logWarning("Label catalog rate-limited; kept the stored catalog and deferred label provisioning", {
48
+ repository,
49
+ operation: error.operation,
50
+ retryAt: DateTime.formatIso(error.retryAt),
51
+ });
52
+ return { ...unchanged, nextPollAt: Option.some(error.retryAt) };
53
+ }
54
+ yield* Effect.logError("Label catalog request failed; kept the stored catalog, deferred label provisioning, and evaluated items anyway", {
55
+ repository,
56
+ ...repositoryFailureLogFields(error),
57
+ });
58
+ return {
59
+ ...unchanged,
60
+ failures: [
61
+ new RepositoryPollFailure({
62
+ repository,
63
+ errorTag: error._tag,
64
+ message: error.message,
65
+ }),
66
+ ],
67
+ };
68
+ }
69
+ const detection = result.success;
70
+ if (!(detection instanceof RepositoryLabelCatalog)) {
71
+ const projection = yield* repositoryLabelReader.get(repository);
72
+ if (Option.isNone(projection)) {
73
+ // The ETag vouches for a projection that is no longer stored, so drop
74
+ // it and fetch the catalog in full next cycle.
75
+ yield* Effect.logWarning("Repository label catalog unchanged (304) but its projection is missing; refetching next cycle and deferring label provisioning", { repository });
76
+ return { ...unchanged, labelEntityTag: Option.none(), entityTagChanged: true };
77
+ }
78
+ yield* Effect.logDebug("Repository label catalog unchanged (304)", {
79
+ repository,
80
+ });
81
+ return { ...unchanged, confirmedLabels: Option.some(projection.value.labels) };
82
+ }
83
+ const labels = detection.labels.map(({ name, color, description }) => new RepositoryLabel({ name, color: Option.some(color), description }));
84
+ yield* repositoryLabelWriter.replace(new RepositoryLabelProjection({ repository, labels }));
85
+ return {
86
+ ...unchanged,
87
+ labelEntityTag: detection.entityTag,
88
+ entityTagChanged: true,
89
+ confirmedLabels: Option.some(labels),
90
+ };
91
+ });
92
+ /**
93
+ * Refreshes and reconciles one repository's Board label catalog before change
94
+ * detection. Pass the catalog ETag from its stored poll cursor; the result gives
95
+ * the ETag to persist after Item processing, plus preflight findings and backoff.
96
+ * Failed catalog requests retain the stored projection and defer provisioning;
97
+ * persistence failures stop the repository for retry.
98
+ */
99
+ export const synchronizeLabels = Effect.fn("PollingTriggers.synchronizeLabels")(function* (repository, declared, entityTag) {
100
+ yield* Effect.annotateCurrentSpan({ repository });
101
+ const github = yield* GitHubPolling;
102
+ const labelReconciler = yield* LabelReconciler;
103
+ const repositoryLabelWriter = yield* RepositoryLabelProjectionWriter;
104
+ const result = yield* Effect.result(github.labels(repository, entityTag));
105
+ const catalog = yield* applyLabelCatalog(repository, entityTag, result);
106
+ const reconciliation = yield* Option.match(catalog.confirmedLabels, {
107
+ onNone: () => Effect.succeed(DEFERRED_RECONCILIATION),
108
+ onSome: (confirmed) => labelReconciler.reconcile(repository, declared, confirmed),
109
+ });
110
+ const preflight = {
111
+ labelEntityTag: reconciliation.catalogChanged
112
+ ? Option.none()
113
+ : catalog.labelEntityTag,
114
+ entityTagChanged: catalog.entityTagChanged || reconciliation.catalogChanged,
115
+ failures: catalog.failures,
116
+ preflightFindings: reconciliation.findings,
117
+ nextPollAt: latestPollAt([catalog.nextPollAt, reconciliation.nextPollAt]),
118
+ };
119
+ if (reconciliation.catalogChanged) {
120
+ yield* repositoryLabelWriter
121
+ .replace(new RepositoryLabelProjection({ repository, labels: reconciliation.labels }))
122
+ .pipe(
123
+ // Provisioning may have reported failures before projection storage
124
+ // fails. Preserve those findings just as for a later Item failure.
125
+ Effect.mapError((error) => ({
126
+ _tag: "InterruptedRepositoryCycle",
127
+ error,
128
+ failures: preflight.failures,
129
+ preflightFindings: preflight.preflightFindings,
130
+ nextPollAt: preflight.nextPollAt,
131
+ })));
132
+ }
133
+ return preflight;
134
+ });
135
+ /**
136
+ * Fetches a detected Item and durably updates its Board projection regardless of
137
+ * whether any Loop applies. Evaluation uses the returned projection's snapshot,
138
+ * identity and content hash, so Board observation and Run decisions agree.
139
+ */
140
+ export const observeItem = Effect.fn("PollingTriggers.observeItem")(function* (repository, changed) {
141
+ yield* Effect.annotateCurrentSpan({ repository, item: changed.number });
142
+ const github = yield* GitHubPolling;
143
+ const items = yield* ItemProjectionWriter;
144
+ const budgets = yield* CycleBudgets;
145
+ const itemKey = encodeGitHubItemKey([
146
+ "github",
147
+ RepositoryName.make(canonicalRepositoryName(repository)),
148
+ ItemNumber.make(changed.number),
149
+ ]);
150
+ const cycleGeneration = yield* budgets.generation(itemKey);
151
+ const snapshot = yield* github.snapshot(repository, changed);
152
+ const projection = new ItemProjection({
153
+ itemKey,
154
+ repository,
155
+ source: ItemProjectionSource.make(changed._tag === "ChangedIssue" ? "issue" : "pr"),
156
+ number: ItemNumber.make(changed.number),
157
+ contentHash: ItemContentHash.make(snapshot.contentHash),
158
+ payload: snapshot.payload,
159
+ });
160
+ yield* items.upsert(projection);
161
+ yield* Effect.logDebug("Fetched changed-item snapshot", {
162
+ repository,
163
+ item: projection.number,
164
+ stream: projection.source,
165
+ contentHash: projection.contentHash,
166
+ });
167
+ return { projection, cycleGeneration };
168
+ });
169
+ //# sourceMappingURL=repository-sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-sync.js","sourceRoot":"","sources":["../../src/polling/repository-sync.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAEL,SAAS,EACT,aAAa,EACb,sBAAsB,GAEvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAA4B,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAEL,YAAY,EACZ,qBAAqB,EACrB,0BAA0B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O,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAC,CAAC;IACH,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAChC,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,+BAA+B,EAAE;QACtD,UAAU;QACV,IAAI,EAAE,UAAU,CAAC,MAAM;QACvB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,WAAW,EAAE,UAAU,CAAC,WAAW;KACpC,CAAC,CAAC;IACH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAyB,CAAC;AAChE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { PollingTriggers } from "./polling/polling.ts";
2
+ export { PollCycle, RepositoryPollFailure } from "./polling/cycle.ts";
3
+ export { GitHubItemKey } from "./polling/repository-sync.ts";
4
+ //# sourceMappingURL=polling-triggers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling-triggers.d.ts","sourceRoot":"","sources":["../src/polling-triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { PollingTriggers } from "./polling/polling.js";
2
+ export { PollCycle, RepositoryPollFailure } from "./polling/cycle.js";
3
+ export { GitHubItemKey } from "./polling/repository-sync.js";
4
+ //# sourceMappingURL=polling-triggers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling-triggers.js","sourceRoot":"","sources":["../src/polling-triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,67 @@
1
+ import type { LoadedInstance } from "@usine/config/instance";
2
+ import { ConfigParser } from "@usine/config/parser";
3
+ import { RunEngine, type EnginePersistenceError } from "@usine/engine/engine";
4
+ import { LoopControl } from "@usine/engine/loop-control";
5
+ import { ExpressionEngine } from "@usine/expression/expression-engine";
6
+ import { Context, Effect, Layer, Option, Schema } from "effect";
7
+ declare const ScheduleAgentFailure_base: Schema.Class<ScheduleAgentFailure, Schema.TaggedStruct<"ScheduleAgentFailure", {
8
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
9
+ readonly agent: Schema.brand<Schema.String, "AgentName">;
10
+ readonly message: Schema.String;
11
+ }>, {}>;
12
+ /** A schedule loop whose agent is no longer in the loaded roster. */
13
+ export declare class ScheduleAgentFailure extends ScheduleAgentFailure_base {
14
+ }
15
+ declare const ScheduleTickFailure_base: Schema.Class<ScheduleTickFailure, Schema.TaggedStruct<"ScheduleTickFailure", {
16
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
17
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
18
+ readonly scheduledAt: Schema.DateTimeUtc;
19
+ readonly errorTag: Schema.NonEmptyString;
20
+ readonly message: Schema.String;
21
+ }>, {}>;
22
+ /** A selected repository whose Tick could not be evaluated or submitted. */
23
+ export declare class ScheduleTickFailure extends ScheduleTickFailure_base {
24
+ }
25
+ declare const ScheduleCronFailure_base: Schema.Class<ScheduleCronFailure, Schema.TaggedStruct<"ScheduleCronFailure", {
26
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
27
+ readonly cron: Schema.String;
28
+ readonly tz: Schema.String;
29
+ readonly message: Schema.String;
30
+ }>, {}>;
31
+ /**
32
+ * A schedule whose cron boundaries could not be computed at this instant.
33
+ * Cron.prev and Cron.next fail inside a DST spring-forward gap even for a cron
34
+ * that parsed; the schedule retries next cycle and its siblings run.
35
+ */
36
+ export declare class ScheduleCronFailure extends ScheduleCronFailure_base {
37
+ }
38
+ export declare const ScheduleFailure: Schema.Union<readonly [typeof ScheduleAgentFailure, typeof ScheduleCronFailure, typeof ScheduleTickFailure]>;
39
+ export type ScheduleFailure = typeof ScheduleFailure.Type;
40
+ declare const ScheduleCycle_base: Schema.Class<ScheduleCycle, Schema.Struct<{
41
+ readonly loops: Schema.Int;
42
+ readonly fanout: Schema.Int;
43
+ readonly submissions: Schema.$Array<Schema.Union<readonly [typeof import("@usine/engine/engine").Claimed, typeof import("@usine/engine/engine").Queued, typeof import("@usine/engine/engine").Ignored, typeof import("@usine/engine/engine").CycleBlocked]>>;
44
+ readonly skipped: Schema.Int;
45
+ readonly alreadyFired: Schema.Int;
46
+ readonly failures: Schema.$Array<Schema.Union<readonly [typeof ScheduleAgentFailure, typeof ScheduleCronFailure, typeof ScheduleTickFailure]>>;
47
+ readonly nextTickAt: Schema.Option<Schema.DateTimeUtc>;
48
+ }>, {}>;
49
+ /** The result of evaluating every schedule loop at one instant. */
50
+ export declare class ScheduleCycle extends ScheduleCycle_base {
51
+ }
52
+ declare const ScheduleTriggers_base: Context.ServiceClass<ScheduleTriggers, "@usine/orchestrator/ScheduleTriggers", {
53
+ /**
54
+ * Evaluates the latest due Tick of every schedule. A repository's failure is
55
+ * logged and reported without stopping its siblings; a cron failure in a
56
+ * DST gap fails only its own schedule.
57
+ */
58
+ readonly tick: (instance: LoadedInstance) => Effect.Effect<ScheduleCycle, EnginePersistenceError>;
59
+ readonly run: (instance: LoadedInstance) => Effect.Effect<never>;
60
+ readonly latest: Effect.Effect<Option.Option<ScheduleCycle>>;
61
+ }>;
62
+ /** Turns due schedule ticks into one Event per selected repository. */
63
+ export declare class ScheduleTriggers extends ScheduleTriggers_base {
64
+ static readonly layer: Layer.Layer<ScheduleTriggers, never, ConfigParser | ExpressionEngine | LoopControl | RunEngine>;
65
+ }
66
+ export {};
67
+ //# sourceMappingURL=schedule-triggers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule-triggers.d.ts","sourceRo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