@antasphere/chassis-contract 0.0.0-stage → 1.0.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 (130) hide show
  1. package/LICENSE +82 -0
  2. package/dist/define.d.ts +177 -0
  3. package/dist/define.d.ts.map +1 -0
  4. package/dist/define.js +35 -0
  5. package/dist/define.js.map +1 -0
  6. package/dist/entitlements.d.ts +486 -0
  7. package/dist/entitlements.d.ts.map +1 -0
  8. package/dist/entitlements.js +344 -0
  9. package/dist/entitlements.js.map +1 -0
  10. package/dist/identity.d.ts +56 -0
  11. package/dist/identity.d.ts.map +1 -0
  12. package/dist/identity.js +2 -0
  13. package/dist/identity.js.map +1 -0
  14. package/dist/index.d.ts +23 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +29 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/routes/index.d.ts +5403 -0
  19. package/dist/routes/index.d.ts.map +1 -0
  20. package/dist/routes/index.js +940 -0
  21. package/dist/routes/index.js.map +1 -0
  22. package/dist/schemas/api-keys.d.ts +54 -0
  23. package/dist/schemas/api-keys.d.ts.map +1 -0
  24. package/dist/schemas/api-keys.js +48 -0
  25. package/dist/schemas/api-keys.js.map +1 -0
  26. package/dist/schemas/audit.d.ts +74 -0
  27. package/dist/schemas/audit.d.ts.map +1 -0
  28. package/dist/schemas/audit.js +65 -0
  29. package/dist/schemas/audit.js.map +1 -0
  30. package/dist/schemas/break-glass.d.ts +42 -0
  31. package/dist/schemas/break-glass.d.ts.map +1 -0
  32. package/dist/schemas/break-glass.js +38 -0
  33. package/dist/schemas/break-glass.js.map +1 -0
  34. package/dist/schemas/cli-auth.d.ts +59 -0
  35. package/dist/schemas/cli-auth.d.ts.map +1 -0
  36. package/dist/schemas/cli-auth.js +68 -0
  37. package/dist/schemas/cli-auth.js.map +1 -0
  38. package/dist/schemas/common.d.ts +96 -0
  39. package/dist/schemas/common.d.ts.map +1 -0
  40. package/dist/schemas/common.js +205 -0
  41. package/dist/schemas/common.js.map +1 -0
  42. package/dist/schemas/demo-passes.d.ts +90 -0
  43. package/dist/schemas/demo-passes.d.ts.map +1 -0
  44. package/dist/schemas/demo-passes.js +60 -0
  45. package/dist/schemas/demo-passes.js.map +1 -0
  46. package/dist/schemas/files.d.ts +39 -0
  47. package/dist/schemas/files.d.ts.map +1 -0
  48. package/dist/schemas/files.js +26 -0
  49. package/dist/schemas/files.js.map +1 -0
  50. package/dist/schemas/instance.d.ts +58 -0
  51. package/dist/schemas/instance.d.ts.map +1 -0
  52. package/dist/schemas/instance.js +70 -0
  53. package/dist/schemas/instance.js.map +1 -0
  54. package/dist/schemas/invitations.d.ts +100 -0
  55. package/dist/schemas/invitations.d.ts.map +1 -0
  56. package/dist/schemas/invitations.js +55 -0
  57. package/dist/schemas/invitations.js.map +1 -0
  58. package/dist/schemas/me.d.ts +81 -0
  59. package/dist/schemas/me.d.ts.map +1 -0
  60. package/dist/schemas/me.js +178 -0
  61. package/dist/schemas/me.js.map +1 -0
  62. package/dist/schemas/members.d.ts +60 -0
  63. package/dist/schemas/members.d.ts.map +1 -0
  64. package/dist/schemas/members.js +43 -0
  65. package/dist/schemas/members.js.map +1 -0
  66. package/dist/schemas/projects.d.ts +232 -0
  67. package/dist/schemas/projects.d.ts.map +1 -0
  68. package/dist/schemas/projects.js +140 -0
  69. package/dist/schemas/projects.js.map +1 -0
  70. package/dist/schemas/scope.d.ts +14 -0
  71. package/dist/schemas/scope.d.ts.map +1 -0
  72. package/dist/schemas/scope.js +5 -0
  73. package/dist/schemas/scope.js.map +1 -0
  74. package/dist/schemas/setup.d.ts +28 -0
  75. package/dist/schemas/setup.d.ts.map +1 -0
  76. package/dist/schemas/setup.js +28 -0
  77. package/dist/schemas/setup.js.map +1 -0
  78. package/dist/schemas/sso-connect.d.ts +30 -0
  79. package/dist/schemas/sso-connect.d.ts.map +1 -0
  80. package/dist/schemas/sso-connect.js +38 -0
  81. package/dist/schemas/sso-connect.js.map +1 -0
  82. package/dist/schemas/sso-logout.d.ts +17 -0
  83. package/dist/schemas/sso-logout.d.ts.map +1 -0
  84. package/dist/schemas/sso-logout.js +16 -0
  85. package/dist/schemas/sso-logout.js.map +1 -0
  86. package/dist/schemas/teams.d.ts +100 -0
  87. package/dist/schemas/teams.d.ts.map +1 -0
  88. package/dist/schemas/teams.js +84 -0
  89. package/dist/schemas/teams.js.map +1 -0
  90. package/dist/schemas/workspaces.d.ts +99 -0
  91. package/dist/schemas/workspaces.d.ts.map +1 -0
  92. package/dist/schemas/workspaces.js +96 -0
  93. package/dist/schemas/workspaces.js.map +1 -0
  94. package/dist/seams.d.ts +185 -0
  95. package/dist/seams.d.ts.map +1 -0
  96. package/dist/seams.js +37 -0
  97. package/dist/seams.js.map +1 -0
  98. package/dist/wire.d.ts +101 -0
  99. package/dist/wire.d.ts.map +1 -0
  100. package/dist/wire.js +161 -0
  101. package/dist/wire.js.map +1 -0
  102. package/package.json +41 -3
  103. package/src/define.ts +64 -0
  104. package/src/entitlements.ts +527 -0
  105. package/src/identity.ts +49 -0
  106. package/src/index.ts +38 -0
  107. package/src/routes/index.ts +1146 -0
  108. package/src/schemas/api-keys.ts +53 -0
  109. package/src/schemas/audit.ts +74 -0
  110. package/src/schemas/break-glass.ts +46 -0
  111. package/src/schemas/cli-auth.ts +78 -0
  112. package/src/schemas/common.ts +206 -0
  113. package/src/schemas/demo-passes.ts +73 -0
  114. package/src/schemas/files.ts +30 -0
  115. package/src/schemas/instance.ts +71 -0
  116. package/src/schemas/invitations.ts +66 -0
  117. package/src/schemas/me.ts +184 -0
  118. package/src/schemas/members.ts +53 -0
  119. package/src/schemas/projects.ts +174 -0
  120. package/src/schemas/scope.ts +18 -0
  121. package/src/schemas/setup.ts +31 -0
  122. package/src/schemas/sso-connect.ts +40 -0
  123. package/src/schemas/sso-logout.ts +17 -0
  124. package/src/schemas/teams.ts +101 -0
  125. package/src/schemas/workspaces.ts +109 -0
  126. package/src/seams.ts +202 -0
  127. package/src/wire.ts +246 -0
  128. package/test/define.test.ts +59 -0
  129. package/test/hub-wire.test.ts +114 -0
  130. package/README.md +0 -3
@@ -0,0 +1,232 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * A PROJECT is a subgroup of a workspace: a name, a description, members with
4
+ * a role, and the tool's resources linked to it. The chassis owns the
5
+ * concept; what a project HOLDS is the tool's (its own link table, its own
6
+ * routes). A project is archived, never deleted.
7
+ */
8
+ /**
9
+ * The three project roles, each one containing the one before it:
10
+ * - `viewer`: reads the project and what is linked to it;
11
+ * - `editor`: viewer + writes what is linked to it, links resources of their own;
12
+ * - `manager`: editor + edits the project, archives it, manages its members.
13
+ * A workspace owner or admin acts as a manager on every project.
14
+ */
15
+ export declare const projectRoleSchema: z.ZodEnum<{
16
+ manager: "manager";
17
+ editor: "editor";
18
+ viewer: "viewer";
19
+ }>;
20
+ export type ProjectRole = z.infer<typeof projectRoleSchema>;
21
+ /** True when `role` is `min` or contains it (`manager` ≥ `editor` ≥ `viewer`). */
22
+ export declare function projectRoleAtLeast(role: ProjectRole, min: ProjectRole): boolean;
23
+ /**
24
+ * Serialized size cap for a project's owner-defined metadata object, in
25
+ * JSON.stringify characters (an environment-free proxy for bytes: the
26
+ * contract runs in browsers and Node alike).
27
+ */
28
+ export declare const PROJECT_METADATA_MAX_LENGTH: number;
29
+ /**
30
+ * Owner-defined structured metadata: a plain JSON object, opaque to the
31
+ * server beyond shape and size. This is the tool's and the integrator's seam,
32
+ * the reason no tool ever needs a column on the project. PATCH replaces the
33
+ * whole object; merge is a client concern.
34
+ */
35
+ export declare const projectMetadataSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
36
+ export declare const projectSchema: z.ZodObject<{
37
+ id: z.ZodString;
38
+ name: z.ZodString;
39
+ description: z.ZodNullable<z.ZodString>;
40
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
41
+ archivedAt: z.ZodNullable<z.ZodString>;
42
+ createdBy: z.ZodNullable<z.ZodString>;
43
+ createdAt: z.ZodString;
44
+ updatedAt: z.ZodString;
45
+ myRole: z.ZodEnum<{
46
+ manager: "manager";
47
+ editor: "editor";
48
+ viewer: "viewer";
49
+ }>;
50
+ memberCount: z.ZodNumber;
51
+ }, z.core.$strip>;
52
+ export type Project = z.infer<typeof projectSchema>;
53
+ export declare const projectsListSchema: z.ZodObject<{
54
+ projects: z.ZodArray<z.ZodObject<{
55
+ id: z.ZodString;
56
+ name: z.ZodString;
57
+ description: z.ZodNullable<z.ZodString>;
58
+ metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
59
+ archivedAt: z.ZodNullable<z.ZodString>;
60
+ createdBy: z.ZodNullable<z.ZodString>;
61
+ createdAt: z.ZodString;
62
+ updatedAt: z.ZodString;
63
+ myRole: z.ZodEnum<{
64
+ manager: "manager";
65
+ editor: "editor";
66
+ viewer: "viewer";
67
+ }>;
68
+ memberCount: z.ZodNumber;
69
+ }, z.core.$strip>>;
70
+ nextCursor: z.ZodNullable<z.ZodString>;
71
+ }, z.core.$strip>;
72
+ export type ProjectsList = z.infer<typeof projectsListSchema>;
73
+ /** `false` (the default) = the live projects, `true` = the archived ones, `all` = both. */
74
+ export declare const projectsArchivedFilterSchema: z.ZodEnum<{
75
+ false: "false";
76
+ true: "true";
77
+ all: "all";
78
+ }>;
79
+ export type ProjectsArchivedFilter = z.infer<typeof projectsArchivedFilterSchema>;
80
+ export declare const projectsListQuerySchema: z.ZodObject<{
81
+ cursor: z.ZodOptional<z.ZodString>;
82
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
83
+ archived: z.ZodDefault<z.ZodEnum<{
84
+ false: "false";
85
+ true: "true";
86
+ all: "all";
87
+ }>>;
88
+ }, z.core.$strip>;
89
+ export declare const projectCreateSchema: z.ZodObject<{
90
+ name: z.ZodString;
91
+ description: z.ZodOptional<z.ZodString>;
92
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
93
+ }, z.core.$strip>;
94
+ export type ProjectCreate = z.infer<typeof projectCreateSchema>;
95
+ export declare const projectUpdateSchema: z.ZodObject<{
96
+ name: z.ZodOptional<z.ZodString>;
97
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
98
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
99
+ }, z.core.$strip>;
100
+ export type ProjectUpdate = z.infer<typeof projectUpdateSchema>;
101
+ /**
102
+ * A project's members are people AND teams, each with a role (PRDCT-2794):
103
+ * one list, told apart by `kind`. A team entry's role is what every active
104
+ * non-guest member of the team holds through it; a person's effective role
105
+ * is the highest of their own entry and their teams' entries. `kind` is
106
+ * `person` on every entry that predates teams, so a reader that never asked
107
+ * for teams still reads what it did.
108
+ */
109
+ export declare const projectPersonMemberSchema: z.ZodObject<{
110
+ kind: z.ZodLiteral<"person">;
111
+ userId: z.ZodString;
112
+ email: z.ZodString;
113
+ name: z.ZodString;
114
+ role: z.ZodEnum<{
115
+ manager: "manager";
116
+ editor: "editor";
117
+ viewer: "viewer";
118
+ }>;
119
+ addedBy: z.ZodNullable<z.ZodString>;
120
+ createdAt: z.ZodString;
121
+ }, z.core.$strip>;
122
+ export type ProjectPersonMember = z.infer<typeof projectPersonMemberSchema>;
123
+ export declare const projectTeamMemberSchema: z.ZodObject<{
124
+ kind: z.ZodLiteral<"team">;
125
+ teamId: z.ZodString;
126
+ slug: z.ZodString;
127
+ name: z.ZodString;
128
+ membersCount: z.ZodNumber;
129
+ hubTeamId: z.ZodNullable<z.ZodString>;
130
+ role: z.ZodEnum<{
131
+ manager: "manager";
132
+ editor: "editor";
133
+ viewer: "viewer";
134
+ }>;
135
+ addedBy: z.ZodNullable<z.ZodString>;
136
+ createdAt: z.ZodString;
137
+ }, z.core.$strip>;
138
+ export type ProjectTeamMember = z.infer<typeof projectTeamMemberSchema>;
139
+ export declare const projectMemberSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
140
+ kind: z.ZodLiteral<"person">;
141
+ userId: z.ZodString;
142
+ email: z.ZodString;
143
+ name: z.ZodString;
144
+ role: z.ZodEnum<{
145
+ manager: "manager";
146
+ editor: "editor";
147
+ viewer: "viewer";
148
+ }>;
149
+ addedBy: z.ZodNullable<z.ZodString>;
150
+ createdAt: z.ZodString;
151
+ }, z.core.$strip>, z.ZodObject<{
152
+ kind: z.ZodLiteral<"team">;
153
+ teamId: z.ZodString;
154
+ slug: z.ZodString;
155
+ name: z.ZodString;
156
+ membersCount: z.ZodNumber;
157
+ hubTeamId: z.ZodNullable<z.ZodString>;
158
+ role: z.ZodEnum<{
159
+ manager: "manager";
160
+ editor: "editor";
161
+ viewer: "viewer";
162
+ }>;
163
+ addedBy: z.ZodNullable<z.ZodString>;
164
+ createdAt: z.ZodString;
165
+ }, z.core.$strip>], "kind">;
166
+ export type ProjectMember = z.infer<typeof projectMemberSchema>;
167
+ export declare const projectMembersListSchema: z.ZodObject<{
168
+ members: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
169
+ kind: z.ZodLiteral<"person">;
170
+ userId: z.ZodString;
171
+ email: z.ZodString;
172
+ name: z.ZodString;
173
+ role: z.ZodEnum<{
174
+ manager: "manager";
175
+ editor: "editor";
176
+ viewer: "viewer";
177
+ }>;
178
+ addedBy: z.ZodNullable<z.ZodString>;
179
+ createdAt: z.ZodString;
180
+ }, z.core.$strip>, z.ZodObject<{
181
+ kind: z.ZodLiteral<"team">;
182
+ teamId: z.ZodString;
183
+ slug: z.ZodString;
184
+ name: z.ZodString;
185
+ membersCount: z.ZodNumber;
186
+ hubTeamId: z.ZodNullable<z.ZodString>;
187
+ role: z.ZodEnum<{
188
+ manager: "manager";
189
+ editor: "editor";
190
+ viewer: "viewer";
191
+ }>;
192
+ addedBy: z.ZodNullable<z.ZodString>;
193
+ createdAt: z.ZodString;
194
+ }, z.core.$strip>], "kind">>;
195
+ nextCursor: z.ZodNullable<z.ZodString>;
196
+ }, z.core.$strip>;
197
+ export type ProjectMembersList = z.infer<typeof projectMembersListSchema>;
198
+ /**
199
+ * Add one of the workspace's OWN active members, named by user id or by
200
+ * email, or one of the workspace's teams by its id: exactly one of the three.
201
+ * No invitation, no claim token, no account is ever minted here.
202
+ */
203
+ export declare const projectMemberAddSchema: z.ZodObject<{
204
+ userId: z.ZodOptional<z.ZodString>;
205
+ email: z.ZodOptional<z.ZodEmail>;
206
+ teamId: z.ZodOptional<z.ZodUUID>;
207
+ role: z.ZodEnum<{
208
+ manager: "manager";
209
+ editor: "editor";
210
+ viewer: "viewer";
211
+ }>;
212
+ }, z.core.$strip>;
213
+ export type ProjectMemberAdd = z.infer<typeof projectMemberAddSchema>;
214
+ export declare const projectMemberRoleSchema: z.ZodObject<{
215
+ role: z.ZodEnum<{
216
+ manager: "manager";
217
+ editor: "editor";
218
+ viewer: "viewer";
219
+ }>;
220
+ }, z.core.$strip>;
221
+ export type ProjectMemberRoleUpdate = z.infer<typeof projectMemberRoleSchema>;
222
+ /** A user id is Better Auth's text id, never a uuid: bounded free text, no control characters. */
223
+ export declare const projectMemberParamsSchema: z.ZodObject<{
224
+ id: z.ZodUUID;
225
+ userId: z.ZodString;
226
+ }, z.core.$strip>;
227
+ /** `{id}` the project and `{teamId}` the team, both uuids. */
228
+ export declare const projectTeamParamsSchema: z.ZodObject<{
229
+ id: z.ZodUUID;
230
+ teamId: z.ZodUUID;
231
+ }, z.core.$strip>;
232
+ //# sourceMappingURL=projects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/schemas/projects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;GAKG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;;EAA0C,CAAC;AACzE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAI5D,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EA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AAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;iBAS/B,CAAC;AACL,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,uBAAuB;;;;;;iBAAwC,CAAC;AAC7E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E,kGAAkG;AAClG,eAAO,MAAM,yBAAyB;;;iBAGpC,CAAC;AAEH,8DAA8D;AAC9D,eAAO,MAAM,uBAAuB;;;iBAA+C,CAAC"}
@@ -0,0 +1,140 @@
1
+ import { z } from 'zod';
2
+ import { cursorPageQuerySchema, noControlChars, opaqueJsonChecks, plainText } from './common.js';
3
+ /**
4
+ * A PROJECT is a subgroup of a workspace: a name, a description, members with
5
+ * a role, and the tool's resources linked to it. The chassis owns the
6
+ * concept; what a project HOLDS is the tool's (its own link table, its own
7
+ * routes). A project is archived, never deleted.
8
+ */
9
+ /**
10
+ * The three project roles, each one containing the one before it:
11
+ * - `viewer`: reads the project and what is linked to it;
12
+ * - `editor`: viewer + writes what is linked to it, links resources of their own;
13
+ * - `manager`: editor + edits the project, archives it, manages its members.
14
+ * A workspace owner or admin acts as a manager on every project.
15
+ */
16
+ export const projectRoleSchema = z.enum(['manager', 'editor', 'viewer']);
17
+ const PROJECT_ROLE_RANK = { viewer: 0, editor: 1, manager: 2 };
18
+ /** True when `role` is `min` or contains it (`manager` ≥ `editor` ≥ `viewer`). */
19
+ export function projectRoleAtLeast(role, min) {
20
+ return PROJECT_ROLE_RANK[role] >= PROJECT_ROLE_RANK[min];
21
+ }
22
+ /**
23
+ * Serialized size cap for a project's owner-defined metadata object, in
24
+ * JSON.stringify characters (an environment-free proxy for bytes: the
25
+ * contract runs in browsers and Node alike).
26
+ */
27
+ export const PROJECT_METADATA_MAX_LENGTH = 16 * 1024;
28
+ /**
29
+ * Owner-defined structured metadata: a plain JSON object, opaque to the
30
+ * server beyond shape and size. This is the tool's and the integrator's seam,
31
+ * the reason no tool ever needs a column on the project. PATCH replaces the
32
+ * whole object; merge is a client concern.
33
+ */
34
+ export const projectMetadataSchema = opaqueJsonChecks(z.record(z.string(), z.unknown())).refine((v) => JSON.stringify(v).length <= PROJECT_METADATA_MAX_LENGTH, `metadata must serialize to at most ${PROJECT_METADATA_MAX_LENGTH} characters`);
35
+ export const projectSchema = z.object({
36
+ id: z.string(),
37
+ name: z.string(),
38
+ description: z.string().nullable(),
39
+ metadata: z.record(z.string(), z.unknown()),
40
+ /** Set while the project is archived: out of the default list, read-only. */
41
+ archivedAt: z.string().nullable(),
42
+ createdBy: z.string().nullable(),
43
+ createdAt: z.string(),
44
+ updatedAt: z.string(),
45
+ /** The CALLER's effective role (`manager` for a workspace owner or admin). */
46
+ myRole: projectRoleSchema,
47
+ memberCount: z.number().int()
48
+ });
49
+ export const projectsListSchema = z.object({
50
+ projects: z.array(projectSchema),
51
+ nextCursor: z.string().nullable()
52
+ });
53
+ /** `false` (the default) = the live projects, `true` = the archived ones, `all` = both. */
54
+ export const projectsArchivedFilterSchema = z.enum(['false', 'true', 'all']);
55
+ export const projectsListQuerySchema = cursorPageQuerySchema.extend({
56
+ archived: projectsArchivedFilterSchema.default('false')
57
+ });
58
+ export const projectCreateSchema = z.object({
59
+ name: plainText(1, 200),
60
+ description: plainText(0, 2000).optional(),
61
+ metadata: projectMetadataSchema.optional()
62
+ });
63
+ // Every field optional, so an empty body is refused HERE (an empty drizzle
64
+ // `.set({})` is a Postgres error, not a client mistake answered 400).
65
+ export const projectUpdateSchema = z
66
+ .object({
67
+ name: plainText(1, 200).optional(),
68
+ /** `null` clears the description. */
69
+ description: plainText(0, 2000).nullable().optional(),
70
+ metadata: projectMetadataSchema.optional()
71
+ })
72
+ .refine((v) => v.name !== undefined || v.description !== undefined || v.metadata !== undefined, {
73
+ error: 'at least one of name, description or metadata is required'
74
+ });
75
+ /**
76
+ * A project's members are people AND teams, each with a role (PRDCT-2794):
77
+ * one list, told apart by `kind`. A team entry's role is what every active
78
+ * non-guest member of the team holds through it; a person's effective role
79
+ * is the highest of their own entry and their teams' entries. `kind` is
80
+ * `person` on every entry that predates teams, so a reader that never asked
81
+ * for teams still reads what it did.
82
+ */
83
+ export const projectPersonMemberSchema = z.object({
84
+ kind: z.literal('person'),
85
+ userId: z.string(),
86
+ email: z.string(),
87
+ name: z.string(),
88
+ role: projectRoleSchema,
89
+ addedBy: z.string().nullable(),
90
+ createdAt: z.string()
91
+ });
92
+ export const projectTeamMemberSchema = z.object({
93
+ kind: z.literal('team'),
94
+ teamId: z.string(),
95
+ slug: z.string(),
96
+ name: z.string(),
97
+ /**
98
+ * How many seats the team holds here, the account site's count. A
99
+ * deactivated member keeps their seat (a pause) and holds nothing through
100
+ * it until reactivated; the team's page shows each seat's state.
101
+ */
102
+ membersCount: z.number().int(),
103
+ /** The hub's team id when the team is the account site's projection; null for the tool's own. */
104
+ hubTeamId: z.string().nullable(),
105
+ role: projectRoleSchema,
106
+ addedBy: z.string().nullable(),
107
+ createdAt: z.string()
108
+ });
109
+ export const projectMemberSchema = z.discriminatedUnion('kind', [
110
+ projectPersonMemberSchema,
111
+ projectTeamMemberSchema
112
+ ]);
113
+ export const projectMembersListSchema = z.object({
114
+ members: z.array(projectMemberSchema),
115
+ nextCursor: z.string().nullable()
116
+ });
117
+ /**
118
+ * Add one of the workspace's OWN active members, named by user id or by
119
+ * email, or one of the workspace's teams by its id: exactly one of the three.
120
+ * No invitation, no claim token, no account is ever minted here.
121
+ */
122
+ export const projectMemberAddSchema = z
123
+ .object({
124
+ userId: plainText(1, 200).optional(),
125
+ email: z.email().optional(),
126
+ teamId: z.uuid().optional(),
127
+ role: projectRoleSchema
128
+ })
129
+ .refine((v) => [v.userId, v.email, v.teamId].filter((k) => k !== undefined).length === 1, {
130
+ error: 'exactly one of userId, email or teamId is required'
131
+ });
132
+ export const projectMemberRoleSchema = z.object({ role: projectRoleSchema });
133
+ /** A user id is Better Auth's text id, never a uuid: bounded free text, no control characters. */
134
+ export const projectMemberParamsSchema = z.object({
135
+ id: z.uuid(),
136
+ userId: noControlChars(z.string().min(1).max(200))
137
+ });
138
+ /** `{id}` the project and `{teamId}` the team, both uuids. */
139
+ export const projectTeamParamsSchema = z.object({ id: z.uuid(), teamId: z.uuid() });
140
+ //# sourceMappingURL=projects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/schemas/projects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEjG;;;;;GAKG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAGzE,MAAM,iBAAiB,GAAgC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAE5F,kFAAkF;AAClF,MAAM,UAAU,kBAAkB,CAAC,IAAiB,EAAE,GAAgB;IACpE,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,IAAI,CAAC;AAErD;;;;;GAKG;AACH,MAAM,CAAC,MA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AAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC3B,IAAI,EAAE,iBAAiB;CACxB,CAAC;KACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;IACxF,KAAK,EAAE,oDAAoD;CAC5D,CAAC,CAAC;AAGL,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAG7E,kGAAkG;AAClG,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;IACZ,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACnD,CAAC,CAAC;AAEH,8DAA8D;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The scope vocabulary is the TOOL's identity (`products:read`, …), so the
4
+ * chassis never spells one: a tool hands its scopes to
5
+ * `defineChassisContract({ scopes })` (../define.ts) and gets back the enum
6
+ * and every schema that carries it.
7
+ */
8
+ export type ScopeTuple = readonly [string, ...string[]];
9
+ /** The zod enum over a tool's scopes — exactly what `z.enum([...scopes])` builds. */
10
+ export type ScopeSchema<TScope extends string> = z.ZodEnum<{
11
+ [K in TScope]: K;
12
+ }>;
13
+ export declare function defineScopeSchema<const TScopes extends ScopeTuple>(scopes: TScopes): ScopeSchema<TScopes[number]>;
14
+ //# sourceMappingURL=scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/schemas/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AAExD,qFAAqF;AACrF,MAAM,MAAM,WAAW,CAAC,MAAM,SAAS,MAAM,IAAI,CAAC,CAAC,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,GAAG,CAAC;CAAE,CAAC,CAAC;AAEjF,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,OAAO,SAAS,UAAU,EAChE,MAAM,EAAE,OAAO,GACd,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAE9B"}
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export function defineScopeSchema(scopes) {
3
+ return z.enum(scopes);
4
+ }
5
+ //# sourceMappingURL=scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/schemas/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,MAAM,UAAU,iBAAiB,CAC/B,MAAe;IAEf,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAA4C,CAAC;AACnE,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * POST /api/v1/setup — one-shot first-boot wizard: creates the owner user
4
+ * and, on the OSS edition, the instance's FIRST workspace (later ones come
5
+ * from `POST /workspaces`). Guarded by the
6
+ * singleton instance_settings row (second attempt → 410) and, optionally, a
7
+ * SETUP_TOKEN. On the CLOUD edition setup creates NO workspace (the
8
+ * response's `workspaceId` is null): every cloud workspace is a hub-org
9
+ * projection, so the operator bootstrap mints a verified, break-glass
10
+ * capable USER only (internal/federation.md, user-scoped federation).
11
+ */
12
+ export declare const setupRequestSchema: z.ZodObject<{
13
+ instanceName: z.ZodString;
14
+ owner: z.ZodObject<{
15
+ email: z.ZodEmail;
16
+ name: z.ZodString;
17
+ password: z.ZodString;
18
+ }, z.core.$strip>;
19
+ setupToken: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>;
21
+ export type SetupRequest = z.infer<typeof setupRequestSchema>;
22
+ export declare const setupResponseSchema: z.ZodObject<{
23
+ instanceId: z.ZodString;
24
+ workspaceId: z.ZodNullable<z.ZodString>;
25
+ ownerUserId: z.ZodString;
26
+ }, z.core.$strip>;
27
+ export type SetupResponse = z.infer<typeof setupResponseSchema>;
28
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/schemas/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;iBAQ7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,mBAAmB;;;;iBAK9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import { plainText } from './common.js';
3
+ /**
4
+ * POST /api/v1/setup — one-shot first-boot wizard: creates the owner user
5
+ * and, on the OSS edition, the instance's FIRST workspace (later ones come
6
+ * from `POST /workspaces`). Guarded by the
7
+ * singleton instance_settings row (second attempt → 410) and, optionally, a
8
+ * SETUP_TOKEN. On the CLOUD edition setup creates NO workspace (the
9
+ * response's `workspaceId` is null): every cloud workspace is a hub-org
10
+ * projection, so the operator bootstrap mints a verified, break-glass
11
+ * capable USER only (internal/federation.md, user-scoped federation).
12
+ */
13
+ export const setupRequestSchema = z.object({
14
+ instanceName: plainText(1, 120),
15
+ owner: z.object({
16
+ email: z.email(),
17
+ name: plainText(1, 120),
18
+ password: z.string().min(12).max(256)
19
+ }),
20
+ setupToken: z.string().optional()
21
+ });
22
+ export const setupResponseSchema = z.object({
23
+ instanceId: z.string(),
24
+ /** The first workspace (oss); null on cloud — no workspace is created there. */
25
+ workspaceId: z.string().nullable(),
26
+ ownerUserId: z.string()
27
+ });
28
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/schemas/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,YAAY,EAAE,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;IAC/B,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE;QAChB,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;QACvB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;KACtC,CAAC;IACF,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,gFAAgF;IAChF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * CLI cross-tool connect (cloud edition only — internal/federation.md P5):
4
+ *
5
+ * POST /sso/cli-connect — exchange a hub-minted 120 s JWT for an API key
6
+ *
7
+ * The counterpart of the hub's H3 `POST /sso/tool-token`: `antasphere login`
8
+ * mints a hub API key once; the hub exchanges it for a short-lived RS256 JWT
9
+ * (`aud` = THIS instance's resource URL, `purpose: 'sso-connect'`, unique
10
+ * `jti`) PLUS a one-time raw offline-grant refresh token (`hubRefreshToken`,
11
+ * scopes `offline_access account:read` — the HUB mints it, so it carries no
12
+ * `orgs:create`: a CLI connect REPLACES the stored grant, and the person's
13
+ * next workspace creation answers `hub_reauth_required` until they sign in
14
+ * with the browser again), and this endpoint turns the pair
15
+ * into an ordinary USER-scoped local API key — no tool-specific login, and
16
+ * the stored grant drives the same live as-the-user hub org reads as a
17
+ * browser SSO login's. PUBLIC path (the hub JWT IS the credential),
18
+ * rate-limited, jti one-time-use. Registered ONLY on EDITION=cloud; an oss
19
+ * instance answers 404 (the route does not exist there).
20
+ *
21
+ * The response reuses the CLI-auth completion shape (`CliAuthCompleted`) —
22
+ * the tool's read + write scopes, never its export scope, full key
23
+ * shown exactly once; `workspaceId` is null (user-scoped, unpinned).
24
+ */
25
+ export declare const ssoCliConnectSchema: z.ZodObject<{
26
+ token: z.ZodString;
27
+ hubRefreshToken: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strip>;
29
+ export type SsoCliConnect = z.infer<typeof ssoCliConnectSchema>;
30
+ //# sourceMappingURL=sso-connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sso-connect.d.ts","sourceRoot":"","sources":["../../src/schemas/sso-connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,eAAO,MAAM,mBAAmB;;;iBAY9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * CLI cross-tool connect (cloud edition only — internal/federation.md P5):
4
+ *
5
+ * POST /sso/cli-connect — exchange a hub-minted 120 s JWT for an API key
6
+ *
7
+ * The counterpart of the hub's H3 `POST /sso/tool-token`: `antasphere login`
8
+ * mints a hub API key once; the hub exchanges it for a short-lived RS256 JWT
9
+ * (`aud` = THIS instance's resource URL, `purpose: 'sso-connect'`, unique
10
+ * `jti`) PLUS a one-time raw offline-grant refresh token (`hubRefreshToken`,
11
+ * scopes `offline_access account:read` — the HUB mints it, so it carries no
12
+ * `orgs:create`: a CLI connect REPLACES the stored grant, and the person's
13
+ * next workspace creation answers `hub_reauth_required` until they sign in
14
+ * with the browser again), and this endpoint turns the pair
15
+ * into an ordinary USER-scoped local API key — no tool-specific login, and
16
+ * the stored grant drives the same live as-the-user hub org reads as a
17
+ * browser SSO login's. PUBLIC path (the hub JWT IS the credential),
18
+ * rate-limited, jti one-time-use. Registered ONLY on EDITION=cloud; an oss
19
+ * instance answers 404 (the route does not exist there).
20
+ *
21
+ * The response reuses the CLI-auth completion shape (`CliAuthCompleted`) —
22
+ * the tool's read + write scopes, never its export scope, full key
23
+ * shown exactly once; `workspaceId` is null (user-scoped, unpinned).
24
+ */
25
+ export const ssoCliConnectSchema = z.object({
26
+ /** The hub-minted exchange JWT (compact JWS — three base64url segments). */
27
+ token: z.string().min(20).max(4096),
28
+ /**
29
+ * The raw one-time offline-grant refresh token from the SAME H3 response
30
+ * (`hubRefreshToken`). Stored encrypted on the account row — it is what
31
+ * keeps a headless CLI user's org reads LIVE between browser logins.
32
+ * Optional on the wire for older clients, but a connect that carries none
33
+ * is refused unless a prior grant already exists (a key must never be
34
+ * minted born-dead).
35
+ */
36
+ hubRefreshToken: z.string().min(20).max(512).optional()
37
+ });
38
+ //# sourceMappingURL=sso-connect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sso-connect.js","sourceRoot":"","sources":["../../src/schemas/sso-connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,4EAA4E;IAC5E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IACnC;;;;;;;OAOG;IACH,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CACxD,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * POST /api/v1/sso/logout (cloud edition ONLY — oss answers the JSON 404
4
+ * terminator): the single-logout server leg. The server has ALREADY revoked
5
+ * the local session and cleared the shared hint cookie by the time this
6
+ * body arrives; `url` is the hub RP-initiated-logout URL the browser must
7
+ * now VISIT to end the hub anchor session (it lands back on
8
+ * `/login?signed_out=1`). `null` = no hub leg was possible (no stored
9
+ * id_token, a pre-flip sid-less one, hub unreachable) — the client goes to
10
+ * `/login?signed_out=1` directly; the LOCAL signout already happened either
11
+ * way.
12
+ */
13
+ export declare const ssoLogoutResponseSchema: z.ZodObject<{
14
+ url: z.ZodNullable<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ export type SsoLogoutResponse = z.infer<typeof ssoLogoutResponseSchema>;
17
+ //# sourceMappingURL=sso-logout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sso-logout.d.ts","sourceRoot":"","sources":["../../src/schemas/sso-logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB;;iBAElC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * POST /api/v1/sso/logout (cloud edition ONLY — oss answers the JSON 404
4
+ * terminator): the single-logout server leg. The server has ALREADY revoked
5
+ * the local session and cleared the shared hint cookie by the time this
6
+ * body arrives; `url` is the hub RP-initiated-logout URL the browser must
7
+ * now VISIT to end the hub anchor session (it lands back on
8
+ * `/login?signed_out=1`). `null` = no hub leg was possible (no stored
9
+ * id_token, a pre-flip sid-less one, hub unreachable) — the client goes to
10
+ * `/login?signed_out=1` directly; the LOCAL signout already happened either
11
+ * way.
12
+ */
13
+ export const ssoLogoutResponseSchema = z.object({
14
+ url: z.string().nullable()
15
+ });
16
+ //# sourceMappingURL=sso-logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sso-logout.js","sourceRoot":"","sources":["../../src/schemas/sso-logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC3B,CAAC,CAAC"}