@warmhub/sdk-ts 0.57.0 → 0.59.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/dist/index.d.ts CHANGED
@@ -1,3 +1,171 @@
1
+ declare const COMMIT_OPERATIONS: readonly ["add", "revise", "retract"];
2
+ type CommitOperation = (typeof COMMIT_OPERATIONS)[number];
3
+ declare const COMMIT_OPERATION_KINDS: readonly ["shape", "thing", "assertion", "collection"];
4
+ type CommitOperationKind = (typeof COMMIT_OPERATION_KINDS)[number];
5
+ type CollectionAbout$2 = {
6
+ pair: [string, string];
7
+ } | {
8
+ triple: [string, string, string];
9
+ } | {
10
+ set: string[];
11
+ } | {
12
+ list: string[];
13
+ };
14
+
15
+ /**
16
+ * Canonical request signing for component CLI dispatch.
17
+ *
18
+ * Component workers expose CLI methods over HTTP. The platform dispatcher
19
+ * signs each call with HMAC-SHA256 over a canonical request representation
20
+ * so the worker can authenticate the caller without sharing more than a
21
+ * single secret. The same canonical input works for GET and POST methods:
22
+ * the difference is whether the method args ride in the query string or
23
+ * the body.
24
+ *
25
+ * Canonical signing input:
26
+ * <METHOD>\n<PATH>\n<CANONICAL_QUERY>\n<INSTALL_REPO>\n<SHA256_HEX(BODY)>\n<TIMESTAMP>
27
+ *
28
+ * Where:
29
+ * - METHOD is the uppercased HTTP method ('GET' | 'POST').
30
+ * - PATH is the URL path component (no scheme, host, or query).
31
+ * - CANONICAL_QUERY is `canonicalCliQueryString(query)` — sorted, RFC 3986
32
+ * percent-encoded, omitting undefined / null entries.
33
+ * - INSTALL_REPO is the `<org>/<repo>` slug of the install, transmitted on
34
+ * the wire as the `X-WarmHub-Install-Repo` header.
35
+ * - BODY is the raw request body string ('' for GET).
36
+ * - TIMESTAMP is unix-seconds since epoch (string-formatted).
37
+ *
38
+ * Verifiers should enforce a tolerance window on the timestamp to bound
39
+ * replay attacks (default 300 s); they should also compare signatures in
40
+ * constant time.
41
+ *
42
+ * This module is intentionally low-level: component authors import the
43
+ * higher-level `verifyCliCall(request, secret)` wrapper from
44
+ * `@warmhub/sdk-ts`, which extracts the canonical inputs from a Fetch
45
+ * `Request` and calls `verifyCliRequest` for them.
46
+ */
47
+ /**
48
+ * Wire header names for component CLI dispatch — the single source of truth
49
+ * shared by the backend dispatcher (which sets them) and `verifyCliCall` (which
50
+ * reads them). The install repo always rides in {@link CLI_INSTALL_REPO_HEADER};
51
+ * the signing scheme adds {@link CLI_SIGNATURE_HEADER} + {@link CLI_TIMESTAMP_HEADER}.
52
+ * @see https://docs.warmhub.ai/sdk-reference/variables/cli_install_repo_header/
53
+ */
54
+ declare const CLI_INSTALL_REPO_HEADER = "X-WarmHub-Install-Repo";
55
+ /**
56
+ * @see https://docs.warmhub.ai/sdk-reference/variables/cli_signature_header/
57
+ */
58
+ declare const CLI_SIGNATURE_HEADER = "X-WarmHub-Signature";
59
+ /**
60
+ * @see https://docs.warmhub.ai/sdk-reference/variables/cli_timestamp_header/
61
+ */
62
+ declare const CLI_TIMESTAMP_HEADER = "X-WarmHub-Timestamp";
63
+ /**
64
+ * HTTP verbs a component CLI method can declare. No-body verbs (GET, DELETE)
65
+ * carry args in the query string; body verbs (POST, PUT, PATCH) carry args in
66
+ * the JSON body.
67
+ */
68
+ type CliHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
69
+
70
+ /**
71
+ * Hardcoded meta-schema for validating shape definitions.
72
+ * Shapes are NOT validated against a DB-stored shape — they validate against this constant.
73
+ * This avoids the bootstrap chicken-and-egg problem.
74
+ *
75
+ * A valid shape definition is:
76
+ * { fields: Record<string, TypeSpec>, description?: string }
77
+ * where TypeSpec is one of:
78
+ * - primitive string: "number", "string", "boolean", "wref", "array"
79
+ * - optional primitive: "number?", "string?", "boolean?", "wref?", "array?"
80
+ * - typed field object: { type: primitive, description?: string }
81
+ * - array: [TypeSpec] (shorthand) or { type: "array", items: TypeSpec }
82
+ * - nested object: { fieldName: TypeSpec, ... } (key may end with "?" for optional)
83
+ *
84
+ * The primitive vocabulary above is closed: any other type name (e.g. "text",
85
+ * "integer", "json", "date") is rejected. See VALID_PRIMITIVE_TYPES in
86
+ * ./shape-types.ts for the authoritative set.
87
+ */
88
+ /**
89
+ * Maximum size, in bytes (UTF-8 encoded), allowed for a single content field value.
90
+ * WarmHub is not a document store: values larger than this are rejected at validation.
91
+ * Store large documents in S3, Box, Drive, or another document system and reference
92
+ * them from WarmHub instead.
93
+ * @see https://docs.warmhub.ai/sdk-reference/variables/max_content_field_bytes/
94
+ */
95
+ declare const MAX_CONTENT_FIELD_BYTES: number;
96
+ /**
97
+ * Human-readable explanation of the {@link MAX_CONTENT_FIELD_BYTES} limit, suitable for
98
+ * appending to a field-specific validation error. States the byte cap and points callers
99
+ * to an external document store for large payloads.
100
+ * @see https://docs.warmhub.ai/sdk-reference/variables/content_field_limit_error/
101
+ */
102
+ declare const CONTENT_FIELD_LIMIT_ERROR: string;
103
+ /**
104
+ * Returns a validation error message if the given string exceeds
105
+ * {@link MAX_CONTENT_FIELD_BYTES} when UTF-8 encoded, or `null` if it is within the limit.
106
+ *
107
+ * @param path - The field path, used to identify the offending field in the message.
108
+ * @param value - The candidate field value to measure.
109
+ * @see https://docs.warmhub.ai/sdk-reference/functions/contentfieldlimiterror/
110
+ */
111
+ declare function contentFieldLimitError(path: string, value: string): string | null;
112
+ /**
113
+ * Validate a data payload against shape field definitions.
114
+ *
115
+ * Shape field types:
116
+ * - "number", "string", "boolean": primitive types
117
+ * - "wref": string (reference to another thing)
118
+ * - Typed field objects: { type: primitive, description?: string }
119
+ * - Nested objects: { fieldName: type, ... }
120
+ * - Arrays: [elementType]
121
+ * - Optional fields: field name ending with "?" (e.g. "terminal_reason?": "string")
122
+ * OR type string ending with "?" (e.g. "terminal_reason": "string?")
123
+ * OR typed object type ending with "?" (e.g. { type: "string?" })
124
+ *
125
+ * For v1 this is permissive: validates top-level field existence and basic types.
126
+ * Returns a {@link ShapeValidatorResult} discriminated union — read `result.valid`
127
+ * to branch, then `result.errors` (only present when invalid) for the list of
128
+ * messages. `result.warnings` may be present in either branch and carries
129
+ * undeclared top-level field names.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * import { validateAgainstShape } from "@warmhub/sdk-ts";
134
+ *
135
+ * const shapeFields = { x: "number", y: "number", label: "string?" };
136
+ *
137
+ * const ok = validateAgainstShape({ x: 1, y: 2 }, shapeFields);
138
+ * // ok.valid === true
139
+ *
140
+ * const bad = validateAgainstShape({ x: "not-a-number" }, shapeFields);
141
+ * if (!bad.valid) {
142
+ * for (const message of bad.errors) console.error(message);
143
+ * // ['Field "x" must be a number', 'Missing required field: "y"']
144
+ * }
145
+ * ```
146
+ * @see https://docs.warmhub.ai/sdk-reference/functions/validateagainstshape/
147
+ */
148
+ declare function validateAgainstShape(data: Record<string, unknown>, shapeFields: Record<string, unknown>): ShapeValidatorResult;
149
+ /**
150
+ * @see https://docs.warmhub.ai/sdk-reference/type-aliases/undeclaredfieldswarning/
151
+ */
152
+ type UndeclaredFieldsWarning = {
153
+ undeclaredFields: string[];
154
+ undeclaredFieldsTruncated?: true;
155
+ totalUndeclared?: number;
156
+ };
157
+ /**
158
+ * @see https://docs.warmhub.ai/sdk-reference/type-aliases/shapevalidatorresult/
159
+ */
160
+ type ShapeValidatorResult = {
161
+ valid: true;
162
+ warnings?: UndeclaredFieldsWarning;
163
+ } | {
164
+ valid: false;
165
+ errors: string[];
166
+ warnings?: UndeclaredFieldsWarning;
167
+ };
168
+
1
169
  type ActionAttempt = {
2
170
  attempt: number;
3
171
  status: string;
@@ -88,7 +256,7 @@ type AccessResolveResult$1 = {
88
256
  orgName: string;
89
257
  repoName: string;
90
258
  visible: boolean;
91
- scopes: Array<'repo:read' | 'repo:write' | 'repo:configure' | 'repo:admin'>;
259
+ scopes: Array<'repo:read' | 'repo:write' | 'repo:configure' | 'repo:admin' | 'repo:action-callback'>;
92
260
  allowedMatches?: Array<string>;
93
261
  }>;
94
262
  orgs: Array<{
@@ -100,7 +268,7 @@ type AccessResolveResult$1 = {
100
268
  type AuthSyncResult = {
101
269
  success: boolean;
102
270
  };
103
- type CollectionAbout$2 = {
271
+ type CollectionAbout$1 = {
104
272
  pair: [string, string];
105
273
  } | {
106
274
  triple: [string, string, string];
@@ -333,7 +501,7 @@ type StreamAppendInput$1 = {
333
501
  } | {
334
502
  operation: 'retract';
335
503
  name: string;
336
- kind?: 'thing' | 'assertion' | 'shape' | 'collection';
504
+ kind?: 'shape' | 'thing' | 'assertion' | 'collection';
337
505
  reason?: string;
338
506
  leaseId?: string;
339
507
  }>;
@@ -691,7 +859,7 @@ interface AddOperation {
691
859
  * (1–2 segments → thing, 3+ segments → assertion). Shape adds always
692
860
  * require explicit `kind: 'shape'`.
693
861
  */
694
- kind?: 'shape' | 'thing' | 'assertion' | 'collection';
862
+ kind?: CommitOperationKind;
695
863
  /**
696
864
  * Target name. Use `Shape/localName` for things and assertions; use the
697
865
  * plain shape name for shapes.
@@ -701,7 +869,7 @@ interface AddOperation {
701
869
  * Assertion target wref or inline collection descriptor. Presence of
702
870
  * `about` makes the add an assertion unless `kind` overrides it.
703
871
  */
704
- about?: string | CollectionAbout$2;
872
+ about?: string | CollectionAbout$1;
705
873
  /**
706
874
  * Shape-validated data payload for shape, thing, or assertion adds.
707
875
  */
@@ -741,7 +909,7 @@ interface ReviseOperation {
741
909
  /**
742
910
  * Optional kind safety hint: `shape`, `thing`, `assertion`, or `collection`.
743
911
  */
744
- kind?: 'shape' | 'thing' | 'assertion' | 'collection';
912
+ kind?: CommitOperationKind;
745
913
  /**
746
914
  * Target name to revise. Equivalent to `wref` for local paths.
747
915
  */
@@ -792,7 +960,7 @@ interface RetractOperation {
792
960
  /**
793
961
  * Optional kind safety hint: `thing`, `assertion`, `shape`, or `collection`.
794
962
  */
795
- kind?: 'thing' | 'assertion' | 'shape' | 'collection';
963
+ kind?: CommitOperationKind;
796
964
  /**
797
965
  * Optional human-readable retraction reason.
798
966
  */
@@ -849,6 +1017,7 @@ declare const DEFAULT_STREAM_CHUNK_SIZE = 1000;
849
1017
  * @internal
850
1018
  */
851
1019
  declare const MAX_STREAM_APPEND_OPERATION_COUNT = 10000;
1020
+ type CommitResultOperation$1 = CommitOperation | 'noop';
852
1021
  interface OperationStreamClient {
853
1022
  stream: {
854
1023
  append(input: StreamAppendInput$1): Promise<StreamAppendResult$1>;
@@ -868,7 +1037,7 @@ type SubmittedStreamResult = {
868
1037
  operations: Array<{
869
1038
  opIndex?: number;
870
1039
  name: string;
871
- operation: 'add' | 'revise' | 'retract' | 'noop';
1040
+ operation: CommitResultOperation$1;
872
1041
  dataHash: string;
873
1042
  version: number;
874
1043
  status?: 'applied' | 'noop' | 'error';
@@ -1060,170 +1229,6 @@ declare function submitOperationsViaStream(client: OperationStreamClient, args:
1060
1229
  retry?: RetryPolicyOptions | false;
1061
1230
  }): Promise<SubmittedStreamResult>;
1062
1231
 
1063
- type CollectionAbout$1 = {
1064
- pair: [string, string];
1065
- } | {
1066
- triple: [string, string, string];
1067
- } | {
1068
- set: string[];
1069
- } | {
1070
- list: string[];
1071
- };
1072
-
1073
- /**
1074
- * Canonical request signing for component CLI dispatch.
1075
- *
1076
- * Component workers expose CLI methods over HTTP. The platform dispatcher
1077
- * signs each call with HMAC-SHA256 over a canonical request representation
1078
- * so the worker can authenticate the caller without sharing more than a
1079
- * single secret. The same canonical input works for GET and POST methods:
1080
- * the difference is whether the method args ride in the query string or
1081
- * the body.
1082
- *
1083
- * Canonical signing input:
1084
- * <METHOD>\n<PATH>\n<CANONICAL_QUERY>\n<INSTALL_REPO>\n<SHA256_HEX(BODY)>\n<TIMESTAMP>
1085
- *
1086
- * Where:
1087
- * - METHOD is the uppercased HTTP method ('GET' | 'POST').
1088
- * - PATH is the URL path component (no scheme, host, or query).
1089
- * - CANONICAL_QUERY is `canonicalCliQueryString(query)` — sorted, RFC 3986
1090
- * percent-encoded, omitting undefined / null entries.
1091
- * - INSTALL_REPO is the `<org>/<repo>` slug of the install, transmitted on
1092
- * the wire as the `X-WarmHub-Install-Repo` header.
1093
- * - BODY is the raw request body string ('' for GET).
1094
- * - TIMESTAMP is unix-seconds since epoch (string-formatted).
1095
- *
1096
- * Verifiers should enforce a tolerance window on the timestamp to bound
1097
- * replay attacks (default 300 s); they should also compare signatures in
1098
- * constant time.
1099
- *
1100
- * This module is intentionally low-level: component authors import the
1101
- * higher-level `verifyCliCall(request, secret)` wrapper from
1102
- * `@warmhub/sdk-ts`, which extracts the canonical inputs from a Fetch
1103
- * `Request` and calls `verifyCliRequest` for them.
1104
- */
1105
- /**
1106
- * Wire header names for component CLI dispatch — the single source of truth
1107
- * shared by the backend dispatcher (which sets them) and `verifyCliCall` (which
1108
- * reads them). The install repo always rides in {@link CLI_INSTALL_REPO_HEADER};
1109
- * the signing scheme adds {@link CLI_SIGNATURE_HEADER} + {@link CLI_TIMESTAMP_HEADER}.
1110
- * @see https://docs.warmhub.ai/sdk-reference/variables/cli_install_repo_header/
1111
- */
1112
- declare const CLI_INSTALL_REPO_HEADER = "X-WarmHub-Install-Repo";
1113
- /**
1114
- * @see https://docs.warmhub.ai/sdk-reference/variables/cli_signature_header/
1115
- */
1116
- declare const CLI_SIGNATURE_HEADER = "X-WarmHub-Signature";
1117
- /**
1118
- * @see https://docs.warmhub.ai/sdk-reference/variables/cli_timestamp_header/
1119
- */
1120
- declare const CLI_TIMESTAMP_HEADER = "X-WarmHub-Timestamp";
1121
- /**
1122
- * HTTP verbs a component CLI method can declare. No-body verbs (GET, DELETE)
1123
- * carry args in the query string; body verbs (POST, PUT, PATCH) carry args in
1124
- * the JSON body.
1125
- */
1126
- type CliHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
1127
-
1128
- /**
1129
- * Hardcoded meta-schema for validating shape definitions.
1130
- * Shapes are NOT validated against a DB-stored shape — they validate against this constant.
1131
- * This avoids the bootstrap chicken-and-egg problem.
1132
- *
1133
- * A valid shape definition is:
1134
- * { fields: Record<string, TypeSpec>, description?: string }
1135
- * where TypeSpec is one of:
1136
- * - primitive string: "number", "string", "boolean", "wref", "array"
1137
- * - optional primitive: "number?", "string?", "boolean?", "wref?", "array?"
1138
- * - typed field object: { type: primitive, description?: string }
1139
- * - array: [TypeSpec] (shorthand) or { type: "array", items: TypeSpec }
1140
- * - nested object: { fieldName: TypeSpec, ... } (key may end with "?" for optional)
1141
- *
1142
- * The primitive vocabulary above is closed: any other type name (e.g. "text",
1143
- * "integer", "json", "date") is rejected. See VALID_PRIMITIVE_TYPES in
1144
- * ./shape-types.ts for the authoritative set.
1145
- */
1146
- /**
1147
- * Maximum size, in bytes (UTF-8 encoded), allowed for a single content field value.
1148
- * WarmHub is not a document store: values larger than this are rejected at validation.
1149
- * Store large documents in S3, Box, Drive, or another document system and reference
1150
- * them from WarmHub instead.
1151
- * @see https://docs.warmhub.ai/sdk-reference/variables/max_content_field_bytes/
1152
- */
1153
- declare const MAX_CONTENT_FIELD_BYTES: number;
1154
- /**
1155
- * Human-readable explanation of the {@link MAX_CONTENT_FIELD_BYTES} limit, suitable for
1156
- * appending to a field-specific validation error. States the byte cap and points callers
1157
- * to an external document store for large payloads.
1158
- * @see https://docs.warmhub.ai/sdk-reference/variables/content_field_limit_error/
1159
- */
1160
- declare const CONTENT_FIELD_LIMIT_ERROR: string;
1161
- /**
1162
- * Returns a validation error message if the given string exceeds
1163
- * {@link MAX_CONTENT_FIELD_BYTES} when UTF-8 encoded, or `null` if it is within the limit.
1164
- *
1165
- * @param path - The field path, used to identify the offending field in the message.
1166
- * @param value - The candidate field value to measure.
1167
- * @see https://docs.warmhub.ai/sdk-reference/functions/contentfieldlimiterror/
1168
- */
1169
- declare function contentFieldLimitError(path: string, value: string): string | null;
1170
- /**
1171
- * Validate a data payload against shape field definitions.
1172
- *
1173
- * Shape field types:
1174
- * - "number", "string", "boolean": primitive types
1175
- * - "wref": string (reference to another thing)
1176
- * - Typed field objects: { type: primitive, description?: string }
1177
- * - Nested objects: { fieldName: type, ... }
1178
- * - Arrays: [elementType]
1179
- * - Optional fields: field name ending with "?" (e.g. "terminal_reason?": "string")
1180
- * OR type string ending with "?" (e.g. "terminal_reason": "string?")
1181
- * OR typed object type ending with "?" (e.g. { type: "string?" })
1182
- *
1183
- * For v1 this is permissive: validates top-level field existence and basic types.
1184
- * Returns a {@link ShapeValidatorResult} discriminated union — read `result.valid`
1185
- * to branch, then `result.errors` (only present when invalid) for the list of
1186
- * messages. `result.warnings` may be present in either branch and carries
1187
- * undeclared top-level field names.
1188
- *
1189
- * @example
1190
- * ```ts
1191
- * import { validateAgainstShape } from "@warmhub/sdk-ts";
1192
- *
1193
- * const shapeFields = { x: "number", y: "number", label: "string?" };
1194
- *
1195
- * const ok = validateAgainstShape({ x: 1, y: 2 }, shapeFields);
1196
- * // ok.valid === true
1197
- *
1198
- * const bad = validateAgainstShape({ x: "not-a-number" }, shapeFields);
1199
- * if (!bad.valid) {
1200
- * for (const message of bad.errors) console.error(message);
1201
- * // ['Field "x" must be a number', 'Missing required field: "y"']
1202
- * }
1203
- * ```
1204
- * @see https://docs.warmhub.ai/sdk-reference/functions/validateagainstshape/
1205
- */
1206
- declare function validateAgainstShape(data: Record<string, unknown>, shapeFields: Record<string, unknown>): ShapeValidatorResult;
1207
- /**
1208
- * @see https://docs.warmhub.ai/sdk-reference/type-aliases/undeclaredfieldswarning/
1209
- */
1210
- type UndeclaredFieldsWarning = {
1211
- undeclaredFields: string[];
1212
- undeclaredFieldsTruncated?: true;
1213
- totalUndeclared?: number;
1214
- };
1215
- /**
1216
- * @see https://docs.warmhub.ai/sdk-reference/type-aliases/shapevalidatorresult/
1217
- */
1218
- type ShapeValidatorResult = {
1219
- valid: true;
1220
- warnings?: UndeclaredFieldsWarning;
1221
- } | {
1222
- valid: false;
1223
- errors: string[];
1224
- warnings?: UndeclaredFieldsWarning;
1225
- };
1226
-
1227
1232
  /**
1228
1233
  * Server-side verifier for component CLI dispatch calls.
1229
1234
  *
@@ -1347,7 +1352,7 @@ interface AddOp {
1347
1352
  /**
1348
1353
  * Assertion target wref or inline collection descriptor. Presence of `about` makes the add an assertion unless `kind` overrides it.
1349
1354
  */
1350
- readonly about?: string | CollectionAbout$1;
1355
+ readonly about?: string | CollectionAbout$2;
1351
1356
  /**
1352
1357
  * Collection type. Used only for collection adds.
1353
1358
  */
@@ -1429,7 +1434,7 @@ interface RetractOp {
1429
1434
  /**
1430
1435
  * Optional kind safety hint: `thing`, `assertion`, `shape`, or `collection`.
1431
1436
  */
1432
- readonly kind?: 'thing' | 'assertion' | 'shape' | 'collection';
1437
+ readonly kind?: CommitOperationKind;
1433
1438
  /**
1434
1439
  * Optional human-readable retraction reason.
1435
1440
  */
@@ -1559,7 +1564,7 @@ declare class OperationBuilder {
1559
1564
  */
1560
1565
  retract(target: string | {
1561
1566
  name: string;
1562
- kind?: 'thing' | 'assertion' | 'shape' | 'collection';
1567
+ kind?: CommitOperationKind;
1563
1568
  reason?: string;
1564
1569
  leaseId?: string;
1565
1570
  }): this;
@@ -1633,7 +1638,7 @@ declare class OperationBuilder {
1633
1638
  }
1634
1639
 
1635
1640
  /** @internal */
1636
- type CollectionAbout = CollectionAbout$2;
1641
+ type CollectionAbout = CollectionAbout$1;
1637
1642
  /** @internal */
1638
1643
  type CollectionTag = CollectionTag$1;
1639
1644
  /** @internal */
@@ -1699,6 +1704,49 @@ interface RequestEvent {
1699
1704
  operation: 'query' | 'mutation' | 'action';
1700
1705
  functionPath: string;
1701
1706
  }
1707
+ /**
1708
+ * Argument forms for the single-subscription management methods (`get`,
1709
+ * `reveal`, `pause`, `resume`, `remove`). GH-4679: the positional
1710
+ * `(orgName, repoName, name)` form addresses a repo-scoped subscription; the
1711
+ * object form may omit `repoName` to address an org-scoped (`org.renamed`)
1712
+ * subscription — `get({ orgName, name })`.
1713
+ */
1714
+ type SubscriptionRefArgs = [orgName: string, repoName: string, name: string] | [ref: {
1715
+ orgName: string;
1716
+ repoName?: string;
1717
+ name: string;
1718
+ }];
1719
+ /** Argument forms for `list` — see {@link SubscriptionRefArgs}. */
1720
+ type SubscriptionListArgs = [orgName: string, repoName?: string] | [ref: {
1721
+ orgName: string;
1722
+ repoName?: string;
1723
+ }];
1724
+ /**
1725
+ * Argument forms for `bindCredentials` — positional `(orgName, repoName,
1726
+ * subscriptionName, credentialSetName)` addresses a repo-scoped subscription;
1727
+ * the object form may omit `repoName` for an org-scoped subscription.
1728
+ */
1729
+ type SubscriptionBindArgs = [
1730
+ orgName: string,
1731
+ repoName: string,
1732
+ subscriptionName: string,
1733
+ credentialSetName: string
1734
+ ] | [
1735
+ ref: {
1736
+ orgName: string;
1737
+ repoName?: string;
1738
+ subscriptionName: string;
1739
+ credentialSetName: string;
1740
+ }
1741
+ ];
1742
+ /** Argument forms for `unbindCredentials` — see {@link SubscriptionBindArgs}. */
1743
+ type SubscriptionUnbindArgs = [orgName: string, repoName: string, subscriptionName: string] | [
1744
+ ref: {
1745
+ orgName: string;
1746
+ repoName?: string;
1747
+ subscriptionName: string;
1748
+ }
1749
+ ];
1702
1750
  /** @internal */
1703
1751
  type CoreErrorKind = 'BACKEND' | 'NOT_FOUND' | 'FORBIDDEN' | 'UNAUTHENTICATED' | 'VALIDATION_ERROR' | 'CONFLICT' | 'RATE_LIMITED' | 'CANCELLED' | 'NETWORK';
1704
1752
  /**
@@ -1745,13 +1793,14 @@ type ShapeChange = ShapeChangeResult;
1745
1793
  type Shape = ShapeGetResult;
1746
1794
  /** @internal */
1747
1795
  type ShapeList = ShapeListResult;
1796
+ type CommitResultOperation = CommitOperation | 'noop';
1748
1797
  /**
1749
1798
  * Result of `client.shape.remove` — confirms the retraction with the new version metadata.
1750
1799
  * @internal
1751
1800
  */
1752
1801
  type ShapeRemove = {
1753
1802
  name: string;
1754
- operation: 'add' | 'revise' | 'retract' | 'noop';
1803
+ operation: CommitResultOperation;
1755
1804
  version: number;
1756
1805
  dataHash: string;
1757
1806
  removed: true;
@@ -1799,10 +1848,8 @@ type SubscriptionInfo = {
1799
1848
  */
1800
1849
  type SubscriptionList = SubscriptionInfo[];
1801
1850
  /** @internal */
1802
- type SubscriptionCompatCreateBase = {
1851
+ type SubscriptionCompatCreateCommon = {
1803
1852
  orgName: string;
1804
- repoName: string;
1805
- shapeName?: string;
1806
1853
  name: string;
1807
1854
  webhookUrl: string;
1808
1855
  fallbackWebhookUrl?: string;
@@ -1810,35 +1857,57 @@ type SubscriptionCompatCreateBase = {
1810
1857
  notifyOnSuccess?: boolean;
1811
1858
  componentRef?: string;
1812
1859
  workspacePolicy?: never;
1860
+ kind: 'webhook';
1813
1861
  /** @internal */
1814
1862
  actionContainer?: string;
1815
1863
  /** @internal */
1816
1864
  actionContainerConfig?: unknown;
1817
1865
  };
1818
1866
  /**
1819
- * Input shape for `client.subscription.create`. Webhook subscriptions require
1820
- * `filterJson` and `webhookUrl`, and must identify a shape via `shapeName`
1821
- * or `filterJson.shape` (or a shape-lifecycle `{ kind: 'shape' }` filter).
1822
- * The cron kind was retired from public surfaces; legacy cron rows remain
1823
- * readable via {@link SubscriptionInfo}.
1867
+ * Input shape for `client.subscription.create`, discriminated on `eventType`
1868
+ * (GH-4679):
1869
+ *
1870
+ * - default / `commit` — operation-based, repo-scoped (`repoName`); requires a
1871
+ * `filterJson` object and a shape binding (`shapeName` or `filterJson.shape`).
1872
+ * - `repo.renamed` — repo-scoped metadata event; no shape/filter/source.
1873
+ * - `org.renamed` — org-scoped metadata event; no `repoName`/shape/filter/source.
1874
+ *
1875
+ * The metadata variants forbid the commit-only fields at the type level so
1876
+ * invalid shapes fail at compile time, not just server-side.
1824
1877
  *
1825
1878
  * @see https://docs.warmhub.ai/subscriptions/creating/
1826
1879
  */
1827
- type SubscriptionCompatCreateInput = SubscriptionCompatCreateBase & {
1828
- kind: 'webhook';
1880
+ type SubscriptionCompatCreateInput = (SubscriptionCompatCreateCommon & {
1881
+ eventType?: 'commit';
1882
+ repoName: string;
1829
1883
  filterJson: Record<string, unknown>;
1884
+ shapeName?: string;
1830
1885
  sourceRepoRef?: string;
1831
- };
1886
+ }) | (SubscriptionCompatCreateCommon & {
1887
+ eventType: 'repo.renamed';
1888
+ repoName: string;
1889
+ filterJson?: never;
1890
+ shapeName?: never;
1891
+ sourceRepoRef?: never;
1892
+ }) | (SubscriptionCompatCreateCommon & {
1893
+ eventType: 'org.renamed';
1894
+ repoName?: never;
1895
+ filterJson?: never;
1896
+ shapeName?: never;
1897
+ sourceRepoRef?: never;
1898
+ });
1832
1899
  /**
1833
- * Input shape for `client.subscription.update`. `orgName`, `repoName`, and
1834
- * `name` identify the subscription; all other fields are optional and only
1835
- * the ones you provide get patched.
1900
+ * Input shape for `client.subscription.update`. `orgName` and `name` identify
1901
+ * the subscription; omit `repoName` to update an org-scoped (`org.renamed`)
1902
+ * subscription. All other fields are optional and only the ones you provide get
1903
+ * patched. Rename subscriptions (`repo.renamed`/`org.renamed`) reject
1904
+ * `shapeName`/`filterJson` — they have only delivery fields to edit.
1836
1905
  *
1837
1906
  * @see https://docs.warmhub.ai/subscriptions/managing/#update-subscription
1838
1907
  */
1839
1908
  type SubscriptionCompatUpdateInput = {
1840
1909
  orgName: string;
1841
- repoName: string;
1910
+ repoName?: string;
1842
1911
  name: string;
1843
1912
  shapeName?: string;
1844
1913
  filterJson?: Record<string, unknown>;
@@ -2361,7 +2430,7 @@ type HistoryResult = {
2361
2430
  versions: Array<{
2362
2431
  version: number;
2363
2432
  wref: string;
2364
- operation: 'add' | 'revise' | 'retract';
2433
+ operation: CommitOperation;
2365
2434
  retractReason?: string;
2366
2435
  active: boolean;
2367
2436
  createdAt: number;
@@ -2381,7 +2450,7 @@ type ThingHeadRequest = {
2381
2450
  orgName: string;
2382
2451
  repoName: string;
2383
2452
  shape?: string;
2384
- kind?: 'shape' | 'thing' | 'assertion' | 'collection';
2453
+ kind?: CommitOperationKind;
2385
2454
  match?: string;
2386
2455
  dataMode?: 'full' | 'summary' | 'none';
2387
2456
  includeRetracted?: boolean;
@@ -2630,7 +2699,7 @@ type FilterOptions = {
2630
2699
  /** Filter to records of this shape name (for example `Player`). */
2631
2700
  shape?: string;
2632
2701
  /** Filter to records of this kind: `shape`, `thing`, `assertion`, or `collection`. */
2633
- kind?: 'shape' | 'thing' | 'assertion' | 'collection';
2702
+ kind?: CommitOperationKind;
2634
2703
  /** Filter assertions whose `about` target wref matches the supplied value. */
2635
2704
  about?: string;
2636
2705
  /** Glob pattern matched against record names (for example `Player/*`). */
@@ -3483,8 +3552,12 @@ declare class WarmHubClient {
3483
3552
  create: (input: SubscriptionCompatCreateInput) => Promise<SubscriptionInfo>;
3484
3553
  /**
3485
3554
  * Get one subscription by name.
3555
+ *
3556
+ * Repo-scoped subscriptions are addressed by `(orgName, repoName, name)`;
3557
+ * org-scoped subscriptions (`org.renamed`) omit `repoName` via the object
3558
+ * form: `get({ orgName, name })`.
3486
3559
  */
3487
- get: (orgName: string, repoName: string, name: string) => Promise<SubscriptionInfo>;
3560
+ get: (...args: SubscriptionRefArgs) => Promise<SubscriptionInfo>;
3488
3561
  /**
3489
3562
  * Reveal the raw webhook URL(s) for a subscription.
3490
3563
  *
@@ -3495,11 +3568,15 @@ declare class WarmHubClient {
3495
3568
  * setup token) may reveal only the subscriptions it is scoped to — a
3496
3569
  * stricter contract than the redacted `get`/`list`, which are unscoped.
3497
3570
  */
3498
- reveal: (orgName: string, repoName: string, name: string) => Promise<SubscriptionRevealResult>;
3571
+ reveal: (...args: SubscriptionRefArgs) => Promise<SubscriptionRevealResult>;
3499
3572
  /**
3500
- * List subscriptions attached to a repository.
3573
+ * List subscriptions in a scope.
3574
+ *
3575
+ * Pass `(orgName, repoName)` to list a repository's subscriptions, or omit
3576
+ * `repoName` — `list(orgName)` or `list({ orgName })` — to list the
3577
+ * org-scoped (`org.renamed`) subscriptions.
3501
3578
  */
3502
- list: (orgName: string, repoName: string) => Promise<SubscriptionList>;
3579
+ list: (...args: SubscriptionListArgs) => Promise<SubscriptionList>;
3503
3580
  /**
3504
3581
  * Update an existing webhook subscription.
3505
3582
  *
@@ -3508,32 +3585,43 @@ declare class WarmHubClient {
3508
3585
  update: (input: SubscriptionCompatUpdateInput) => Promise<SubscriptionInfo>;
3509
3586
  /**
3510
3587
  * Pause a subscription.
3588
+ *
3589
+ * Omit `repoName` (object form) to pause an org-scoped subscription.
3511
3590
  */
3512
- pause: (orgName: string, repoName: string, name: string) => Promise<{
3591
+ pause: (...args: SubscriptionRefArgs) => Promise<{
3513
3592
  name: string;
3514
3593
  active: boolean;
3515
3594
  }>;
3516
3595
  /**
3517
3596
  * Resume a paused subscription.
3597
+ *
3598
+ * Omit `repoName` (object form) to resume an org-scoped subscription.
3518
3599
  */
3519
- resume: (orgName: string, repoName: string, name: string) => Promise<{
3600
+ resume: (...args: SubscriptionRefArgs) => Promise<{
3520
3601
  name: string;
3521
3602
  active: boolean;
3522
3603
  }>;
3523
3604
  /**
3524
3605
  * Delete a subscription.
3606
+ *
3607
+ * Omit `repoName` (object form) to delete an org-scoped subscription.
3525
3608
  */
3526
- remove: (orgName: string, repoName: string, name: string) => Promise<{
3609
+ remove: (...args: SubscriptionRefArgs) => Promise<{
3527
3610
  ok: true;
3528
3611
  }>;
3529
3612
  /**
3530
3613
  * Bind a credential set to a subscription for outbound webhook authentication.
3614
+ *
3615
+ * Omit `repoName` (object form) to bind an org-scoped subscription to one of
3616
+ * the org's org-scoped credential sets.
3531
3617
  */
3532
- bindCredentials: (orgName: string, repoName: string, subscriptionName: string, credentialSetName: string) => Promise<SubscriptionBindCredentialsResult>;
3618
+ bindCredentials: (...args: SubscriptionBindArgs) => Promise<SubscriptionBindCredentialsResult>;
3533
3619
  /**
3534
3620
  * Remove the credential set currently bound to a subscription.
3621
+ *
3622
+ * Omit `repoName` (object form) for an org-scoped subscription.
3535
3623
  */
3536
- unbindCredentials: (orgName: string, repoName: string, subscriptionName: string) => Promise<SubscriptionUnbindCredentialsResult>;
3624
+ unbindCredentials: (...args: SubscriptionUnbindArgs) => Promise<SubscriptionUnbindCredentialsResult>;
3537
3625
  };
3538
3626
  /**
3539
3627
  * Low-level action lease, delivery, run, and notification primitives for subscription consumers.