@iveri/contracts 0.5.0 → 0.7.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 (86) hide show
  1. package/README.md +8 -2
  2. package/dist/cjs/api/conduit/connection.type.d.ts +100 -0
  3. package/dist/cjs/api/conduit/connection.type.d.ts.map +1 -0
  4. package/dist/cjs/api/conduit/connection.type.js +3 -0
  5. package/dist/cjs/api/conduit/connection.type.js.map +1 -0
  6. package/dist/cjs/api/conduit/connector-auth-type.enum.d.ts +42 -0
  7. package/dist/cjs/api/conduit/connector-auth-type.enum.d.ts.map +1 -0
  8. package/dist/cjs/api/conduit/connector-auth-type.enum.js +46 -0
  9. package/dist/cjs/api/conduit/connector-auth-type.enum.js.map +1 -0
  10. package/dist/cjs/api/conduit/connector.type.d.ts +179 -0
  11. package/dist/cjs/api/conduit/connector.type.d.ts.map +1 -0
  12. package/dist/cjs/api/conduit/connector.type.js +13 -0
  13. package/dist/cjs/api/conduit/connector.type.js.map +1 -0
  14. package/dist/cjs/api/conduit/dispatch-status.enum.d.ts +40 -0
  15. package/dist/cjs/api/conduit/dispatch-status.enum.d.ts.map +1 -0
  16. package/dist/cjs/api/conduit/dispatch-status.enum.js +44 -0
  17. package/dist/cjs/api/conduit/dispatch-status.enum.js.map +1 -0
  18. package/dist/cjs/api/conduit/dispatch.type.d.ts +143 -0
  19. package/dist/cjs/api/conduit/dispatch.type.d.ts.map +1 -0
  20. package/dist/cjs/api/conduit/dispatch.type.js +3 -0
  21. package/dist/cjs/api/conduit/dispatch.type.js.map +1 -0
  22. package/dist/cjs/api/conduit/index.d.ts +5 -0
  23. package/dist/cjs/api/conduit/index.d.ts.map +1 -1
  24. package/dist/cjs/api/conduit/index.js +5 -0
  25. package/dist/cjs/api/conduit/index.js.map +1 -1
  26. package/dist/cjs/api/identity/access-token-payload.interface.d.ts +53 -0
  27. package/dist/cjs/api/identity/access-token-payload.interface.d.ts.map +1 -0
  28. package/dist/cjs/api/identity/access-token-payload.interface.js +3 -0
  29. package/dist/cjs/api/identity/access-token-payload.interface.js.map +1 -0
  30. package/dist/cjs/api/identity/auth.type.d.ts +21 -0
  31. package/dist/cjs/api/identity/auth.type.d.ts.map +1 -1
  32. package/dist/cjs/api/identity/index.d.ts +2 -0
  33. package/dist/cjs/api/identity/index.d.ts.map +1 -1
  34. package/dist/cjs/api/identity/index.js +2 -0
  35. package/dist/cjs/api/identity/index.js.map +1 -1
  36. package/dist/cjs/api/identity/principal-type.enum.d.ts +19 -0
  37. package/dist/cjs/api/identity/principal-type.enum.d.ts.map +1 -0
  38. package/dist/cjs/api/identity/principal-type.enum.js +23 -0
  39. package/dist/cjs/api/identity/principal-type.enum.js.map +1 -0
  40. package/dist/cjs/enum/user-permission.enum.d.ts +40 -1
  41. package/dist/cjs/enum/user-permission.enum.d.ts.map +1 -1
  42. package/dist/cjs/enum/user-permission.enum.js +42 -0
  43. package/dist/cjs/enum/user-permission.enum.js.map +1 -1
  44. package/dist/esm/api/conduit/connection.type.d.ts +100 -0
  45. package/dist/esm/api/conduit/connection.type.d.ts.map +1 -0
  46. package/dist/esm/api/conduit/connection.type.js +2 -0
  47. package/dist/esm/api/conduit/connection.type.js.map +1 -0
  48. package/dist/esm/api/conduit/connector-auth-type.enum.d.ts +42 -0
  49. package/dist/esm/api/conduit/connector-auth-type.enum.d.ts.map +1 -0
  50. package/dist/esm/api/conduit/connector-auth-type.enum.js +43 -0
  51. package/dist/esm/api/conduit/connector-auth-type.enum.js.map +1 -0
  52. package/dist/esm/api/conduit/connector.type.d.ts +179 -0
  53. package/dist/esm/api/conduit/connector.type.d.ts.map +1 -0
  54. package/dist/esm/api/conduit/connector.type.js +10 -0
  55. package/dist/esm/api/conduit/connector.type.js.map +1 -0
  56. package/dist/esm/api/conduit/dispatch-status.enum.d.ts +40 -0
  57. package/dist/esm/api/conduit/dispatch-status.enum.d.ts.map +1 -0
  58. package/dist/esm/api/conduit/dispatch-status.enum.js +41 -0
  59. package/dist/esm/api/conduit/dispatch-status.enum.js.map +1 -0
  60. package/dist/esm/api/conduit/dispatch.type.d.ts +143 -0
  61. package/dist/esm/api/conduit/dispatch.type.d.ts.map +1 -0
  62. package/dist/esm/api/conduit/dispatch.type.js +2 -0
  63. package/dist/esm/api/conduit/dispatch.type.js.map +1 -0
  64. package/dist/esm/api/conduit/index.d.ts +5 -0
  65. package/dist/esm/api/conduit/index.d.ts.map +1 -1
  66. package/dist/esm/api/conduit/index.js +5 -0
  67. package/dist/esm/api/conduit/index.js.map +1 -1
  68. package/dist/esm/api/identity/access-token-payload.interface.d.ts +53 -0
  69. package/dist/esm/api/identity/access-token-payload.interface.d.ts.map +1 -0
  70. package/dist/esm/api/identity/access-token-payload.interface.js +2 -0
  71. package/dist/esm/api/identity/access-token-payload.interface.js.map +1 -0
  72. package/dist/esm/api/identity/auth.type.d.ts +21 -0
  73. package/dist/esm/api/identity/auth.type.d.ts.map +1 -1
  74. package/dist/esm/api/identity/index.d.ts +2 -0
  75. package/dist/esm/api/identity/index.d.ts.map +1 -1
  76. package/dist/esm/api/identity/index.js +2 -0
  77. package/dist/esm/api/identity/index.js.map +1 -1
  78. package/dist/esm/api/identity/principal-type.enum.d.ts +19 -0
  79. package/dist/esm/api/identity/principal-type.enum.d.ts.map +1 -0
  80. package/dist/esm/api/identity/principal-type.enum.js +20 -0
  81. package/dist/esm/api/identity/principal-type.enum.js.map +1 -0
  82. package/dist/esm/enum/user-permission.enum.d.ts +40 -1
  83. package/dist/esm/enum/user-permission.enum.d.ts.map +1 -1
  84. package/dist/esm/enum/user-permission.enum.js +42 -0
  85. package/dist/esm/enum/user-permission.enum.js.map +1 -1
  86. package/package.json +1 -1
@@ -0,0 +1,143 @@
1
+ import type { CursorPage } from '../../type/cursor-page.type.js';
2
+ import type { IsoDateTime } from '../../type/iso-date-time.type.js';
3
+ import type { Nullable } from '../../type/nil.type.js';
4
+ import type { UUID } from '../../type/uuid.type.js';
5
+ import type { DispatchStatus } from './dispatch-status.enum.js';
6
+ /**
7
+ * One outbound request Conduit has accepted responsibility for.
8
+ *
9
+ * The inbound pipeline reversed: a vertical POSTs here, Conduit persists and answers `202`, and
10
+ * the provider is called afterwards with retries and a dead-letter queue. The caller is released
11
+ * from the third party's availability entirely — which is the point, because a CRM that awaits
12
+ * the Graph API inline is a CRM that is down whenever Meta is.
13
+ *
14
+ * **The payload is stored as sent.** Conduit does not reshape it into a provider's format; §14
15
+ * rules out transforms beyond header templating, and a gateway that rewrites bodies is a gateway
16
+ * that has opinions about domains it must not know exist.
17
+ */
18
+ export interface Dispatch {
19
+ id: UUID;
20
+ /** The connection this went out through. A loose reference — it may since have been deleted. */
21
+ connectionId: UUID;
22
+ /** Snapshotted, so the record still reads correctly after the connection is renamed. */
23
+ connectionKey: string;
24
+ connectorKey: string;
25
+ /** The operation named at submit time. */
26
+ operation: string;
27
+ /**
28
+ * Resolved when the dispatch was accepted, not read from the manifest now.
29
+ *
30
+ * Same rule as a delivery's target: editing an operation's path must not retroactively
31
+ * change where Conduit says it sent something.
32
+ */
33
+ targetUrl: string;
34
+ method: string;
35
+ /**
36
+ * The caller's own key, echoed back.
37
+ *
38
+ * Submitting twice with the same key returns the **first** dispatch rather than creating a
39
+ * second — which is what makes a vertical's own retry safe. Null when the caller supplied
40
+ * none, in which case a resubmit is a second send and that is the caller's choice.
41
+ */
42
+ idempotencyKey: Nullable<string>;
43
+ status: DispatchStatus;
44
+ attemptCount: number;
45
+ /** Snapshotted from the connector's retry policy when accepted. */
46
+ maxAttempts: number;
47
+ nextAttemptAt: IsoDateTime;
48
+ lastAttemptAt: Nullable<IsoDateTime>;
49
+ /** Null when no response arrived. See `lastError`. */
50
+ lastResponseStatus: Nullable<number>;
51
+ lastResponseBodyPreview: Nullable<string>;
52
+ lastError: Nullable<string>;
53
+ /** Set when an operator redrove this. */
54
+ redrivenByUserId: Nullable<UUID>;
55
+ completedAt: Nullable<IsoDateTime>;
56
+ createdAt: IsoDateTime;
57
+ }
58
+ /**
59
+ * One attempt at one dispatch.
60
+ *
61
+ * `wasRateLimited` is the field that stops an operator misreading the history. A dispatch held
62
+ * back by the connector's own limit did not fail, cost no attempt, and needs nothing done about
63
+ * it — but without a record it looks like a gap in the timeline, and the obvious conclusion is
64
+ * that the queue stalled.
65
+ */
66
+ export interface DispatchAttempt {
67
+ id: UUID;
68
+ /** 1-based. Equal for two rows only when one of them was a rate-limit deferral. */
69
+ attemptNumber: number;
70
+ /** Null when no response arrived at all. */
71
+ responseStatus: Nullable<number>;
72
+ responseBodyPreview: Nullable<string>;
73
+ errorMessage: Nullable<string>;
74
+ durationMs: number;
75
+ isSuccess: boolean;
76
+ /** Recorded but not charged against the attempt budget. */
77
+ wasRateLimited: boolean;
78
+ /** Whether the access token was refreshed and the request re-sent within this attempt. */
79
+ didRefreshCredentials: boolean;
80
+ createdAt: IsoDateTime;
81
+ }
82
+ /** `GET /api/v1/dispatches/:id/attempts`. Oldest first — an attempt history reads as a story. */
83
+ export interface DispatchAttemptsList {
84
+ items: DispatchAttempt[];
85
+ }
86
+ /** `GET /api/v1/dispatches`. Cursor-paginated: the collection is appended to while it is read. */
87
+ export type DispatchesPage = CursorPage<Dispatch>;
88
+ /** Query for `GET /api/v1/dispatches`. */
89
+ export interface GetDispatchesQuery {
90
+ limit?: number;
91
+ /** Opaque cursor from the previous page's `nextCursor`. Never parse it. */
92
+ after?: Nullable<string>;
93
+ /** `dead-lettered` is the DLQ view. The DLQ is a filter, not a separate resource. */
94
+ status?: Nullable<DispatchStatus>;
95
+ connectionId?: Nullable<UUID>;
96
+ operation?: Nullable<string>;
97
+ }
98
+ /**
99
+ * `POST /api/v1/dispatches` — the request a vertical makes to send something.
100
+ *
101
+ * Note what is **not** here: no URL, no host, no arbitrary headers. The caller picks a connection
102
+ * and an operation, both of which someone configured deliberately, and Conduit derives the
103
+ * target. Accepting a URL would make this an authenticated open proxy sitting inside our network.
104
+ */
105
+ export interface SubmitDispatchBody {
106
+ /** Which connection to send through, by its tenant-scoped key. */
107
+ connectionKey: string;
108
+ /** Which of the connector's operations to invoke, by key. */
109
+ operation: string;
110
+ /** The request body, sent to the provider as-is. */
111
+ payload: Record<string, unknown>;
112
+ /**
113
+ * Values for `{placeholders}` in the operation's path that the connection does not supply.
114
+ *
115
+ * Percent-encoded into the path, so a value cannot introduce a path segment or a query
116
+ * string and steer the request at a different endpoint of the same host.
117
+ */
118
+ pathParams?: Nullable<Record<string, string>>;
119
+ /** Appended to the resolved URL. Values are encoded. */
120
+ query?: Nullable<Record<string, string>>;
121
+ /**
122
+ * The caller's idempotency key, scoped to the tenant.
123
+ *
124
+ * **Strongly recommended.** Without one, a vertical that times out submitting and retries
125
+ * sends the customer two messages. With one, the second submit returns the first dispatch.
126
+ */
127
+ idempotencyKey?: Nullable<string>;
128
+ }
129
+ /**
130
+ * `202 Accepted` from `POST /api/v1/dispatches`.
131
+ *
132
+ * Deliberately not the full {@link Dispatch}: at this moment the only true facts are that it was
133
+ * accepted and where to look next. Returning a status the caller might treat as an outcome
134
+ * invites exactly the synchronous coupling this endpoint exists to remove.
135
+ */
136
+ export interface SubmitDispatchResponse {
137
+ id: UUID;
138
+ status: DispatchStatus;
139
+ /** True when this submit matched an existing idempotency key and created nothing. */
140
+ isDuplicate: boolean;
141
+ createdAt: IsoDateTime;
142
+ }
143
+ //# sourceMappingURL=dispatch.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.type.d.ts","sourceRoot":"","sources":["../../../../src/api/conduit/dispatch.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEh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vB,qFAAqF;IACrF,WAAW,EAAE,OAAO,CAAC;IAErB,SAAS,EAAE,WAAW,CAAC;CAC1B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=dispatch.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.type.js","sourceRoot":"","sources":["../../../../src/api/conduit/dispatch.type.ts"],"names":[],"mappings":""}
@@ -1,7 +1,12 @@
1
1
  export * from './capture.type.js';
2
+ export * from './connection.type.js';
3
+ export * from './connector-auth-type.enum.js';
4
+ export * from './connector.type.js';
2
5
  export * from './delivery-status.enum.js';
3
6
  export * from './delivery.type.js';
4
7
  export * from './destination.type.js';
8
+ export * from './dispatch-status.enum.js';
9
+ export * from './dispatch.type.js';
5
10
  export * from './endpoint.type.js';
6
11
  export * from './handshake-kind.enum.js';
7
12
  export * from './match-operator.enum.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/conduit/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/conduit/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC"}
@@ -15,9 +15,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./capture.type.js"), exports);
18
+ __exportStar(require("./connection.type.js"), exports);
19
+ __exportStar(require("./connector-auth-type.enum.js"), exports);
20
+ __exportStar(require("./connector.type.js"), exports);
18
21
  __exportStar(require("./delivery-status.enum.js"), exports);
19
22
  __exportStar(require("./delivery.type.js"), exports);
20
23
  __exportStar(require("./destination.type.js"), exports);
24
+ __exportStar(require("./dispatch-status.enum.js"), exports);
25
+ __exportStar(require("./dispatch.type.js"), exports);
21
26
  __exportStar(require("./endpoint.type.js"), exports);
22
27
  __exportStar(require("./handshake-kind.enum.js"), exports);
23
28
  __exportStar(require("./match-operator.enum.js"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/conduit/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,4DAA0C;AAC1C,qDAAmC;AACnC,wDAAsC;AACtC,qDAAmC;AACnC,2DAAyC;AACzC,2DAAyC;AACzC,qDAAmC;AACnC,mDAAiC;AACjC,kDAAgC;AAChC,gEAA8C;AAC9C,+DAA6C;AAC7C,oEAAkD;AAClD,8DAA4C;AAC5C,sDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/conduit/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,uDAAqC;AACrC,gEAA8C;AAC9C,sDAAoC;AACpC,4DAA0C;AAC1C,qDAAmC;AACnC,wDAAsC;AACtC,4DAA0C;AAC1C,qDAAmC;AACnC,qDAAmC;AACnC,2DAAyC;AACzC,2DAAyC;AACzC,qDAAmC;AACnC,mDAAiC;AACjC,kDAAgC;AAChC,gEAA8C;AAC9C,+DAA6C;AAC7C,oEAAkD;AAClD,8DAA4C;AAC5C,sDAAoC"}
@@ -0,0 +1,53 @@
1
+ import type { UserPermission } from '../../enum/user-permission.enum.js';
2
+ import type { UUID } from '../../type/uuid.type.js';
3
+ import type { PrincipalType } from './principal-type.enum.js';
4
+ /**
5
+ * Claims carried by an access token.
6
+ *
7
+ * **`iveri-identity-api` issues these; every other service only verifies them.** The shape is
8
+ * therefore a contract owned by identity, and it lives here rather than in either repo because
9
+ * both sides have to agree byte for byte — a service whose idea of these claims has drifted
10
+ * does not fail loudly, it rejects every request or, worse, reads the wrong field and keeps
11
+ * going. `conduit-api` carried a hand-copied duplicate of this interface until the `pt` claim
12
+ * had to be added to both at once, which is exactly the drift the copy invited.
13
+ *
14
+ * Names are short and non-obvious (`tid`, `perms`) because this is JWT convention and because
15
+ * the token travels on every request — the registered claims are three characters for the same
16
+ * reason.
17
+ *
18
+ * **Permissions are embedded rather than resolved per request.** That is the whole point of a
19
+ * JWT here: any Iveri service verifies a token with the shared secret and never calls identity
20
+ * on the hot path. The cost is staleness — revoking a role does not invalidate access tokens
21
+ * already issued, so a removed permission survives up to identity's `JWT_ACCESS_TOKEN_TTL`
22
+ * (15 minutes by default), or `JWT_SERVICE_TOKEN_TTL` for a service token. Anything needing
23
+ * immediate revocation must check state at the point of use, not rely on the token.
24
+ */
25
+ export interface AccessTokenPayload {
26
+ /**
27
+ * Subject — **the principal**, which is a user id or an API key id depending on {@link pt}.
28
+ *
29
+ * Read it together with `pt` or not at all. Treating it as a user id unconditionally is the
30
+ * one mistake this shape is arranged to prevent.
31
+ */
32
+ sub: UUID;
33
+ /**
34
+ * Which kind of principal `sub` names.
35
+ *
36
+ * Required, so adding the service-token path could not silently leave a consumer reading a
37
+ * machine's `sub` as a person's id.
38
+ */
39
+ pt: PrincipalType;
40
+ /** Tenant the token is scoped to. Becomes `RequestContext.tenantId`; never trusted from a header. */
41
+ tid: UUID;
42
+ /** Permissions resolved from the principal's roles — or from the API key's grant — at issue time. */
43
+ perms: UserPermission[];
44
+ /** Issued-at, seconds since epoch. Set by the signer. */
45
+ iat?: number;
46
+ /** Expiry, seconds since epoch. Set by the signer. */
47
+ exp?: number;
48
+ /** Issuer, verified on every decode so a token from another Iveri environment is rejected. */
49
+ iss?: string;
50
+ /** Audience, verified alongside `iss`. */
51
+ aud?: string;
52
+ }
53
+ //# sourceMappingURL=access-token-payload.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-token-payload.interface.d.ts","sourceRoot":"","sources":["../../../../src/api/identity/access-token-payload.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;;OAKG;IACH,GAAG,EAAE,IAAI,CAAC;IAEV;;;;;OAKG;IACH,EAAE,EAAE,aAAa,CAAC;IAElB,qGAAqG;IACrG,GAAG,EAAE,IAAI,CAAC;IAEV,qGAAqG;IACrG,KAAK,EAAE,cAAc,EAAE,CAAC;IAExB,yDAAyD;IACzD,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,sDAAsD;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,8FAA8F;IAC9F,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,0CAA0C;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=access-token-payload.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-token-payload.interface.js","sourceRoot":"","sources":["../../../../src/api/identity/access-token-payload.interface.ts"],"names":[],"mappings":""}
@@ -51,6 +51,27 @@ export interface AuthTokens {
51
51
  /** Lifetime of `accessToken` in seconds, not of `refreshToken`. */
52
52
  expiresInSeconds: number;
53
53
  }
54
+ /**
55
+ * Returned by `POST /auth/token` — the API-key-for-JWT exchange a service makes so that other
56
+ * Iveri services can authorize it **without calling identity**.
57
+ *
58
+ * **There is deliberately no refresh token.** The API key already is the long-lived credential,
59
+ * and it is revocable by a row. A refresh token here would be a second long-lived credential
60
+ * with its own independent lifetime, rotation rule and leak story, obtained from the first —
61
+ * so revoking the key would no longer be enough to stop the caller. A service re-exchanges
62
+ * instead, which costs one call per {@link expiresInSeconds}.
63
+ *
64
+ * The key travels as `x-api-key`, so this call has no request body.
65
+ */
66
+ export interface ServiceToken {
67
+ /** Send as `Authorization: Bearer <accessToken>`. Carries `pt: 'service'`. */
68
+ accessToken: string;
69
+ /**
70
+ * Lifetime in seconds. Shorter than a human session's: a service re-exchanges with nobody
71
+ * waiting, so the revocation window is cheap to shrink.
72
+ */
73
+ expiresInSeconds: number;
74
+ }
54
75
  /**
55
76
  * Who the caller is. Returned by `GET /auth/me` and nested inside {@link AuthSession}.
56
77
  *
@@ -1 +1 @@
1
- {"version":3,"file":"auth.type.d.ts","sourceRoot":"","sources":["../../../../src/api/identity/auth.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK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AAM,CAAC;CACxB;AAED,iGAAiG;AACjG,MAAM,WAAW,oBAAoB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,+EAA+E;AAC/E,MAAM,WAAW,UAAU;IACvB,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;;;;OAQG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB,mEAAmE;IACnE,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,YAAY;IACzB,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,SAAS;IACtB,qCAAqC;IACrC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEvB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAE3B,QAAQ,EAAE,IAAI,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAE3B,qCAAqC;IACrC,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAE7C,SAAS,EAAE,MAAM,EAAE,CAAC;IAEpB,gEAAgE;IAChE,WAAW,EAAE,cAAc,EAAE,CAAC;CACjC;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,UAAU,CAAC;CACtB"}
@@ -1,4 +1,6 @@
1
+ export * from './access-token-payload.interface.js';
1
2
  export * from './auth.type.js';
2
3
  export * from './membership-status.enum.js';
4
+ export * from './principal-type.enum.js';
3
5
  export * from './tenant-status.enum.js';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/identity/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/identity/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./access-token-payload.interface.js"), exports);
17
18
  __exportStar(require("./auth.type.js"), exports);
18
19
  __exportStar(require("./membership-status.enum.js"), exports);
20
+ __exportStar(require("./principal-type.enum.js"), exports);
19
21
  __exportStar(require("./tenant-status.enum.js"), exports);
20
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/identity/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,8DAA4C;AAC5C,0DAAwC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/identity/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAoD;AACpD,iDAA+B;AAC/B,8DAA4C;AAC5C,2DAAyC;AACzC,0DAAwC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * What kind of principal an access token was minted for.
3
+ *
4
+ * It exists because `sub` alone cannot answer the question. A JWT's subject is *the principal*,
5
+ * and identity issues tokens for two kinds of them: a person who logged in, and a service that
6
+ * exchanged an API key. Both put a UUID in `sub`, and the two UUIDs mean entirely different
7
+ * things — one names a row in `user`, the other a row in `api_key`.
8
+ *
9
+ * A consumer that reads `sub` as a user id without checking this claim attributes a machine's
10
+ * actions to a user who does not exist. That is why every guard branches on it, and why it is
11
+ * required rather than optional: `tsc` then makes the branch impossible to forget.
12
+ */
13
+ export declare enum PrincipalType {
14
+ /** A person, authenticated by password. `sub` is their `user.id`. */
15
+ USER = "user",
16
+ /** A service, authenticated by API key. `sub` is the `api_key.id`, and there is no user. */
17
+ SERVICE = "service"
18
+ }
19
+ //# sourceMappingURL=principal-type.enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"principal-type.enum.d.ts","sourceRoot":"","sources":["../../../../src/api/identity/principal-type.enum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,oBAAY,aAAa;IACrB,qEAAqE;IACrE,IAAI,SAAS;IAEb,4FAA4F;IAC5F,OAAO,YAAY;CACtB"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrincipalType = void 0;
4
+ /**
5
+ * What kind of principal an access token was minted for.
6
+ *
7
+ * It exists because `sub` alone cannot answer the question. A JWT's subject is *the principal*,
8
+ * and identity issues tokens for two kinds of them: a person who logged in, and a service that
9
+ * exchanged an API key. Both put a UUID in `sub`, and the two UUIDs mean entirely different
10
+ * things — one names a row in `user`, the other a row in `api_key`.
11
+ *
12
+ * A consumer that reads `sub` as a user id without checking this claim attributes a machine's
13
+ * actions to a user who does not exist. That is why every guard branches on it, and why it is
14
+ * required rather than optional: `tsc` then makes the branch impossible to forget.
15
+ */
16
+ var PrincipalType;
17
+ (function (PrincipalType) {
18
+ /** A person, authenticated by password. `sub` is their `user.id`. */
19
+ PrincipalType["USER"] = "user";
20
+ /** A service, authenticated by API key. `sub` is the `api_key.id`, and there is no user. */
21
+ PrincipalType["SERVICE"] = "service";
22
+ })(PrincipalType || (exports.PrincipalType = PrincipalType = {}));
23
+ //# sourceMappingURL=principal-type.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"principal-type.enum.js","sourceRoot":"","sources":["../../../../src/api/identity/principal-type.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACH,IAAY,aAMX;AAND,WAAY,aAAa;IACrB,qEAAqE;IACrE,8BAAa,CAAA;IAEb,4FAA4F;IAC5F,oCAAmB,CAAA;AACvB,CAAC,EANW,aAAa,6BAAb,aAAa,QAMxB"}
@@ -89,7 +89,46 @@ export declare enum UserPermission {
89
89
  * read: it causes an outbound request rather than returning a row, and redriving a large
90
90
  * dead-letter backlog is a way to flood a customer's own service.
91
91
  */
92
- CONDUIT_DELIVERY_OPERATE = "conduit:delivery:operate"
92
+ CONDUIT_DELIVERY_OPERATE = "conduit:delivery:operate",
93
+ /** Read connector manifests. They hold no credential, so this is configuration only. */
94
+ CONDUIT_CONNECTOR_READ = "conduit:connector:read",
95
+ /**
96
+ * Define or amend a connector manifest — **the list of hosts and paths Conduit may be asked
97
+ * to call**, and the token endpoint it will send a customer's client secret to.
98
+ *
99
+ * The most powerful permission in the outbound half. A dispatch cannot name a URL; it can
100
+ * only name an operation somebody with this permission wrote down, which is what keeps
101
+ * outbound from being an authenticated open proxy. Whoever holds this decides where the
102
+ * proxy may point.
103
+ */
104
+ CONDUIT_CONNECTOR_MANAGE = "conduit:connector:manage",
105
+ /** Read connections. Never exposes their stored credential values. */
106
+ CONDUIT_CONNECTION_READ = "conduit:connection:read",
107
+ /**
108
+ * Create, amend or delete a connection — the customer's own third-party credentials.
109
+ *
110
+ * Single manage permission rather than create/update/delete: the dangerous act is holding
111
+ * the credential at all, and the three carry the same risk.
112
+ */
113
+ CONDUIT_CONNECTION_MANAGE = "conduit:connection:manage",
114
+ /**
115
+ * Read the outbound log and its dead-letter queue, including each attempt's response.
116
+ *
117
+ * A dispatch record holds the payload a vertical asked to send — a customer's message text,
118
+ * an order — so this is a data-read permission, not a config one.
119
+ */
120
+ CONDUIT_DISPATCH_READ = "conduit:dispatch:read",
121
+ /**
122
+ * Submit an outbound request. **This is the permission a vertical holds**, and the only one
123
+ * it needs: `unibox-api` sending a reply presents this and nothing else.
124
+ *
125
+ * Separate from `CONDUIT_DISPATCH_OPERATE` because sending is the routine act and operating
126
+ * the queue is the exceptional one — a service principal that can send should not also be
127
+ * able to redrive a backlog.
128
+ */
129
+ CONDUIT_DISPATCH_SEND = "conduit:dispatch:send",
130
+ /** Redrive a dead-lettered dispatch, or cancel one still pending. */
131
+ CONDUIT_DISPATCH_OPERATE = "conduit:dispatch:operate"
93
132
  }
94
133
  /**
95
134
  * Every member, for seeding the owner role and validating custom-role input.
@@ -1 +1 @@
1
- {"version":3,"file":"user-permission.enum.d.ts","sourceRoot":"","sources":["../../../src/enum/user-permission.enum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,oBAAY,cAAc;IAItB,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,sFAAsF;IACtF,aAAa,kBAAkB;IAG/B,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAG3B,eAAe,oBAAoB;IACnC,6EAA6E;IAC7E,iBAAiB,sBAAsB;IACvC;;;OAGG;IACH,sBAAsB,2BAA2B;IAGjD,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAG3B,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IAKjC,qEAAqE;IACrE,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;IACnD,uBAAuB,4BAA4B;IACnD,uBAAuB,4BAA4B;IAGnD;;;;OAIG;IACH,oBAAoB,yBAAyB;IAC7C,sBAAsB,2BAA2B;IAGjD;;;;OAIG;IACH,sBAAsB,2BAA2B;IA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G;IACH,0BAA0B,+BAA+B;IAGzD,kBAAkB,uBAAuB;IACzC,2DAA2D;IAC3D,oBAAoB,yBAAyB;IAG7C;;;;;OAKG;IACH,qBAAqB,0BAA0B;IAC/C;;;;;;OAMG;IACH,wBAAwB,6BAA6B;IAGrD,wFAAwF;IACxF,sBAAsB,2BAA2B;IACjD;;;;;;;;OAQG;IACH,wBAAwB,6BAA6B;IAGrD,sEAAsE;IACtE,uBAAuB,4BAA4B;IACnD;;;;;OAKG;IACH,yBAAyB,8BAA8B;IAGvD;;;;;OAKG;IACH,qBAAqB,0BAA0B;IAC/C;;;;;;;OAOG;IACH,qBAAqB,0BAA0B;IAC/C,qEAAqE;IACrE,wBAAwB,6BAA6B;CACxD;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,cAAc,EAAiD,CAAC"}
@@ -108,6 +108,48 @@ var UserPermission;
108
108
  * dead-letter backlog is a way to flood a customer's own service.
109
109
  */
110
110
  UserPermission["CONDUIT_DELIVERY_OPERATE"] = "conduit:delivery:operate";
111
+ // ── Connector (outbound) ────────────────────────────────────────────────
112
+ /** Read connector manifests. They hold no credential, so this is configuration only. */
113
+ UserPermission["CONDUIT_CONNECTOR_READ"] = "conduit:connector:read";
114
+ /**
115
+ * Define or amend a connector manifest — **the list of hosts and paths Conduit may be asked
116
+ * to call**, and the token endpoint it will send a customer's client secret to.
117
+ *
118
+ * The most powerful permission in the outbound half. A dispatch cannot name a URL; it can
119
+ * only name an operation somebody with this permission wrote down, which is what keeps
120
+ * outbound from being an authenticated open proxy. Whoever holds this decides where the
121
+ * proxy may point.
122
+ */
123
+ UserPermission["CONDUIT_CONNECTOR_MANAGE"] = "conduit:connector:manage";
124
+ // ── Connection (outbound) ───────────────────────────────────────────────
125
+ /** Read connections. Never exposes their stored credential values. */
126
+ UserPermission["CONDUIT_CONNECTION_READ"] = "conduit:connection:read";
127
+ /**
128
+ * Create, amend or delete a connection — the customer's own third-party credentials.
129
+ *
130
+ * Single manage permission rather than create/update/delete: the dangerous act is holding
131
+ * the credential at all, and the three carry the same risk.
132
+ */
133
+ UserPermission["CONDUIT_CONNECTION_MANAGE"] = "conduit:connection:manage";
134
+ // ── Dispatch (outbound) ─────────────────────────────────────────────────
135
+ /**
136
+ * Read the outbound log and its dead-letter queue, including each attempt's response.
137
+ *
138
+ * A dispatch record holds the payload a vertical asked to send — a customer's message text,
139
+ * an order — so this is a data-read permission, not a config one.
140
+ */
141
+ UserPermission["CONDUIT_DISPATCH_READ"] = "conduit:dispatch:read";
142
+ /**
143
+ * Submit an outbound request. **This is the permission a vertical holds**, and the only one
144
+ * it needs: `unibox-api` sending a reply presents this and nothing else.
145
+ *
146
+ * Separate from `CONDUIT_DISPATCH_OPERATE` because sending is the routine act and operating
147
+ * the queue is the exceptional one — a service principal that can send should not also be
148
+ * able to redrive a backlog.
149
+ */
150
+ UserPermission["CONDUIT_DISPATCH_SEND"] = "conduit:dispatch:send";
151
+ /** Redrive a dead-lettered dispatch, or cancel one still pending. */
152
+ UserPermission["CONDUIT_DISPATCH_OPERATE"] = "conduit:dispatch:operate";
111
153
  })(UserPermission || (exports.UserPermission = UserPermission = {}));
112
154
  /**
113
155
  * Every member, for seeding the owner role and validating custom-role input.
@@ -1 +1 @@
1
- {"version":3,"file":"user-permission.enum.js","sourceRoot":"","sources":["../../../src/enum/user-permission.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,IAAY,cAqGX;AArGD,WAAY,cAAc;IACtB,4EAA4E;IAE5E,2EAA2E;IAC3E,6CAA2B,CAAA;IAC3B,iDAA+B,CAAA;IAC/B,sFAAsF;IACtF,iDAA+B,CAAA;IAE/B,2EAA2E;IAC3E,yCAAuB,CAAA;IACvB,6CAA2B,CAAA;IAC3B,6CAA2B,CAAA;IAC3B,6CAA2B,CAAA;IAE3B,2EAA2E;IAC3E,qDAAmC,CAAA;IACnC,6EAA6E;IAC7E,yDAAuC,CAAA;IACvC;;;OAGG;I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qE;IACrE,uEAAqD,CAAA;AACzD,CAAC,EAlJW,cAAc,8BAAd,cAAc,QAkJzB;AAED;;;;;GAKG;AACU,QAAA,oBAAoB,GAA8B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC"}
@@ -0,0 +1,100 @@
1
+ import type { IsoDateTime } from '../../type/iso-date-time.type.js';
2
+ import type { Nullable } from '../../type/nil.type.js';
3
+ import type { UUID } from '../../type/uuid.type.js';
4
+ /**
5
+ * One tenant's configured instance of a connector: the credentials and the account details that
6
+ * turn a manifest into something that can actually send.
7
+ *
8
+ * The split is the reason a manifest can ship in the binary. A connector says "WhatsApp Cloud
9
+ * lives at graph.facebook.com and authenticates with a bearer token"; a connection says "and
10
+ * *this* is our token, for *this* phone number". One is ours and identical for everybody; the
11
+ * other is the customer's and is the single most sensitive thing this service holds.
12
+ *
13
+ * **No endpoint of this API returns a credential value**, in any form — not masked, not
14
+ * truncated, not a length. `credentialNames` answers the only question an operator has, which is
15
+ * whether something is configured. Same control as a destination's headers and an endpoint's
16
+ * signing secret, for the same reason: §11 says one leak ends the company.
17
+ */
18
+ export interface Connection {
19
+ id: UUID;
20
+ /** Stable identifier a dispatch names instead of an id, so callers can be configured by name. */
21
+ key: string;
22
+ name: string;
23
+ description: Nullable<string>;
24
+ /** The manifest this connection instantiates. Built-in or tenant-defined. */
25
+ connectorKey: string;
26
+ /** Sorted. **The values are never returned by any endpoint of this API.** */
27
+ credentialNames: string[];
28
+ /**
29
+ * Non-secret values filling `{placeholders}` in an operation path — a phone number id, an
30
+ * account id, an API version.
31
+ *
32
+ * Deliberately separate from credentials rather than one map with a secrecy flag: a flag is
33
+ * a thing somebody sets wrong once, and the failure mode is a token in a response body.
34
+ * Variables are returned in full because they are the part an operator needs to check.
35
+ */
36
+ variables: Record<string, string>;
37
+ /**
38
+ * When the cached OAuth access token stops being usable, or null when there is none —
39
+ * either because the connector authenticates statically or because nothing has fetched one
40
+ * yet.
41
+ *
42
+ * The expiry is returned, the token is not. It is what makes "why is this connection
43
+ * failing" answerable without exposing anything.
44
+ */
45
+ accessTokenExpiresAt: Nullable<IsoDateTime>;
46
+ /**
47
+ * Why the last authentication attempt failed, or null when the last one worked.
48
+ *
49
+ * A refresh token that a provider has revoked is the most common real failure on this
50
+ * aggregate, and it is invisible otherwise: dispatches simply dead-letter with a 401 and
51
+ * nothing points at the connection.
52
+ */
53
+ lastAuthError: Nullable<string>;
54
+ /** Stops *new* dispatches being accepted. Does not cancel ones already queued. */
55
+ isActive: boolean;
56
+ createdAt: IsoDateTime;
57
+ updatedAt: IsoDateTime;
58
+ }
59
+ /** `GET /api/v1/connections`. Offset-paginated — a small, slow-moving collection. */
60
+ export interface ConnectionsPage {
61
+ items: Connection[];
62
+ total: number;
63
+ limit: number;
64
+ offset: number;
65
+ }
66
+ /** `POST /api/v1/connections`. */
67
+ export interface CreateConnectionBody {
68
+ key: string;
69
+ name: string;
70
+ description?: Nullable<string>;
71
+ connectorKey: string;
72
+ /**
73
+ * Secrets this connection authenticates with. **Stored encrypted and never returned.**
74
+ *
75
+ * Which names are expected depends on the connector's auth type: an `API_KEY_HEADER`
76
+ * manifest names its own, an OAuth one wants `clientId`/`clientSecret` and, for the refresh
77
+ * grant, `refreshToken`.
78
+ */
79
+ credentials: Record<string, string>;
80
+ variables?: Nullable<Record<string, string>>;
81
+ }
82
+ /**
83
+ * `PATCH /api/v1/connections/:id`.
84
+ *
85
+ * **`credentials` has three states, not two.** Omitting it leaves the stored map untouched,
86
+ * `null` clears it, an object replaces it wholesale. A form that sends `{}` meaning "unchanged"
87
+ * deletes the customer's token, and the symptom is every dispatch dead-lettering on a 401.
88
+ *
89
+ * Replacing credentials also discards the cached access token: a token minted from the old
90
+ * client secret is not evidence that the new one works, and keeping it would hide a typo until
91
+ * the token happened to expire.
92
+ */
93
+ export interface UpdateConnectionBody {
94
+ name?: string;
95
+ description?: Nullable<string>;
96
+ credentials?: Nullable<Record<string, string>>;
97
+ variables?: Nullable<Record<string, string>>;
98
+ isActive?: boolean;
99
+ }
100
+ //# sourceMappingURL=connection.type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.type.d.ts","sourceRoot":"","sources":["../../../../src/api/conduit/connection.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,UAAU;IACvB,EAAE,EAAE,IAAI,CAAC;IAET,iGAAiG;IACjG,GAAG,EAAE,MAAM,CAAC;IAEZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAE9B,6EAA6E;IAC7E,YAAY,EAAE,MAAM,CAAC;IAErB,6EAA6E;IAC7E,eAAe,EAAE,MAAM,EAAE,CAAC;IAE1B;;;;;;;OAOG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;;;;;;OAOG;IACH,oBAAoB,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAE5C;;;;;;OAMG;IACH,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEhC,kFAAkF;IAClF,QAAQ,EAAE,OAAO,CAAC;IAElB,SAAS,EAAE,WAAW,CAAC;IACvB,SAAS,EAAE,WAAW,CAAC;CAC1B;AAED,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,kCAAkC;AAClC,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=connection.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.type.js","sourceRoot":"","sources":["../../../../src/api/conduit/connection.type.ts"],"names":[],"mappings":""}