@substrat-run/contracts 0.215.0 → 0.217.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 (80) hide show
  1. package/dist/broker-dead-letters.d.ts +114 -0
  2. package/dist/broker-dead-letters.d.ts.map +1 -0
  3. package/dist/broker-dead-letters.js +110 -0
  4. package/dist/broker-dead-letters.js.map +1 -0
  5. package/dist/broker-relay.d.ts +67 -0
  6. package/dist/broker-relay.d.ts.map +1 -1
  7. package/dist/broker-relay.js +30 -0
  8. package/dist/broker-relay.js.map +1 -1
  9. package/dist/connect-intent.d.ts +75 -0
  10. package/dist/connect-intent.d.ts.map +1 -0
  11. package/dist/connect-intent.js +89 -0
  12. package/dist/connect-intent.js.map +1 -0
  13. package/dist/control-plane.d.ts +28 -0
  14. package/dist/control-plane.d.ts.map +1 -1
  15. package/dist/control-plane.js +56 -0
  16. package/dist/control-plane.js.map +1 -1
  17. package/dist/deploy.d.ts +44 -0
  18. package/dist/deploy.d.ts.map +1 -1
  19. package/dist/deploy.js +58 -0
  20. package/dist/deploy.js.map +1 -1
  21. package/dist/dev-recording.d.ts +109 -0
  22. package/dist/dev-recording.d.ts.map +1 -0
  23. package/dist/dev-recording.js +128 -0
  24. package/dist/dev-recording.js.map +1 -0
  25. package/dist/email-intent.d.ts +14 -0
  26. package/dist/email-intent.d.ts.map +1 -1
  27. package/dist/email-intent.js +28 -0
  28. package/dist/email-intent.js.map +1 -1
  29. package/dist/environments.d.ts +62 -0
  30. package/dist/environments.d.ts.map +1 -0
  31. package/dist/environments.js +55 -0
  32. package/dist/environments.js.map +1 -0
  33. package/dist/index.d.ts +8 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +8 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/introspection.d.ts.map +1 -1
  38. package/dist/introspection.js +3 -2
  39. package/dist/introspection.js.map +1 -1
  40. package/dist/manifest.d.ts +122 -0
  41. package/dist/manifest.d.ts.map +1 -1
  42. package/dist/manifest.js +96 -1
  43. package/dist/manifest.js.map +1 -1
  44. package/dist/mcp-image.d.ts +38 -0
  45. package/dist/mcp-image.d.ts.map +1 -0
  46. package/dist/mcp-image.js +31 -0
  47. package/dist/mcp-image.js.map +1 -0
  48. package/dist/operations.d.ts +43 -2
  49. package/dist/operations.d.ts.map +1 -1
  50. package/dist/operations.js +56 -1
  51. package/dist/operations.js.map +1 -1
  52. package/dist/registry.d.ts +46 -0
  53. package/dist/registry.d.ts.map +1 -1
  54. package/dist/registry.js +35 -0
  55. package/dist/registry.js.map +1 -1
  56. package/dist/runtime-tables.d.ts +12 -0
  57. package/dist/runtime-tables.d.ts.map +1 -0
  58. package/dist/runtime-tables.js +15 -0
  59. package/dist/runtime-tables.js.map +1 -0
  60. package/dist/scope-store-envelope.d.ts +57 -4
  61. package/dist/scope-store-envelope.d.ts.map +1 -1
  62. package/dist/scope-store-envelope.js +82 -15
  63. package/dist/scope-store-envelope.js.map +1 -1
  64. package/dist/scope-types.d.ts +108 -0
  65. package/dist/scope-types.d.ts.map +1 -0
  66. package/dist/scope-types.js +198 -0
  67. package/dist/scope-types.js.map +1 -0
  68. package/dist/source-build.d.ts +16 -0
  69. package/dist/source-build.d.ts.map +1 -1
  70. package/dist/source-build.js +10 -0
  71. package/dist/source-build.js.map +1 -1
  72. package/dist/vertical-connector.d.ts +84 -2
  73. package/dist/vertical-connector.d.ts.map +1 -1
  74. package/dist/vertical-connector.js +59 -2
  75. package/dist/vertical-connector.js.map +1 -1
  76. package/dist/vertical-events.d.ts +42 -0
  77. package/dist/vertical-events.d.ts.map +1 -1
  78. package/dist/vertical-events.js +8 -0
  79. package/dist/vertical-events.js.map +1 -1
  80. package/package.json +2 -2
@@ -0,0 +1,114 @@
1
+ import { z } from 'zod';
2
+ /** The door on an app's deployment that reads its broker's dead letters (POST, the body below). */
3
+ export declare const BROKER_DEAD_LETTERS_PATH = "/internal/broker/dead-letters";
4
+ /** The doors that resend a dead letter (it is due again, its attempts reset) and discard one. */
5
+ export declare const BROKER_DEAD_LETTER_RESEND_PATH = "/internal/broker/dead-letters/resend";
6
+ export declare const BROKER_DEAD_LETTER_DISCARD_PATH = "/internal/broker/dead-letters/discard";
7
+ /** How many dead letters one read returns at most; the broker reads oldest first. */
8
+ export declare const BROKER_DEAD_LETTERS_MAX = 200;
9
+ /** One dead letter: a message the broker gave up on for one receiver. */
10
+ export declare const brokerDeadLetter: z.ZodObject<{
11
+ messageId: z.ZodString;
12
+ receiver: z.ZodString;
13
+ kind: z.ZodEnum<{
14
+ event: "event";
15
+ intent: "intent";
16
+ }>;
17
+ type: z.ZodString;
18
+ scopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
19
+ committedAt: z.ZodString;
20
+ key: z.ZodNullable<z.ZodString>;
21
+ attempts: z.ZodNumber;
22
+ lastStatus: z.ZodNullable<z.ZodNumber>;
23
+ deadAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
24
+ expiresAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
25
+ resends: z.ZodNumber;
26
+ traceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ invocationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ lastError: z.ZodOptional<z.ZodNullable<z.ZodString>>;
29
+ body: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strict>;
31
+ export type BrokerDeadLetter = z.infer<typeof brokerDeadLetter>;
32
+ /** What the dead-letter door is asked. `content` is the control plane's decision, never the caller's. */
33
+ export declare const brokerDeadLettersRequest: z.ZodObject<{
34
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
35
+ receiver: z.ZodOptional<z.ZodString>;
36
+ limit: z.ZodOptional<z.ZodNumber>;
37
+ content: z.ZodBoolean;
38
+ }, z.core.$strict>;
39
+ export type BrokerDeadLettersRequest = z.infer<typeof brokerDeadLettersRequest>;
40
+ /** The read's answer: the entries, and whether they carry content. */
41
+ export declare const brokerDeadLettersPage: z.ZodObject<{
42
+ entries: z.ZodArray<z.ZodObject<{
43
+ messageId: z.ZodString;
44
+ receiver: z.ZodString;
45
+ kind: z.ZodEnum<{
46
+ event: "event";
47
+ intent: "intent";
48
+ }>;
49
+ type: z.ZodString;
50
+ scopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
51
+ committedAt: z.ZodString;
52
+ key: z.ZodNullable<z.ZodString>;
53
+ attempts: z.ZodNumber;
54
+ lastStatus: z.ZodNullable<z.ZodNumber>;
55
+ deadAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
56
+ expiresAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
57
+ resends: z.ZodNumber;
58
+ traceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
59
+ invocationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
60
+ lastError: z.ZodOptional<z.ZodNullable<z.ZodString>>;
61
+ body: z.ZodOptional<z.ZodString>;
62
+ }, z.core.$strict>>;
63
+ content: z.ZodBoolean;
64
+ }, z.core.$strip>;
65
+ export type BrokerDeadLettersPage = z.infer<typeof brokerDeadLettersPage>;
66
+ /** The query a person's read carries: which receiver, and how many. */
67
+ export declare const brokerDeadLettersQuery: z.ZodObject<{
68
+ receiver: z.ZodOptional<z.ZodString>;
69
+ limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
70
+ }, z.core.$strict>;
71
+ export type BrokerDeadLettersQuery = z.infer<typeof brokerDeadLettersQuery>;
72
+ /** One dead letter named for a resend or a discard. No receiver: every receiver it is dead at. */
73
+ export declare const brokerDeadLetterTarget: z.ZodObject<{
74
+ messageId: z.ZodString;
75
+ receiver: z.ZodOptional<z.ZodString>;
76
+ }, z.core.$strict>;
77
+ export type BrokerDeadLetterTarget = z.infer<typeof brokerDeadLetterTarget>;
78
+ /** What the door is asked to resend or discard. */
79
+ export declare const brokerDeadLetterActionRequest: z.ZodObject<{
80
+ messageId: z.ZodString;
81
+ receiver: z.ZodOptional<z.ZodString>;
82
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
83
+ }, z.core.$strict>;
84
+ export type BrokerDeadLetterActionRequest = z.infer<typeof brokerDeadLetterActionRequest>;
85
+ /** How many deliveries moved: 0 when none was dead (already resent, discarded or expired). */
86
+ export declare const brokerDeadLetterActionAnswer: z.ZodObject<{
87
+ moved: z.ZodNumber;
88
+ }, z.core.$strip>;
89
+ export type BrokerDeadLetterActionAnswer = z.infer<typeof brokerDeadLetterActionAnswer>;
90
+ /**
91
+ * One resend or discard, as the admin log keeps it: the app instance it was asked through, the
92
+ * message and receiver named, and how many deliveries moved. No content: the row is the platform's.
93
+ */
94
+ export declare const brokerDeadLetterAudit: z.ZodObject<{
95
+ action: z.ZodEnum<{
96
+ discard: "discard";
97
+ resend: "resend";
98
+ }>;
99
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
100
+ scopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
101
+ messageId: z.ZodString;
102
+ receiver: z.ZodOptional<z.ZodString>;
103
+ moved: z.ZodNumber;
104
+ }, z.core.$strict>;
105
+ export type BrokerDeadLetterAudit = z.infer<typeof brokerDeadLetterAudit>;
106
+ /** A dead letter with its content removed: what a staff read is given. */
107
+ export declare function withoutContent(entry: BrokerDeadLetter): BrokerDeadLetter;
108
+ /**
109
+ * The page a reader is given, whatever the deployment answered: with content only when `content`
110
+ * is true, and stripped of it otherwise, so a deployment that ignored the flag still shows staff
111
+ * nothing of a message. Parsed, so a field the schema does not name never rides through.
112
+ */
113
+ export declare function deadLetterView(answer: unknown, content: boolean): BrokerDeadLettersPage;
114
+ //# sourceMappingURL=broker-dead-letters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-dead-letters.d.ts","sourceRoot":"","sources":["../src/broker-dead-letters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,mGAAmG;AACnG,eAAO,MAAM,wBAAwB,kCAAkC,CA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qB;;;;;;;;;;kBASvB,CAAC;AACZ,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CAGxE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,qBAAqB,CAGvF"}
@@ -0,0 +1,110 @@
1
+ import { z } from 'zod';
2
+ import { instant, scopeId, tenantId } from './ids.js';
3
+ // The delivery broker's dead letter, as people see it (K-74, rfc/broker-and-tenant-isolation.md
4
+ // §4.6 and §9.1, #3474). A broker runs per (tenant, app) in the app's own deployment, and keeps a
5
+ // message it gave up on for one receiver for 14 days, to be resent or discarded.
6
+ //
7
+ // **Who sees what is decided here, once.** The tenant's admin sees their own tenant's dead letters
8
+ // WITH content: the message's row as the scope committed it, and the receiver's error text about it
9
+ // (which may echo what it was handed). The platform's operators see the same entries WITHOUT either:
10
+ // ids, the declared type, counts, times and the receiver's status code. The control plane is what
11
+ // applies the rule (`deadLetterView`), on the answer it relays, whatever the deployment sent; the
12
+ // deployment's door is also asked without content for a staff read, so content never leaves the
13
+ // app's script for one. A subject's erasure reaches a dead letter's content in the broker itself
14
+ // (#3484), so an erased subject's content is never shown to anyone.
15
+ /** The door on an app's deployment that reads its broker's dead letters (POST, the body below). */
16
+ export const BROKER_DEAD_LETTERS_PATH = '/internal/broker/dead-letters';
17
+ /** The doors that resend a dead letter (it is due again, its attempts reset) and discard one. */
18
+ export const BROKER_DEAD_LETTER_RESEND_PATH = '/internal/broker/dead-letters/resend';
19
+ export const BROKER_DEAD_LETTER_DISCARD_PATH = '/internal/broker/dead-letters/discard';
20
+ /** How many dead letters one read returns at most; the broker reads oldest first. */
21
+ export const BROKER_DEAD_LETTERS_MAX = 200;
22
+ const messageId = z.string().min(1).max(64);
23
+ /** A receiver is a subscription's name, unique per broker (`'default'`, the relay's, the lake's). */
24
+ const receiver = z.string().min(1).max(200);
25
+ /** One dead letter: a message the broker gave up on for one receiver. */
26
+ export const brokerDeadLetter = z
27
+ .object({
28
+ messageId,
29
+ receiver,
30
+ /** `event`: an outbox row the scope emitted. `intent`: a platform intent it raised. */
31
+ kind: z.enum(['event', 'intent']),
32
+ /** The event's declared type, or the intent's kind. */
33
+ type: z.string().min(1),
34
+ scopeId,
35
+ committedAt: z.string().min(1),
36
+ /** The sender's ordering key: while this one is dead, later messages with the key wait behind it. */
37
+ key: z.string().nullable(),
38
+ attempts: z.number().int().nonnegative(),
39
+ /** The receiver's HTTP status on the last failure, when it gave one. */
40
+ lastStatus: z.number().int().nullable(),
41
+ deadAt: instant,
42
+ /** When the broker drops it unless it is resent first. */
43
+ expiresAt: instant,
44
+ resends: z.number().int().nonnegative(),
45
+ /** The W3C trace id the message was committed under, and the invocation that wrote it, where known. Ids, not content. */
46
+ traceId: z.string().nullable().optional(),
47
+ invocationId: z.string().nullable().optional(),
48
+ /** Content: the receiver's error text about the last attempt. The tenant's view only. */
49
+ lastError: z.string().nullable().optional(),
50
+ /** Content: the message's row, as JSON text. The tenant's view only. */
51
+ body: z.string().optional(),
52
+ })
53
+ .strict();
54
+ /** What the dead-letter door is asked. `content` is the control plane's decision, never the caller's. */
55
+ export const brokerDeadLettersRequest = z
56
+ .object({
57
+ tenantId,
58
+ receiver: receiver.optional(),
59
+ limit: z.number().int().min(1).max(BROKER_DEAD_LETTERS_MAX).optional(),
60
+ content: z.boolean(),
61
+ })
62
+ .strict();
63
+ /** The read's answer: the entries, and whether they carry content. */
64
+ export const brokerDeadLettersPage = z.object({
65
+ entries: z.array(brokerDeadLetter),
66
+ /** True only on the tenant's own read. A staff read is always false. */
67
+ content: z.boolean(),
68
+ });
69
+ /** The query a person's read carries: which receiver, and how many. */
70
+ export const brokerDeadLettersQuery = z
71
+ .object({
72
+ receiver: receiver.optional(),
73
+ limit: z.coerce.number().int().min(1).max(BROKER_DEAD_LETTERS_MAX).optional(),
74
+ })
75
+ .strict();
76
+ /** One dead letter named for a resend or a discard. No receiver: every receiver it is dead at. */
77
+ export const brokerDeadLetterTarget = z.object({ messageId, receiver: receiver.optional() }).strict();
78
+ /** What the door is asked to resend or discard. */
79
+ export const brokerDeadLetterActionRequest = brokerDeadLetterTarget.extend({ tenantId }).strict();
80
+ /** How many deliveries moved: 0 when none was dead (already resent, discarded or expired). */
81
+ export const brokerDeadLetterActionAnswer = z.object({ moved: z.number().int().nonnegative() });
82
+ /**
83
+ * One resend or discard, as the admin log keeps it: the app instance it was asked through, the
84
+ * message and receiver named, and how many deliveries moved. No content: the row is the platform's.
85
+ */
86
+ export const brokerDeadLetterAudit = z
87
+ .object({
88
+ action: z.enum(['resend', 'discard']),
89
+ tenantId,
90
+ scopeId,
91
+ messageId,
92
+ receiver: receiver.optional(),
93
+ moved: z.number().int().nonnegative(),
94
+ })
95
+ .strict();
96
+ /** A dead letter with its content removed: what a staff read is given. */
97
+ export function withoutContent(entry) {
98
+ const { body: _body, lastError: _lastError, ...metadata } = entry;
99
+ return metadata;
100
+ }
101
+ /**
102
+ * The page a reader is given, whatever the deployment answered: with content only when `content`
103
+ * is true, and stripped of it otherwise, so a deployment that ignored the flag still shows staff
104
+ * nothing of a message. Parsed, so a field the schema does not name never rides through.
105
+ */
106
+ export function deadLetterView(answer, content) {
107
+ const entries = z.object({ entries: z.array(brokerDeadLetter) }).parse(answer).entries;
108
+ return { entries: content ? entries : entries.map(withoutContent), content };
109
+ }
110
+ //# sourceMappingURL=broker-dead-letters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker-dead-letters.js","sourceRoot":"","sources":["../src/broker-dead-letters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEtD,gGAAgG;AAChG,kGAAkG;AACl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ACH,MAAM,UAAU,cAAc,CAAC,MAAe,EAAE,OAAgB;IAC9D,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;IACvF,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC;AAC/E,CAAC"}
@@ -124,4 +124,71 @@ export declare const relayAnswer: z.ZodDiscriminatedUnion<[z.ZodObject<{
124
124
  message: z.ZodString;
125
125
  }, z.core.$strict>], "outcome">;
126
126
  export type RelayAnswer = z.infer<typeof relayAnswer>;
127
+ /**
128
+ * A relayed event's `body` (#3492): exactly one of #1705's two shapes, as the producer's own
129
+ * export read released it. The receiving scope's door parses it with this, never the sender's types.
130
+ */
131
+ export declare const relayEventBody: z.ZodUnion<readonly [z.ZodObject<{
132
+ event: z.ZodObject<{
133
+ id: z.core.$ZodBranded<z.ZodString, "EventId", "out">;
134
+ type: z.ZodString;
135
+ schemaVersion: z.ZodNumber;
136
+ occurredAt: z.core.$ZodBranded<z.ZodString, "Instant", "out">;
137
+ entity: z.ZodObject<{
138
+ entityType: z.ZodString;
139
+ entityId: z.ZodString;
140
+ }, z.core.$strip>;
141
+ payload: z.ZodUnknown;
142
+ hops: z.ZodNumber;
143
+ }, z.core.$strip>;
144
+ }, z.core.$strict>, z.ZodObject<{
145
+ withheld: z.ZodObject<{
146
+ id: z.core.$ZodBranded<z.ZodString, "EventId", "out">;
147
+ type: z.ZodString;
148
+ schemaVersion: z.ZodNumber;
149
+ occurredAt: z.ZodString;
150
+ entity: z.ZodObject<{
151
+ entityType: z.ZodString;
152
+ entityId: z.ZodString;
153
+ }, z.core.$strip>;
154
+ reason: z.ZodEnum<{
155
+ cascade: "cascade";
156
+ pii: "pii";
157
+ undecodable: "undecodable";
158
+ version: "version";
159
+ }>;
160
+ }, z.core.$strip>;
161
+ }, z.core.$strict>]>;
162
+ export type RelayEventBody = z.infer<typeof relayEventBody>;
163
+ /**
164
+ * What a request's resume target is invoked with (#3492): a K-62 attempt's record operation, run as
165
+ * the system of the module the target names, in the scope that waits. `answered` carries the
166
+ * reply; `expired` says why the attempt is to be abandoned. A record operation parses this as its
167
+ * input. It is handed over under one idempotency key per request, so a repeated hand-over replays.
168
+ */
169
+ export declare const relayResumeInput: z.ZodObject<{
170
+ attemptId: z.ZodString;
171
+ requestId: z.ZodString;
172
+ result: z.ZodDiscriminatedUnion<[z.ZodObject<{
173
+ outcome: z.ZodLiteral<"answered">;
174
+ reply: z.ZodObject<{
175
+ id: z.ZodString;
176
+ type: z.ZodString;
177
+ body: z.ZodUnknown;
178
+ from: z.ZodObject<{
179
+ app: z.ZodString;
180
+ scopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
181
+ actor: z.ZodLiteral<"app">;
182
+ }, z.core.$strict>;
183
+ }, z.core.$strict>;
184
+ }, z.core.$strict>, z.ZodObject<{
185
+ outcome: z.ZodLiteral<"expired">;
186
+ reason: z.ZodEnum<{
187
+ deadline: "deadline";
188
+ "no-broker": "no-broker";
189
+ refused: "refused";
190
+ }>;
191
+ }, z.core.$strict>], "outcome">;
192
+ }, z.core.$strict>;
193
+ export type RelayResumeInput = z.infer<typeof relayResumeInput>;
127
194
  //# sourceMappingURL=broker-relay.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"broker-relay.d.ts","sourceRoot":"","sources":["../src/broker-relay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,4FAA4F;AAC5F,eAAO,MAAM,iBAAiB,2BAA2B,CAAC;AAE1D,eAAO,MAAM,SAAS;;;;EAAwC,CAAC;AAC/D,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,O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} from 'zod';
2
2
  import { scopeId, tenantId, verticalSlug } from './ids.js';
3
+ import { exportedEvent, withheldEvent } from './vertical-events.js';
3
4
  // Broker to broker (K-74, rfc/broker-and-tenant-isolation.md §4.3–§4.4, #3469): the messages one
4
5
  // app's delivery broker hands another's, through the router, in the same tenant.
5
6
  //
@@ -97,4 +98,33 @@ export const relayAnswer = z.discriminatedUnion('outcome', [
97
98
  z.object({ outcome: z.literal('no-broker') }).strict(),
98
99
  z.object({ outcome: z.literal('refused'), reason: relayRefusal, message: z.string() }).strict(),
99
100
  ]);
101
+ /**
102
+ * A relayed event's `body` (#3492): exactly one of #1705's two shapes, as the producer's own
103
+ * export read released it. The receiving scope's door parses it with this, never the sender's types.
104
+ */
105
+ export const relayEventBody = z.union([
106
+ z.object({ event: exportedEvent }).strict(),
107
+ z.object({ withheld: withheldEvent }).strict(),
108
+ ]);
109
+ /**
110
+ * What a request's resume target is invoked with (#3492): a K-62 attempt's record operation, run as
111
+ * the system of the module the target names, in the scope that waits. `answered` carries the
112
+ * reply; `expired` says why the attempt is to be abandoned. A record operation parses this as its
113
+ * input. It is handed over under one idempotency key per request, so a repeated hand-over replays.
114
+ */
115
+ export const relayResumeInput = z
116
+ .object({
117
+ attemptId: z.string().min(1),
118
+ requestId: messageId,
119
+ result: z.discriminatedUnion('outcome', [
120
+ z
121
+ .object({
122
+ outcome: z.literal('answered'),
123
+ reply: z.object({ id: messageId, type: z.string().min(1), body: z.unknown(), from: brokerRelayCaller }).strict(),
124
+ })
125
+ .strict(),
126
+ z.object({ outcome: z.literal('expired'), reason: z.enum(['deadline', 'no-broker', 'refused']) }).strict(),
127
+ ]),
128
+ })
129
+ .strict();
100
130
  //# sourceMappingURL=broker-relay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"broker-relay.js","sourceRoot":"","sources":["../src/broker-relay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,Q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C,MAAM,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;SACjH,CAAC;aACD,MAAM,EAAE;QACX,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;KAC3G,CAAC;CACH,CAAC;KACD,MAAM,EAAE,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * A provider consent round, asked for by WRITING (K-58 step 6, #3374 decision (b)).
4
+ *
5
+ * A vertical used to start an in-session round by calling up: `requestConnectUrl` POSTed
6
+ * `/internal/connections/connect-url` with the shared platform credential and redirected its user
7
+ * to the URL that came back. The up-call goes. The vertical's operation writes this intent instead,
8
+ * in its own transaction, and its harness redirects the browser to a page the PLATFORM owns,
9
+ * naming the intent. That page reads the intent out of the scope that wrote it, mints the signed
10
+ * state itself, spends the intent, and sends the browser on to the consent origin. The vertical
11
+ * holds no credential for any of it, and never sees the state, the consent code or the token.
12
+ *
13
+ * The payload is the relay's body without the caller's identity. Who asked is the kernel's stamp
14
+ * on the row (`requestedBy`), and which scope asked is the scope the page read it from, so neither
15
+ * is something the payload can say.
16
+ */
17
+ export declare const CONNECT_PROVIDER_KIND = "connect-provider";
18
+ /** How long a request stays redeemable when it asks for nothing else: 15 minutes, the ceiling. */
19
+ export declare const CONNECT_REQUEST_DEFAULT_TTL_SECONDS = 900;
20
+ export declare const connectProviderRequest: z.ZodObject<{
21
+ provider: z.ZodString;
22
+ returnUrl: z.ZodOptional<z.ZodString>;
23
+ subjectRef: z.ZodOptional<z.ZodString>;
24
+ ttlSeconds: z.ZodOptional<z.ZodNumber>;
25
+ owner: z.ZodOptional<z.ZodEnum<{
26
+ scope: "scope";
27
+ tenant: "tenant";
28
+ }>>;
29
+ }, z.core.$strict>;
30
+ export type ConnectProviderRequest = z.infer<typeof connectProviderRequest>;
31
+ /**
32
+ * The platform page's path, under the control plane's public origin (the `CONTROL_PLANE_URL` a
33
+ * pushed vertical is given). The ids are path segments rather than a query, so nothing a vertical
34
+ * appends can be read as one of them.
35
+ */
36
+ export declare const CONNECT_REQUEST_PATH_PREFIX = "/connect-request";
37
+ /**
38
+ * Where a vertical's harness sends the browser once its operation wrote the request: the
39
+ * platform's page for that request. A pure string: no call, and no credential.
40
+ *
41
+ * ```ts
42
+ * const { requestId } = await scope.invoke('crm/connect-client-books', { clientId });
43
+ * return Response.redirect(connectRequestUrl(env.CONTROL_PLANE_URL, { tenantId, scopeId, requestId }), 303);
44
+ * ```
45
+ */
46
+ export declare function connectRequestUrl(controlPlaneUrl: string, ids: {
47
+ tenantId: string;
48
+ scopeId: string;
49
+ requestId: string;
50
+ }): string;
51
+ /**
52
+ * Why the page did not start a round, as the `?error=` slug it returns to the vertical with (when
53
+ * the request named a return URL that checks out), or the page it renders (when it did not).
54
+ *
55
+ * - `connect_unknown`: no pending request by that id in that scope. One answer for a request that
56
+ * never existed, one already redeemed, one in another scope, and a malformed id, so the page is
57
+ * no oracle for which requests exist.
58
+ * - `connect_expired`: the request outlived its `ttlSeconds`. Press Connect again.
59
+ * - `connect_refused`: the request is not one the platform runs a round for: no such provider, a
60
+ * preview or a fork, a scope's own round its version does not declare, a requester who is not a
61
+ * person acting as themselves, a return URL this scope does not answer on.
62
+ * - `connect_unavailable`: this deployment cannot run a round now (not configured, or the scope's
63
+ * deployment could not be reached). Nothing was spent; try again.
64
+ * - `connect_interrupted`: the round was being started when the scope's deployment stopped
65
+ * answering, so the request may already be spent. Press Connect again for a new one.
66
+ */
67
+ export declare const connectRequestRefusal: z.ZodEnum<{
68
+ connect_expired: "connect_expired";
69
+ connect_interrupted: "connect_interrupted";
70
+ connect_refused: "connect_refused";
71
+ connect_unavailable: "connect_unavailable";
72
+ connect_unknown: "connect_unknown";
73
+ }>;
74
+ export type ConnectRequestRefusal = z.infer<typeof connectRequestRefusal>;
75
+ //# sourceMappingURL=connect-intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-intent.d.ts","sourceRoot":"","sources":["../src/connect-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD,kGAAkG;AAClG,eAAO,MAAM,mCAAmC,MAAM,CAAC;AAEvD,eAAO,MAAM,sBAAsB;;;;;;;;;kBAwBxB,CAAC;AACZ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,qBAAqB,CAAC;AAE9D;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC5D,MAAM,CAIR;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB;;;;;;EAMhC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,89 @@
1
+ import { z } from 'zod';
2
+ import { connectionProvider } from './connections.js';
3
+ /**
4
+ * A provider consent round, asked for by WRITING (K-58 step 6, #3374 decision (b)).
5
+ *
6
+ * A vertical used to start an in-session round by calling up: `requestConnectUrl` POSTed
7
+ * `/internal/connections/connect-url` with the shared platform credential and redirected its user
8
+ * to the URL that came back. The up-call goes. The vertical's operation writes this intent instead,
9
+ * in its own transaction, and its harness redirects the browser to a page the PLATFORM owns,
10
+ * naming the intent. That page reads the intent out of the scope that wrote it, mints the signed
11
+ * state itself, spends the intent, and sends the browser on to the consent origin. The vertical
12
+ * holds no credential for any of it, and never sees the state, the consent code or the token.
13
+ *
14
+ * The payload is the relay's body without the caller's identity. Who asked is the kernel's stamp
15
+ * on the row (`requestedBy`), and which scope asked is the scope the page read it from, so neither
16
+ * is something the payload can say.
17
+ */
18
+ export const CONNECT_PROVIDER_KIND = 'connect-provider';
19
+ /** How long a request stays redeemable when it asks for nothing else: 15 minutes, the ceiling. */
20
+ export const CONNECT_REQUEST_DEFAULT_TTL_SECONDS = 900;
21
+ export const connectProviderRequest = z
22
+ .object({
23
+ /** Provider slug (`fortnox`). One with no platform-hosted consent round is refused at the page. */
24
+ provider: connectionProvider,
25
+ /**
26
+ * Where the browser returns when the round settles, refused or not. Must be `https:` on a
27
+ * hostname bound to the scope that wrote the request; the page checks it against the hostname
28
+ * map before it sends anyone there, so the platform's origin is never an open redirect.
29
+ */
30
+ returnUrl: z.string().url().optional(),
31
+ /** The vertical's own name for what is being connected, echoed on the return. Opaque to the platform. */
32
+ subjectRef: z.string().min(1).max(256).optional(),
33
+ /**
34
+ * Seconds the request stays redeemable, counted from the operation that wrote it. Clamped to
35
+ * 15 minutes: the person who pressed Connect is the person about to be redirected.
36
+ */
37
+ ttlSeconds: z.number().int().positive().max(CONNECT_REQUEST_DEFAULT_TTL_SECONDS).optional(),
38
+ /**
39
+ * Whose connection the round ends in (#3410): `tenant` (the default) or this scope's own. A
40
+ * scope's own round needs no further proof of the caller: the request was read out of the
41
+ * scope's own journal, which is a stronger proof than the egress hop gives the relay.
42
+ */
43
+ owner: z.enum(['tenant', 'scope']).optional(),
44
+ })
45
+ .strict();
46
+ /**
47
+ * The platform page's path, under the control plane's public origin (the `CONTROL_PLANE_URL` a
48
+ * pushed vertical is given). The ids are path segments rather than a query, so nothing a vertical
49
+ * appends can be read as one of them.
50
+ */
51
+ export const CONNECT_REQUEST_PATH_PREFIX = '/connect-request';
52
+ /**
53
+ * Where a vertical's harness sends the browser once its operation wrote the request: the
54
+ * platform's page for that request. A pure string: no call, and no credential.
55
+ *
56
+ * ```ts
57
+ * const { requestId } = await scope.invoke('crm/connect-client-books', { clientId });
58
+ * return Response.redirect(connectRequestUrl(env.CONTROL_PLANE_URL, { tenantId, scopeId, requestId }), 303);
59
+ * ```
60
+ */
61
+ export function connectRequestUrl(controlPlaneUrl, ids) {
62
+ const base = controlPlaneUrl.replace(/\/+$/, '');
63
+ const seg = (s) => encodeURIComponent(s);
64
+ return `${base}${CONNECT_REQUEST_PATH_PREFIX}/${seg(ids.tenantId)}/${seg(ids.scopeId)}/${seg(ids.requestId)}`;
65
+ }
66
+ /**
67
+ * Why the page did not start a round, as the `?error=` slug it returns to the vertical with (when
68
+ * the request named a return URL that checks out), or the page it renders (when it did not).
69
+ *
70
+ * - `connect_unknown`: no pending request by that id in that scope. One answer for a request that
71
+ * never existed, one already redeemed, one in another scope, and a malformed id, so the page is
72
+ * no oracle for which requests exist.
73
+ * - `connect_expired`: the request outlived its `ttlSeconds`. Press Connect again.
74
+ * - `connect_refused`: the request is not one the platform runs a round for: no such provider, a
75
+ * preview or a fork, a scope's own round its version does not declare, a requester who is not a
76
+ * person acting as themselves, a return URL this scope does not answer on.
77
+ * - `connect_unavailable`: this deployment cannot run a round now (not configured, or the scope's
78
+ * deployment could not be reached). Nothing was spent; try again.
79
+ * - `connect_interrupted`: the round was being started when the scope's deployment stopped
80
+ * answering, so the request may already be spent. Press Connect again for a new one.
81
+ */
82
+ export const connectRequestRefusal = z.enum([
83
+ 'connect_unknown',
84
+ 'connect_expired',
85
+ 'connect_refused',
86
+ 'connect_unavailable',
87
+ 'connect_interrupted',
88
+ ]);
89
+ //# sourceMappingURL=connect-intent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-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