@cosmoops/connect-sdk 0.9.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +566 -0
- package/README.md +113 -42
- package/dist/cjs/cli/doctor.js +3 -3
- package/dist/cjs/cli/init.js +3 -3
- package/dist/cjs/client/components/access-gate.js +20 -1
- package/dist/cjs/client/components/ai-screens.js +73 -0
- package/dist/cjs/client/components/ai-widgets.js +37 -0
- package/dist/cjs/client/components/app-shell.js +75 -41
- package/dist/cjs/client/components/apps-grid.js +3 -2
- package/dist/cjs/client/components/ask-ai.js +50 -5
- package/dist/cjs/client/components/confirm-dialog.js +40 -0
- package/dist/cjs/client/components/cursor-pagination.js +22 -0
- package/dist/cjs/client/components/filter-tabs.js +24 -0
- package/dist/cjs/client/components/grievance-notice.js +30 -0
- package/dist/cjs/client/components/link-button.js +17 -10
- package/dist/cjs/client/components/logo.js +4 -3
- package/dist/cjs/client/components/nav.js +41 -0
- package/dist/cjs/client/components/plan-pricing.js +27 -0
- package/dist/cjs/client/components/plans.js +1 -1
- package/dist/cjs/client/components/platform-gate.js +48 -0
- package/dist/cjs/client/components/shell-context.js +149 -0
- package/dist/cjs/client/components/side-nav.js +49 -23
- package/dist/cjs/client/components/sidebar.js +127 -0
- package/dist/cjs/client/components/subscribe-dialog.js +2 -2
- package/dist/cjs/client/components/subscription.js +1 -1
- package/dist/cjs/client/components/user-menu.js +96 -37
- package/dist/cjs/client/components/workspace-switcher.js +100 -0
- package/dist/cjs/client/index.js +72 -2
- package/dist/cjs/client/provider.js +57 -2
- package/dist/cjs/client/use-checkout.js +9 -5
- package/dist/cjs/errors.js +1 -1
- package/dist/cjs/index.js +16 -1
- package/dist/cjs/mcp/index.js +90 -0
- package/dist/cjs/mcp/tools.js +369 -0
- package/dist/cjs/next/index.js +2 -2
- package/dist/cjs/server/client.js +25 -2
- package/dist/cjs/server/handler.js +203 -18
- package/dist/cjs/server/http.js +6 -2
- package/dist/cjs/server/resources/acting-as.js +16 -0
- package/dist/cjs/server/resources/ai.js +22 -2
- package/dist/cjs/server/resources/data.js +374 -0
- package/dist/cjs/server/resources/identity.js +7 -3
- package/dist/cjs/server/resources/kv.js +84 -0
- package/dist/cjs/server/resources/platform.js +43 -0
- package/dist/cjs/server/resources/sessions.js +1 -1
- package/dist/cjs/server/resources/workspaces.js +74 -0
- package/dist/cjs/store-schema.js +66 -0
- package/dist/cjs/store.js +152 -0
- package/dist/cjs/ui/empty-state.js +28 -0
- package/dist/cjs/ui/index.js +44 -0
- package/dist/cjs/ui/page-header.js +27 -0
- package/dist/cjs/ui/page-shell.js +44 -0
- package/dist/cjs/ui/section.js +20 -0
- package/dist/cjs/ui/setting-row.js +14 -0
- package/dist/cjs/ui/status-chip.js +17 -0
- package/dist/esm/cli/doctor.js +3 -3
- package/dist/esm/cli/init.js +3 -3
- package/dist/esm/client/components/access-gate.js +20 -1
- package/dist/esm/client/components/ai-screens.js +69 -0
- package/dist/esm/client/components/ai-widgets.js +37 -1
- package/dist/esm/client/components/app-shell.js +81 -47
- package/dist/esm/client/components/apps-grid.js +3 -2
- package/dist/esm/client/components/ask-ai.js +51 -6
- package/dist/esm/client/components/confirm-dialog.js +37 -0
- package/dist/esm/client/components/cursor-pagination.js +19 -0
- package/dist/esm/client/components/filter-tabs.js +21 -0
- package/dist/esm/client/components/grievance-notice.js +27 -0
- package/dist/esm/client/components/link-button.js +17 -10
- package/dist/esm/client/components/logo.js +4 -3
- package/dist/esm/client/components/nav.js +40 -0
- package/dist/esm/client/components/plan-pricing.js +25 -0
- package/dist/esm/client/components/plans.js +2 -2
- package/dist/esm/client/components/platform-gate.js +45 -0
- package/dist/esm/client/components/shell-context.js +141 -0
- package/dist/esm/client/components/side-nav.js +48 -21
- package/dist/esm/client/components/sidebar.js +120 -0
- package/dist/esm/client/components/subscribe-dialog.js +3 -3
- package/dist/esm/client/components/subscription.js +2 -2
- package/dist/esm/client/components/user-menu.js +95 -38
- package/dist/esm/client/components/workspace-switcher.js +97 -0
- package/dist/esm/client/index.js +47 -4
- package/dist/esm/client/provider.js +53 -2
- package/dist/esm/client/use-checkout.js +9 -5
- package/dist/esm/errors.js +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/mcp/index.js +85 -0
- package/dist/esm/mcp/tools.js +366 -0
- package/dist/esm/next/index.js +2 -2
- package/dist/esm/server/client.js +25 -2
- package/dist/esm/server/handler.js +203 -18
- package/dist/esm/server/http.js +6 -2
- package/dist/esm/server/resources/acting-as.js +13 -0
- package/dist/esm/server/resources/ai.js +22 -2
- package/dist/esm/server/resources/data.js +369 -0
- package/dist/esm/server/resources/identity.js +7 -3
- package/dist/esm/server/resources/kv.js +80 -0
- package/dist/esm/server/resources/platform.js +39 -0
- package/dist/esm/server/resources/sessions.js +1 -1
- package/dist/esm/server/resources/workspaces.js +70 -0
- package/dist/esm/store-schema.js +62 -0
- package/dist/esm/store.js +141 -0
- package/dist/esm/ui/empty-state.js +25 -0
- package/dist/esm/ui/index.js +34 -0
- package/dist/esm/ui/page-header.js +24 -0
- package/dist/esm/ui/page-shell.js +41 -0
- package/dist/esm/ui/section.js +17 -0
- package/dist/esm/ui/setting-row.js +11 -0
- package/dist/esm/ui/status-chip.js +14 -0
- package/dist/types/client/components/ai-screens.d.ts +25 -0
- package/dist/types/client/components/ai-widgets.d.ts +34 -1
- package/dist/types/client/components/app-shell.d.ts +65 -27
- package/dist/types/client/components/apps-grid.d.ts +11 -2
- package/dist/types/client/components/ask-ai.d.ts +47 -1
- package/dist/types/client/components/confirm-dialog.d.ts +34 -0
- package/dist/types/client/components/cursor-pagination.d.ts +27 -0
- package/dist/types/client/components/filter-tabs.d.ts +26 -0
- package/dist/types/client/components/grievance-notice.d.ts +31 -0
- package/dist/types/client/components/link-button.d.ts +32 -9
- package/dist/types/client/components/logo.d.ts +18 -2
- package/dist/types/client/components/nav.d.ts +24 -0
- package/dist/types/client/components/plan-pricing.d.ts +10 -0
- package/dist/types/client/components/platform-gate.d.ts +53 -0
- package/dist/types/client/components/shell-context.d.ts +116 -0
- package/dist/types/client/components/side-nav.d.ts +27 -13
- package/dist/types/client/components/sidebar.d.ts +95 -0
- package/dist/types/client/components/user-menu.d.ts +68 -22
- package/dist/types/client/components/workspace-switcher.d.ts +49 -0
- package/dist/types/client/index.d.ts +29 -5
- package/dist/types/client/provider.d.ts +109 -6
- package/dist/types/client/use-checkout.d.ts +8 -4
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/mcp/index.d.ts +74 -0
- package/dist/types/mcp/tools.d.ts +107 -0
- package/dist/types/next/index.d.ts +1 -1
- package/dist/types/server/client.d.ts +25 -2
- package/dist/types/server/http.d.ts +8 -2
- package/dist/types/server/index.d.ts +4 -0
- package/dist/types/server/resources/acting-as.d.ts +11 -0
- package/dist/types/server/resources/ai.d.ts +20 -2
- package/dist/types/server/resources/data.d.ts +258 -0
- package/dist/types/server/resources/kv.d.ts +63 -0
- package/dist/types/server/resources/platform.d.ts +32 -0
- package/dist/types/server/resources/workspaces.d.ts +55 -0
- package/dist/types/store-schema.d.ts +52 -0
- package/dist/types/store.d.ts +96 -0
- package/dist/types/types.d.ts +369 -16
- package/dist/types/ui/empty-state.d.ts +34 -0
- package/dist/types/ui/index.d.ts +40 -0
- package/dist/types/ui/page-header.d.ts +34 -0
- package/dist/types/ui/page-shell.d.ts +39 -0
- package/dist/types/ui/section.d.ts +26 -0
- package/dist/types/ui/setting-row.d.ts +18 -0
- package/dist/types/ui/status-chip.d.ts +36 -0
- package/package.json +15 -2
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { StoreDocument, StoreFieldTransform, StoreOrderBy, StorePrecondition, StoreQueryFilter } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Building blocks for `data.commit` - the transform sentinels, and the two
|
|
4
|
+
* ways to say "only if nothing has moved".
|
|
5
|
+
*
|
|
6
|
+
* Isomorphic and dependency-free, so a Server Component and a client component
|
|
7
|
+
* building the same write use the same constructors. They are functions rather
|
|
8
|
+
* than object literals you write by hand because the sentinel shape is an
|
|
9
|
+
* encoding, not an API: `{ __transform: "increment", by: 1 }` is what goes over
|
|
10
|
+
* the wire, and nothing outside this file should have to know that.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Add to a number, atomically.
|
|
14
|
+
*
|
|
15
|
+
* **The one operation you genuinely cannot do yourself.** Increments are
|
|
16
|
+
* commutative, so two concurrent `increment(500)` calls both land - where
|
|
17
|
+
* read-add-write from your own process loses one of them however carefully it
|
|
18
|
+
* retries, because the read and the write are two round trips with a gap in
|
|
19
|
+
* between. Use this for balances, counters and tallies, and reach for a
|
|
20
|
+
* precondition only when the new value depends on the old one in a way
|
|
21
|
+
* addition cannot express.
|
|
22
|
+
*
|
|
23
|
+
* Negative to subtract; there is no separate `decrement`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function increment(by: number): StoreFieldTransform;
|
|
26
|
+
/** Connect's own write time, rather than a clock reading from your process. */
|
|
27
|
+
export declare function serverTimestamp(): StoreFieldTransform;
|
|
28
|
+
/** Adds the values not already in the array. Order is not preserved. */
|
|
29
|
+
export declare function arrayUnion(...values: unknown[]): StoreFieldTransform;
|
|
30
|
+
/** Removes every occurrence of each value. */
|
|
31
|
+
export declare function arrayRemove(...values: unknown[]): StoreFieldTransform;
|
|
32
|
+
/**
|
|
33
|
+
* Removes the field entirely.
|
|
34
|
+
*
|
|
35
|
+
* `merge` only - a `replace` already drops every field it does not list, so
|
|
36
|
+
* asking it to delete one is a contradiction rather than a narrowing.
|
|
37
|
+
*/
|
|
38
|
+
export declare function deleteField(): StoreFieldTransform;
|
|
39
|
+
/**
|
|
40
|
+
* "Only if this document has not changed since I read it."
|
|
41
|
+
*
|
|
42
|
+
* Pass the document a read returned, and the precondition is built from its
|
|
43
|
+
* `_updateTime`. Taking the document rather than the timestamp is deliberate:
|
|
44
|
+
* a caller who has to reach for `doc.data._updateTime` themselves is one typo
|
|
45
|
+
* away from a precondition that silently does nothing.
|
|
46
|
+
*
|
|
47
|
+
* Throws rather than degrading when the document carries no `_updateTime` -
|
|
48
|
+
* that only happens for a document you built yourself rather than read, and a
|
|
49
|
+
* precondition that quietly became "no precondition" is worse than a crash at
|
|
50
|
+
* the call site.
|
|
51
|
+
*/
|
|
52
|
+
export declare function unchangedSince(document: StoreDocument): StorePrecondition;
|
|
53
|
+
/** "Only if this document exists" / "only if it does not." */
|
|
54
|
+
export declare function documentExists(exists?: boolean): StorePrecondition;
|
|
55
|
+
/** How one field sits in a composite index. `array-contains` is a position, not an order. */
|
|
56
|
+
export type StoreIndexDirection = "asc" | "desc" | "array-contains";
|
|
57
|
+
export interface StoreIndexField {
|
|
58
|
+
field: string;
|
|
59
|
+
direction: StoreIndexDirection;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The composite index a query shape needs, or `null` when Firestore's
|
|
63
|
+
* automatic single-field indexes already serve it.
|
|
64
|
+
*
|
|
65
|
+
* Use it to generate your Store tab declarations from the queries your code
|
|
66
|
+
* actually makes, rather than transcribing them by hand and discovering the
|
|
67
|
+
* gap in production:
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* const needed = MY_QUERY_SHAPES.map(storeIndexFor).filter(Boolean);
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* **Field order is Firestore's, not yours.** Equality fields first (sorted, so
|
|
74
|
+
* the order you passed them in cannot produce two different declarations for
|
|
75
|
+
* one query), then the `array-contains` field, then the field the query orders
|
|
76
|
+
* by. Declaring the same shape twice in two orders builds two indexes, one of
|
|
77
|
+
* which is dead weight on every document write.
|
|
78
|
+
*
|
|
79
|
+
* Connect runs the same derivation server-side and is the authority: a query
|
|
80
|
+
* with no matching declared index is refused with the index it needs spelled
|
|
81
|
+
* out, so a disagreement here surfaces on the first call rather than silently.
|
|
82
|
+
*
|
|
83
|
+
* Throws for a query Firestore cannot serve at all - two `array-contains`
|
|
84
|
+
* filters, ranges over two fields, or a range ordered by a different field.
|
|
85
|
+
*/
|
|
86
|
+
export declare function storeIndexFor(query: {
|
|
87
|
+
filters?: readonly StoreQueryFilter[];
|
|
88
|
+
orderBy?: StoreOrderBy | null;
|
|
89
|
+
}): StoreIndexField[] | null;
|
|
90
|
+
/**
|
|
91
|
+
* An index as one comparable string - `"status:asc,createdAt:desc"`.
|
|
92
|
+
*
|
|
93
|
+
* Deduplicate a generated list on this before declaring it: a dozen query
|
|
94
|
+
* shapes across a screen usually collapse to two or three distinct indexes.
|
|
95
|
+
*/
|
|
96
|
+
export declare function storeIndexSignature(fields: readonly StoreIndexField[]): string;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -25,8 +25,21 @@ export interface ConnectUser {
|
|
|
25
25
|
* failing outright - so pair the two rather than branching on `null`.
|
|
26
26
|
*/
|
|
27
27
|
photoUrl: string | null;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The workspace this session is scoped to - the tenant to key your own data
|
|
30
|
+
* on. **`null` only for a Connect platform staff session**, where `staff`
|
|
31
|
+
* is `true`; see `SessionAccess`.
|
|
32
|
+
*
|
|
33
|
+
* Nullable since 0.11.0, and the breaking change in that release. If you do
|
|
34
|
+
* not turn staff access on for your application (it is off by default and
|
|
35
|
+
* per-application), this is never `null` and the only work is a type
|
|
36
|
+
* narrow. If you do, decide first what your tenanting does with a session
|
|
37
|
+
* that has no tenant - typically: serve your operator console off `staff`,
|
|
38
|
+
* and nothing else.
|
|
39
|
+
*/
|
|
40
|
+
workspaceId: string | null;
|
|
41
|
+
/** `null` on a staff session, for the same reason as `workspaceId`. */
|
|
42
|
+
workspaceName: string | null;
|
|
30
43
|
/**
|
|
31
44
|
* Whether this is a one-seat personal account or a team.
|
|
32
45
|
*
|
|
@@ -40,8 +53,10 @@ export interface ConnectUser {
|
|
|
40
53
|
* Re-read it from `identity.getUser()`; do not cache it past the sign-in.
|
|
41
54
|
* An `"individual"` workspace can convert to `"business"` under a live
|
|
42
55
|
* session (the reverse never happens).
|
|
56
|
+
*
|
|
57
|
+
* `null` on a staff session - there is no workspace to have a type.
|
|
43
58
|
*/
|
|
44
|
-
workspaceType: WorkspaceType;
|
|
59
|
+
workspaceType: WorkspaceType | null;
|
|
45
60
|
}
|
|
46
61
|
export type WorkspaceType = "individual" | "business";
|
|
47
62
|
export type ApplicationAudience = "b2b" | "b2c" | "both";
|
|
@@ -86,15 +101,61 @@ export interface SessionSubscription {
|
|
|
86
101
|
isTrialing: boolean;
|
|
87
102
|
}
|
|
88
103
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
104
|
+
* Who the signed-in account is to you, in three flat fields.
|
|
105
|
+
*
|
|
106
|
+
* Replaces the `applicationRole` (`{role, granted}`) and `platformAccess`
|
|
107
|
+
* (`{roles}`) blocks, which were mutually exclusive by construction: a
|
|
108
|
+
* Connect platform account belongs to no workspace, so one of the two was
|
|
109
|
+
* always the empty answer and every integration wrote the same null-check
|
|
110
|
+
* twice.
|
|
111
|
+
*
|
|
112
|
+
* Read `staff` first - it decides what the other two mean.
|
|
113
|
+
*
|
|
114
|
+
* **`staff` is not a client-side security boundary.** `<ConnectPlatformGate>`
|
|
115
|
+
* and the hooks around it decide what to *render*; the browser can ignore all
|
|
116
|
+
* of it. Re-check it server-side with `client.identity.getUser(sessionToken)`
|
|
117
|
+
* before serving anything an operator console exposes.
|
|
92
118
|
*/
|
|
93
|
-
export interface
|
|
119
|
+
export interface SessionAccess {
|
|
120
|
+
/**
|
|
121
|
+
* The one role this session holds, or `null`.
|
|
122
|
+
*
|
|
123
|
+
* For a member (`staff: false`): the role matched on *your* application,
|
|
124
|
+
* resolved for your `client_id` rather than their workspace-wide roles -
|
|
125
|
+
* `null` when their permissions match no single role you defined, including
|
|
126
|
+
* when they have no access to your application at all.
|
|
127
|
+
*
|
|
128
|
+
* For staff (`staff: true`): the highest-authority Connect platform role
|
|
129
|
+
* **your application accepts** - never Connect's full role list for that
|
|
130
|
+
* person. An application accepting only `developer` is told `"developer"`
|
|
131
|
+
* about a `platform_admin` who also holds it.
|
|
132
|
+
*/
|
|
94
133
|
role: string | null;
|
|
95
|
-
|
|
134
|
+
/**
|
|
135
|
+
* What to gate on. Permission ids from *your* own `permissionCatalog` for a
|
|
136
|
+
* member; Connect `platform:*` ids for staff. One vocabulary at a time,
|
|
137
|
+
* decided by `staff` - a member session never carries a `platform:*` id and
|
|
138
|
+
* a staff session never carries one of yours.
|
|
139
|
+
*/
|
|
140
|
+
permissions: string[];
|
|
141
|
+
/**
|
|
142
|
+
* `true` when this is one of Connect's own operators rather than your
|
|
143
|
+
* customer.
|
|
144
|
+
*
|
|
145
|
+
* Only ever `true` when a Connect platform account signs in **and** your
|
|
146
|
+
* application has staff access turned on for that role. It is off by
|
|
147
|
+
* default; a platform admin enables it per application in the Connect
|
|
148
|
+
* Console, so until then this is always `false`.
|
|
149
|
+
*
|
|
150
|
+
* A staff session is shaped differently, and every difference is
|
|
151
|
+
* deliberate: `user.workspaceId`/`workspaceName`/`workspaceType` are `null`
|
|
152
|
+
* (these accounts belong to no workspace, by enforcement rather than by
|
|
153
|
+
* accident) and `subscription` is `null` (nobody is paying for staff to be
|
|
154
|
+
* here). Serve your operator console off this session and nothing else.
|
|
155
|
+
*/
|
|
156
|
+
staff: boolean;
|
|
96
157
|
}
|
|
97
|
-
export interface TokenResponse {
|
|
158
|
+
export interface TokenResponse extends SessionAccess {
|
|
98
159
|
idToken: string;
|
|
99
160
|
tokenType: "Bearer";
|
|
100
161
|
/** Seconds until `idToken` expires - about 5 minutes. */
|
|
@@ -105,15 +166,17 @@ export interface TokenResponse {
|
|
|
105
166
|
sessionTokenExpiresIn: number;
|
|
106
167
|
user: ConnectUser;
|
|
107
168
|
subscription: SessionSubscription | null;
|
|
108
|
-
applicationRole: ApplicationRole;
|
|
109
169
|
/** Whether this account is the kind your application serves - see `SessionAudience`. */
|
|
110
170
|
audience: SessionAudience;
|
|
111
171
|
}
|
|
112
|
-
export interface UserResponse {
|
|
172
|
+
export interface UserResponse extends SessionAccess {
|
|
113
173
|
user: ConnectUser;
|
|
114
174
|
subscription: SessionSubscription | null;
|
|
115
|
-
|
|
116
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Live, like `subscription` and `role`/`permissions`/`staff` - a workspace
|
|
177
|
+
* that converted to a business since sign-in matches here without another
|
|
178
|
+
* sign-in.
|
|
179
|
+
*/
|
|
117
180
|
audience: SessionAudience;
|
|
118
181
|
/** ISO 8601. Refresh proactively off this rather than waiting for a 401. */
|
|
119
182
|
sessionExpiresAt: string;
|
|
@@ -248,7 +311,7 @@ export interface Plan {
|
|
|
248
311
|
/** GST-exclusive, in paise. */
|
|
249
312
|
price: number;
|
|
250
313
|
currency: "INR";
|
|
251
|
-
billingInterval:
|
|
314
|
+
billingInterval: BillingInterval;
|
|
252
315
|
gstRate: number;
|
|
253
316
|
addons: PlanAddon[];
|
|
254
317
|
seats: PlanSeats;
|
|
@@ -257,6 +320,16 @@ export interface Plan {
|
|
|
257
320
|
/** What this plan unlocks, labelled for display - see `PlanFeature`. */
|
|
258
321
|
features: PlanFeature[];
|
|
259
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* How often a plan bills.
|
|
325
|
+
*
|
|
326
|
+
* `"one-time"` is a plan that is paid for once and does not renew, so it has
|
|
327
|
+
* no cadence to pair with: `planGroup` still groups it, but there is no
|
|
328
|
+
* monthly/annual toggle to render for it. A pricing grid that assumes two
|
|
329
|
+
* cadences will show it under whichever tab happens to be selected - check the
|
|
330
|
+
* interval before offering the switch.
|
|
331
|
+
*/
|
|
332
|
+
export type BillingInterval = "monthly" | "annual" | "one-time";
|
|
260
333
|
export interface PlansResponse {
|
|
261
334
|
plans: Plan[];
|
|
262
335
|
}
|
|
@@ -264,7 +337,7 @@ export interface PlansResponse {
|
|
|
264
337
|
export interface SubscribedPlan {
|
|
265
338
|
id: string;
|
|
266
339
|
name: string;
|
|
267
|
-
billingInterval:
|
|
340
|
+
billingInterval: BillingInterval;
|
|
268
341
|
price: number;
|
|
269
342
|
currency: "INR";
|
|
270
343
|
gstRate: number;
|
|
@@ -483,6 +556,46 @@ export interface WorkspaceApp {
|
|
|
483
556
|
/** Launchable but not healthy (paused, or cancelling at period end) - badge it, do not hide it. */
|
|
484
557
|
needsAttention: boolean;
|
|
485
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* The platform's DPDP grievance channel - `companyProfile.grievance`.
|
|
561
|
+
*
|
|
562
|
+
* Flat and non-nullable: Connect resolves every field against its published
|
|
563
|
+
* defaults before answering, so there is no "not configured yet" state to
|
|
564
|
+
* branch on here. See `PlatformResource.getCompanyProfile`.
|
|
565
|
+
*/
|
|
566
|
+
export interface GrievanceChannel {
|
|
567
|
+
officerName: string;
|
|
568
|
+
officerEmail: string;
|
|
569
|
+
/** Free text, e.g. `"Monday - Friday, 10:00 AM - 6:00 PM IST"`. */
|
|
570
|
+
hours: string;
|
|
571
|
+
/** The redressal window the published notice commits to, in days. */
|
|
572
|
+
responseDays: number;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Who operates the platform your application runs on, and how a user
|
|
576
|
+
* complains to them.
|
|
577
|
+
*
|
|
578
|
+
* You are a Data Processor on this notice, not a second Data Fiduciary - so
|
|
579
|
+
* this is the block your privacy page and your consent capture print, rather
|
|
580
|
+
* than one of your own kept in environment variables. That is the whole point
|
|
581
|
+
* of reading it: a statutory contact copied into `.env` goes stale silently,
|
|
582
|
+
* and every application holding a copy publishes a channel that reaches
|
|
583
|
+
* nobody.
|
|
584
|
+
*/
|
|
585
|
+
export interface CompanyProfile {
|
|
586
|
+
legalName: string;
|
|
587
|
+
/** Trading name, for prose the full registered name reads oddly in. */
|
|
588
|
+
brandName: string;
|
|
589
|
+
registeredAddress: string;
|
|
590
|
+
contactEmail: string;
|
|
591
|
+
website: string | null;
|
|
592
|
+
/** GSTIN, `null` if the operating entity is not GST-registered. */
|
|
593
|
+
gstNumber: string | null;
|
|
594
|
+
grievance: GrievanceChannel;
|
|
595
|
+
}
|
|
596
|
+
export interface CompanyProfileResponse {
|
|
597
|
+
companyProfile: CompanyProfile;
|
|
598
|
+
}
|
|
486
599
|
export type SessionDeviceType = "desktop" | "mobile" | "tablet" | "unknown";
|
|
487
600
|
export interface SessionDevice {
|
|
488
601
|
userAgent: string;
|
|
@@ -785,5 +898,245 @@ export interface AiSourcesInput {
|
|
|
785
898
|
snippet?: string;
|
|
786
899
|
}[];
|
|
787
900
|
}
|
|
901
|
+
export interface AiActionsInput {
|
|
902
|
+
title?: string;
|
|
903
|
+
actions: {
|
|
904
|
+
label: string;
|
|
905
|
+
href: string;
|
|
906
|
+
detail?: string;
|
|
907
|
+
}[];
|
|
908
|
+
}
|
|
788
909
|
/** The tools this client knows how to draw. Anything else in the stream is ignored. */
|
|
789
|
-
export type AiToolName = "showTable" | "showChart" | "showMetrics" | "showTimeline" | "showDetails" | "showSteps" | "showSources";
|
|
910
|
+
export type AiToolName = "showTable" | "showChart" | "showMetrics" | "showTimeline" | "showDetails" | "showSteps" | "showSources" | "showActions";
|
|
911
|
+
/**
|
|
912
|
+
* One screen in your application, described for the assistant.
|
|
913
|
+
*
|
|
914
|
+
* ## Why you declare these rather than Connect discovering them
|
|
915
|
+
*
|
|
916
|
+
* Connect has no idea what your app is. It cannot know that `/deals` is a
|
|
917
|
+
* pipeline, that a "lead" becomes a "contact", or that the thing your users
|
|
918
|
+
* call a quote lives under Settings. Without that, an assistant sitting inside
|
|
919
|
+
* your product answers from general knowledge about software - which is exactly
|
|
920
|
+
* how it reads.
|
|
921
|
+
*
|
|
922
|
+
* Declaring a screen is the cheapest possible fix: one line of prose per route,
|
|
923
|
+
* and questions like "what can I do here?" start answering in your product's
|
|
924
|
+
* own words.
|
|
925
|
+
*
|
|
926
|
+
* ## What Connect does and does not do with them
|
|
927
|
+
*
|
|
928
|
+
* They are **prose and links, and nothing else**. Connect puts your
|
|
929
|
+
* descriptions into the model's context so it can answer and so `showActions`
|
|
930
|
+
* can link to your screens. It never uses them to decide what anyone may do -
|
|
931
|
+
* your app's own authorization is untouched and unconsulted here - and it never
|
|
932
|
+
* executes anything on your behalf.
|
|
933
|
+
*
|
|
934
|
+
* They also arrive from a browser, so Connect treats them as untrusted text:
|
|
935
|
+
* bounded in count and length, and flattened to single lines before they reach
|
|
936
|
+
* a prompt.
|
|
937
|
+
*/
|
|
938
|
+
export interface ConnectScreen {
|
|
939
|
+
/**
|
|
940
|
+
* The route, as your router writes it. Dynamic segments in brackets -
|
|
941
|
+
* `/deals/[dealId]` - so a live path with a real id still matches.
|
|
942
|
+
*/
|
|
943
|
+
path: string;
|
|
944
|
+
/** One line: what a person does here, in your product's words. */
|
|
945
|
+
purpose: string;
|
|
946
|
+
/**
|
|
947
|
+
* Opening questions offered as chips on an empty conversation, phrased as
|
|
948
|
+
* your users would type them. Two or three; a fourth is a menu.
|
|
949
|
+
*/
|
|
950
|
+
suggestions?: string[];
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* One document from the `data` store.
|
|
954
|
+
*
|
|
955
|
+
* Connect's own bookkeeping rides *inside* `data` under a `_` prefix -
|
|
956
|
+
* `_createdAt`, `_updatedAt`, `_createdBy`, `_updatedBy` - rather than as
|
|
957
|
+
* sibling fields, so a document round-trips through your code unchanged. You
|
|
958
|
+
* cannot write a `_`-prefixed field; that is what makes `_createdBy`
|
|
959
|
+
* trustworthy. It is `"application"` for a server-to-server write, or the
|
|
960
|
+
* Connect user id when a signed-in user drove it.
|
|
961
|
+
*/
|
|
962
|
+
export interface StoreDocument {
|
|
963
|
+
id: string;
|
|
964
|
+
/**
|
|
965
|
+
* The document's own fields, plus Connect's bookkeeping under `_`:
|
|
966
|
+
* `_createdAt`, `_updatedAt`, `_createdBy`, `_updatedBy`, and - on anything
|
|
967
|
+
* that came from a read - `_updateTime`.
|
|
968
|
+
*
|
|
969
|
+
* `_updateTime` is the value a `{ updateTime }` precondition on `commit` is
|
|
970
|
+
* compared against. It is Firestore's own write timestamp rather than the
|
|
971
|
+
* `_updatedAt` field beside it, because a transform in the same commit can
|
|
972
|
+
* move the field and cannot touch the write timestamp.
|
|
973
|
+
*
|
|
974
|
+
* None of them may be written back - strip every `_`-prefixed key before
|
|
975
|
+
* sending a document you read.
|
|
976
|
+
*/
|
|
977
|
+
data: Record<string, unknown>;
|
|
978
|
+
}
|
|
979
|
+
/** The comparison operators a store query may use - narrower than Firestore's own set. */
|
|
980
|
+
export type StoreQueryOperator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not-in" | "array-contains";
|
|
981
|
+
export interface StoreQueryFilter {
|
|
982
|
+
/** Must be one of the collection's declared `queryableFields`. */
|
|
983
|
+
field: string;
|
|
984
|
+
op: StoreQueryOperator;
|
|
985
|
+
value: unknown;
|
|
986
|
+
}
|
|
987
|
+
export interface StoreOrderBy {
|
|
988
|
+
field: string;
|
|
989
|
+
direction: "asc" | "desc";
|
|
990
|
+
}
|
|
991
|
+
export interface StoreQueryPage {
|
|
992
|
+
items: StoreDocument[];
|
|
993
|
+
/** Pass as the next `cursor`. `null` is the end of the collection. */
|
|
994
|
+
nextCursor: string | null;
|
|
995
|
+
}
|
|
996
|
+
export type StoreAggregationOperation = "count" | "sum" | "avg";
|
|
997
|
+
/**
|
|
998
|
+
* One aggregation over a filtered collection.
|
|
999
|
+
*
|
|
1000
|
+
* `alias` is what the result is keyed by, so a single request can carry a
|
|
1001
|
+
* count and a sum without the response shape depending on argument order.
|
|
1002
|
+
*/
|
|
1003
|
+
export interface StoreAggregation {
|
|
1004
|
+
op: StoreAggregationOperation;
|
|
1005
|
+
/** Required for `sum`/`avg`. `count` counts documents and takes none. */
|
|
1006
|
+
field?: string | null;
|
|
1007
|
+
alias: string;
|
|
1008
|
+
}
|
|
1009
|
+
export interface StoreAggregatePage {
|
|
1010
|
+
/**
|
|
1011
|
+
* One number per alias.
|
|
1012
|
+
*
|
|
1013
|
+
* A `sum` or `avg` over nothing is `null`, not `0` - "nothing matched" and
|
|
1014
|
+
* "the total is zero" are different facts. A `count` is always a number.
|
|
1015
|
+
*/
|
|
1016
|
+
values: Record<string, number | null>;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* A value Connect computes at write time instead of storing verbatim.
|
|
1020
|
+
*
|
|
1021
|
+
* Build them with the `increment`/`serverTimestamp`/`arrayUnion`/
|
|
1022
|
+
* `arrayRemove`/`deleteField` helpers rather than by hand - the sentinel shape
|
|
1023
|
+
* is an encoding, not an API.
|
|
1024
|
+
*
|
|
1025
|
+
* `increment` is the one that cannot be expressed any other way: it is
|
|
1026
|
+
* commutative, so concurrent increments all land with no precondition and no
|
|
1027
|
+
* retry, which read-modify-write from your own process can never guarantee.
|
|
1028
|
+
*/
|
|
1029
|
+
export type StoreFieldTransform = {
|
|
1030
|
+
__transform: "increment";
|
|
1031
|
+
by: number;
|
|
1032
|
+
} | {
|
|
1033
|
+
__transform: "serverTimestamp";
|
|
1034
|
+
} | {
|
|
1035
|
+
__transform: "arrayUnion";
|
|
1036
|
+
values: unknown[];
|
|
1037
|
+
} | {
|
|
1038
|
+
__transform: "arrayRemove";
|
|
1039
|
+
values: unknown[];
|
|
1040
|
+
} | {
|
|
1041
|
+
__transform: "delete";
|
|
1042
|
+
};
|
|
1043
|
+
/**
|
|
1044
|
+
* What must still be true of a document for a commit to land.
|
|
1045
|
+
*
|
|
1046
|
+
* `{ updateTime }` is the `_updateTime` a read returned - the optimistic half
|
|
1047
|
+
* of read, decide, commit. A precondition that no longer holds fails the whole
|
|
1048
|
+
* commit with a 409 and writes nothing.
|
|
1049
|
+
*/
|
|
1050
|
+
export type StorePrecondition = {
|
|
1051
|
+
exists: boolean;
|
|
1052
|
+
} | {
|
|
1053
|
+
updateTime: string;
|
|
1054
|
+
};
|
|
1055
|
+
export type StoreCommitMode = "create" | "replace" | "merge" | "delete";
|
|
1056
|
+
/** One write inside a commit. Each names its own collection - a commit may span several. */
|
|
1057
|
+
export interface StoreCommitOperation {
|
|
1058
|
+
op: StoreCommitMode;
|
|
1059
|
+
collection: string;
|
|
1060
|
+
/** Omit only on `create`, to have an id allocated. */
|
|
1061
|
+
id?: string | null;
|
|
1062
|
+
/** Absent on `delete`. Top-level values may be `StoreFieldTransform`s. */
|
|
1063
|
+
data?: Record<string, unknown> | null;
|
|
1064
|
+
/** Not accepted on `create`, which already means "and it must not exist". */
|
|
1065
|
+
precondition?: StorePrecondition | null;
|
|
1066
|
+
}
|
|
1067
|
+
export interface StoreCommitResult {
|
|
1068
|
+
/** The document id each operation wrote, positionally aligned with the operations sent. */
|
|
1069
|
+
ids: string[];
|
|
1070
|
+
}
|
|
1071
|
+
/** One entry from the `kv` store. */
|
|
1072
|
+
export interface KvEntry {
|
|
1073
|
+
key: string;
|
|
1074
|
+
value: unknown;
|
|
1075
|
+
/** ISO-8601, or `null` when the entry never expires. */
|
|
1076
|
+
expiresAt: string | null;
|
|
1077
|
+
updatedAt: string;
|
|
1078
|
+
}
|
|
1079
|
+
export interface KvPage {
|
|
1080
|
+
items: KvEntry[];
|
|
1081
|
+
/**
|
|
1082
|
+
* Pass as the next `cursor`. `null` is the end of the namespace.
|
|
1083
|
+
*
|
|
1084
|
+
* A page can be shorter than `limit` and still have one - expired entries
|
|
1085
|
+
* are filtered after paging - so this, not an empty `items`, is the signal
|
|
1086
|
+
* to stop.
|
|
1087
|
+
*/
|
|
1088
|
+
nextCursor: string | null;
|
|
1089
|
+
}
|
|
1090
|
+
/** One row from a cross-workspace scan - carries the workspace it belongs to. */
|
|
1091
|
+
export interface ScannedStoreDocument extends StoreDocument {
|
|
1092
|
+
workspaceId: string;
|
|
1093
|
+
}
|
|
1094
|
+
export interface StoreScanPage {
|
|
1095
|
+
items: ScannedStoreDocument[];
|
|
1096
|
+
/** `{workspaceId}/{documentId}`. Pass as the next `cursor`; `null` is the end. */
|
|
1097
|
+
nextCursor: string | null;
|
|
1098
|
+
}
|
|
1099
|
+
/** One workspace the signed-in user belongs to - a row in a workspace switcher. */
|
|
1100
|
+
export interface UserWorkspace {
|
|
1101
|
+
workspaceId: string;
|
|
1102
|
+
name: string;
|
|
1103
|
+
type: WorkspaceType;
|
|
1104
|
+
/** The workspace this session is currently pinned to. */
|
|
1105
|
+
isActive: boolean;
|
|
1106
|
+
/**
|
|
1107
|
+
* Whether your application is sold to this kind of workspace. `false` rows
|
|
1108
|
+
* are worth showing disabled with the reason - a workspace that silently
|
|
1109
|
+
* disappears from a switcher reads as data loss to the person who owns it.
|
|
1110
|
+
*/
|
|
1111
|
+
inAudience: boolean;
|
|
1112
|
+
/** Whether it holds an entitling subscription to your application. */
|
|
1113
|
+
subscribed: boolean;
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* The result of a workspace switch.
|
|
1117
|
+
*
|
|
1118
|
+
* `sessionToken` is a **new** credential - the one you switched from is
|
|
1119
|
+
* revoked. Persist this before navigating, or the user is signed out.
|
|
1120
|
+
*/
|
|
1121
|
+
export interface WorkspaceSwitchResult {
|
|
1122
|
+
sessionToken: string;
|
|
1123
|
+
sessionTokenExpiresIn: number;
|
|
1124
|
+
workspaceId: string;
|
|
1125
|
+
workspaceName: string;
|
|
1126
|
+
workspaceType: WorkspaceType;
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* One member of the workspace a session is on.
|
|
1130
|
+
*
|
|
1131
|
+
* `granted` is resolved for *your* application - permission ids from your own
|
|
1132
|
+
* catalog, not the member's Connect roles.
|
|
1133
|
+
*/
|
|
1134
|
+
export interface ConnectWorkspaceMember {
|
|
1135
|
+
userId: string;
|
|
1136
|
+
email: string;
|
|
1137
|
+
displayName: string | null;
|
|
1138
|
+
photoUrl: string | null;
|
|
1139
|
+
status: string;
|
|
1140
|
+
granted: string[];
|
|
1141
|
+
role: string | null;
|
|
1142
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface ConnectEmptyStateProps {
|
|
3
|
+
/** Rendered at `size-8`. Any icon element - lucide, an SVG, a glyph. */
|
|
4
|
+
icon?: ReactNode;
|
|
5
|
+
/** What is absent, in the user's words. One line. */
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* The one control that resolves the emptiness - "New contact" for a list
|
|
10
|
+
* that has never had anything in it, "Clear filter" for one whose contents
|
|
11
|
+
* are merely hidden.
|
|
12
|
+
*/
|
|
13
|
+
action?: ReactNode;
|
|
14
|
+
variant?: "card" | "dashed" | "plain";
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* What a list, grid or table shows when it has nothing to show.
|
|
19
|
+
*
|
|
20
|
+
* **The two empty states are different facts and the copy must say so.** "You
|
|
21
|
+
* have no contacts" and "no contacts match this filter" call for different
|
|
22
|
+
* words and a different action - create the thing, versus undo the filter
|
|
23
|
+
* hiding it. Both render through here; the caller decides which by what it
|
|
24
|
+
* passes as `action`. Getting this wrong costs a user real time: an
|
|
25
|
+
* unfiltered-looking empty state in front of a filtered list reads as data
|
|
26
|
+
* loss.
|
|
27
|
+
*
|
|
28
|
+
* `variant` chooses the container by what the state stands *in*: `card` (the
|
|
29
|
+
* default), `dashed` for a region that will be filled in place - a file grid,
|
|
30
|
+
* a board column - where the outline is what says "things appear here", and
|
|
31
|
+
* `plain` for a slot already inside a card that would otherwise nest two
|
|
32
|
+
* borders.
|
|
33
|
+
*/
|
|
34
|
+
export declare function ConnectEmptyState({ icon, title, description, action, variant, className, }: Readonly<ConnectEmptyStateProps>): import("react").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page-composition primitives - the layer between HeroUI and your features.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately **not** `"use client"`. Everything here is presentational, with
|
|
5
|
+
* no hooks and no state, so it renders in a Server Component and stays out of
|
|
6
|
+
* the browser bundle. That is the whole reason this is a separate entry point
|
|
7
|
+
* from `@cosmoops/connect-sdk/client`: that module's barrel carries a
|
|
8
|
+
* `"use client"` directive, so re-exporting a `<Card>` wrapper through it
|
|
9
|
+
* would turn every page shell in your app into a client boundary for no gain.
|
|
10
|
+
*
|
|
11
|
+
* The interactive counterparts - a confirm dialog, cursor pagination, filter
|
|
12
|
+
* tabs - hold state and live in `/client` alongside the rest of the browser
|
|
13
|
+
* half.
|
|
14
|
+
*
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { ConnectPageShell, ConnectSection } from "@cosmoops/connect-sdk/ui";
|
|
17
|
+
*
|
|
18
|
+
* export default function ContactsPage() {
|
|
19
|
+
* return (
|
|
20
|
+
* <ConnectPageShell title="Contacts" description="Everyone you do business with.">
|
|
21
|
+
* <ConnectPageShell.Async fallback={<TableSkeleton />}>
|
|
22
|
+
* <ContactsTable />
|
|
23
|
+
* </ConnectPageShell.Async>
|
|
24
|
+
* </ConnectPageShell>
|
|
25
|
+
* );
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export { ConnectPageShell } from "./page-shell.js";
|
|
30
|
+
export type { ConnectPageShellProps } from "./page-shell.js";
|
|
31
|
+
export { ConnectPageHeader } from "./page-header.js";
|
|
32
|
+
export type { ConnectPageHeaderProps } from "./page-header.js";
|
|
33
|
+
export { ConnectSection } from "./section.js";
|
|
34
|
+
export type { ConnectSectionProps } from "./section.js";
|
|
35
|
+
export { ConnectEmptyState } from "./empty-state.js";
|
|
36
|
+
export type { ConnectEmptyStateProps } from "./empty-state.js";
|
|
37
|
+
export { ConnectSettingRow } from "./setting-row.js";
|
|
38
|
+
export type { ConnectSettingRowProps } from "./setting-row.js";
|
|
39
|
+
export { ConnectStatusChip } from "./status-chip.js";
|
|
40
|
+
export type { ConnectStatusTone, ConnectStatusPresentation } from "./status-chip.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface ConnectPageHeaderProps {
|
|
3
|
+
title: ReactNode;
|
|
4
|
+
description?: ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* Rendered opposite the title. Keep it to one control - a page has one
|
|
7
|
+
* primary action, and a second here has nothing to align against.
|
|
8
|
+
*/
|
|
9
|
+
action?: ReactNode;
|
|
10
|
+
/** Set `false` when the description carries a link that must stay readable on a phone. */
|
|
11
|
+
clamp?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The title / description / action block a page opens with.
|
|
16
|
+
*
|
|
17
|
+
* The structure is the point, not the styling. The action is a peer of the
|
|
18
|
+
* **title**, not of the block, so nothing below the first line can move it -
|
|
19
|
+
* the common hand-rolled shape puts the action after the description, which
|
|
20
|
+
* makes the vertical position of a page's primary control a function of how
|
|
21
|
+
* long someone wrote the paragraph above it. On a phone that pushes it most of
|
|
22
|
+
* a thumb's reach down the screen.
|
|
23
|
+
*
|
|
24
|
+
* Mobile-first, and the two axes are separate decisions: the title row is a
|
|
25
|
+
* `justify-between` at every width (title left, action right, where a thumb
|
|
26
|
+
* expects it), while the description is clamped to two lines on a phone and
|
|
27
|
+
* released from `sm` up.
|
|
28
|
+
*
|
|
29
|
+
* An `h2`, because the document's `h1` is the application itself.
|
|
30
|
+
*
|
|
31
|
+
* No hooks and no state, so this renders from a Server Component - which is
|
|
32
|
+
* why it lives in `@cosmoops/connect-sdk/ui` rather than `/client`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function ConnectPageHeader({ title, description, action, clamp, className, }: Readonly<ConnectPageHeaderProps>): import("react").JSX.Element;
|