@lssm/lib.identity-rbac 0.0.0-canary-20251217083314 → 1.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contracts/index.js +1 -5
- package/dist/contracts/organization.js +1 -607
- package/dist/contracts/rbac.js +1 -487
- package/dist/contracts/user.js +1 -335
- package/dist/entities/index.js +1 -35
- package/dist/entities/organization.js +1 -151
- package/dist/entities/rbac.js +1 -138
- package/dist/entities/user.js +1 -194
- package/dist/events.js +1 -543
- package/dist/identity-rbac.feature.js +1 -186
- package/dist/index.js +1 -14
- package/dist/policies/engine.js +1 -167
- package/dist/policies/index.js +1 -3
- package/package.json +18 -18
- package/dist/contracts/dist/capabilities/openbanking.js +0 -88
- package/dist/contracts/dist/client/index.js +0 -5
- package/dist/contracts/dist/client/react/feature-render.js +0 -2
- package/dist/contracts/dist/client/react/form-render.js +0 -4
- package/dist/contracts/dist/client/react/index.js +0 -4
- package/dist/contracts/dist/contract-registry/index.js +0 -1
- package/dist/contracts/dist/contract-registry/schemas.js +0 -60
- package/dist/contracts/dist/docs/PUBLISHING.docblock.js +0 -16
- package/dist/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +0 -16
- package/dist/contracts/dist/docs/index.js +0 -29
- package/dist/contracts/dist/docs/presentations.js +0 -71
- package/dist/contracts/dist/docs/registry.js +0 -44
- package/dist/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +0 -16
- package/dist/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +0 -16
- package/dist/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +0 -16
- package/dist/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +0 -16
- package/dist/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +0 -16
- package/dist/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +0 -80
- package/dist/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +0 -57
- package/dist/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +0 -16
- package/dist/contracts/dist/docs/tech/llm/llm-integration.docblock.js +0 -357
- package/dist/contracts/dist/docs/tech/mcp-endpoints.docblock.js +0 -37
- package/dist/contracts/dist/docs/tech/presentation-runtime.docblock.js +0 -16
- package/dist/contracts/dist/docs/tech/schema/README.docblock.js +0 -20
- package/dist/contracts/dist/docs/tech/studio/learning-events.docblock.js +0 -48
- package/dist/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +0 -79
- package/dist/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +0 -84
- package/dist/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +0 -45
- package/dist/contracts/dist/docs/tech/studio/project-routing.docblock.js +0 -67
- package/dist/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +0 -40
- package/dist/contracts/dist/docs/tech/studio/team-invitations.docblock.js +0 -69
- package/dist/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +0 -47
- package/dist/contracts/dist/docs/tech/studio/workspaces.docblock.js +0 -62
- package/dist/contracts/dist/docs/tech/telemetry-ingest.docblock.js +0 -155
- package/dist/contracts/dist/docs/tech/templates/runtime.docblock.js +0 -20
- package/dist/contracts/dist/docs/tech/vscode-extension.docblock.js +0 -101
- package/dist/contracts/dist/docs/tech/workflows/overview.docblock.js +0 -20
- package/dist/contracts/dist/events.js +0 -10
- package/dist/contracts/dist/experiments/evaluator.js +0 -1
- package/dist/contracts/dist/index.js +0 -71
- package/dist/contracts/dist/install.js +0 -2
- package/dist/contracts/dist/integrations/contracts.js +0 -377
- package/dist/contracts/dist/integrations/index.js +0 -18
- package/dist/contracts/dist/integrations/openbanking/contracts/accounts.js +0 -228
- package/dist/contracts/dist/integrations/openbanking/contracts/balances.js +0 -159
- package/dist/contracts/dist/integrations/openbanking/contracts/index.js +0 -3
- package/dist/contracts/dist/integrations/openbanking/contracts/transactions.js +0 -210
- package/dist/contracts/dist/integrations/openbanking/models.js +0 -242
- package/dist/contracts/dist/integrations/openbanking/telemetry.js +0 -13
- package/dist/contracts/dist/integrations/providers/elevenlabs.js +0 -52
- package/dist/contracts/dist/integrations/providers/gcs-storage.js +0 -75
- package/dist/contracts/dist/integrations/providers/gmail.js +0 -87
- package/dist/contracts/dist/integrations/providers/google-calendar.js +0 -66
- package/dist/contracts/dist/integrations/providers/index.js +0 -11
- package/dist/contracts/dist/integrations/providers/mistral.js +0 -68
- package/dist/contracts/dist/integrations/providers/postmark.js +0 -68
- package/dist/contracts/dist/integrations/providers/powens.js +0 -116
- package/dist/contracts/dist/integrations/providers/qdrant.js +0 -73
- package/dist/contracts/dist/integrations/providers/registry.js +0 -10
- package/dist/contracts/dist/integrations/providers/stripe.js +0 -83
- package/dist/contracts/dist/integrations/providers/twilio-sms.js +0 -61
- package/dist/contracts/dist/jsonschema.js +0 -1
- package/dist/contracts/dist/knowledge/contracts.js +0 -306
- package/dist/contracts/dist/knowledge/index.js +0 -7
- package/dist/contracts/dist/knowledge/spaces/email-threads.js +0 -34
- package/dist/contracts/dist/knowledge/spaces/financial-docs.js +0 -34
- package/dist/contracts/dist/knowledge/spaces/financial-overview.js +0 -38
- package/dist/contracts/dist/knowledge/spaces/index.js +0 -6
- package/dist/contracts/dist/knowledge/spaces/product-canon.js +0 -34
- package/dist/contracts/dist/knowledge/spaces/support-faq.js +0 -37
- package/dist/contracts/dist/knowledge/spaces/uploaded-docs.js +0 -34
- package/dist/contracts/dist/llm/exporters.js +0 -19
- package/dist/contracts/dist/llm/index.js +0 -2
- package/dist/contracts/dist/llm/prompts.js +0 -1
- package/dist/contracts/dist/onboarding-base.js +0 -196
- package/dist/contracts/dist/openapi.js +0 -1
- package/dist/contracts/dist/ownership.js +0 -21
- package/dist/contracts/dist/presentations.js +0 -1
- package/dist/contracts/dist/presentations.v2.js +0 -11
- package/dist/contracts/dist/prompt.js +0 -1
- package/dist/contracts/dist/promptRegistry.js +0 -1
- package/dist/contracts/dist/regenerator/index.js +0 -1
- package/dist/contracts/dist/regenerator/service.js +0 -6
- package/dist/contracts/dist/registry.js +0 -2
- package/dist/contracts/dist/resources.js +0 -1
- package/dist/contracts/dist/schema/dist/EnumType.js +0 -2
- package/dist/contracts/dist/schema/dist/FieldType.js +0 -49
- package/dist/contracts/dist/schema/dist/ScalarTypeEnum.js +0 -236
- package/dist/contracts/dist/schema/dist/SchemaModel.js +0 -34
- package/dist/contracts/dist/schema/dist/entity/defineEntity.js +0 -1
- package/dist/contracts/dist/schema/dist/entity/index.js +0 -2
- package/dist/contracts/dist/schema/dist/entity/types.js +0 -1
- package/dist/contracts/dist/schema/dist/index.js +0 -6
- package/dist/contracts/dist/server/graphql-pothos.js +0 -6
- package/dist/contracts/dist/server/index.js +0 -8
- package/dist/contracts/dist/server/mcp/createMcpServer.js +0 -4
- package/dist/contracts/dist/server/mcp/registerPresentations.js +0 -2
- package/dist/contracts/dist/server/mcp/registerPrompts.js +0 -1
- package/dist/contracts/dist/server/mcp/registerResources.js +0 -2
- package/dist/contracts/dist/server/mcp/registerTools.js +0 -1
- package/dist/contracts/dist/server/provider-mcp.js +0 -1
- package/dist/contracts/dist/server/rest-elysia.js +0 -1
- package/dist/contracts/dist/server/rest-express.js +0 -1
- package/dist/contracts/dist/server/rest-generic.js +0 -1
- package/dist/contracts/dist/server/rest-next-app.js +0 -1
- package/dist/contracts/dist/server/rest-next-pages.js +0 -1
- package/dist/contracts/dist/spec.js +0 -34
- package/dist/contracts/dist/telemetry/index.js +0 -1
- package/dist/contracts/dist/telemetry/tracker.js +0 -1
- package/dist/contracts/dist/tests/index.js +0 -1
- package/dist/contracts/dist/tests/runner.js +0 -2
- package/dist/contracts/dist/workflow/index.js +0 -1
- package/dist/contracts/dist/workflow/runner.js +0 -1
- package/dist/contracts/index.d.ts +0 -4
- package/dist/contracts/organization.d.ts +0 -895
- package/dist/contracts/rbac.d.ts +0 -611
- package/dist/contracts/user.d.ts +0 -610
- package/dist/entities/index.d.ts +0 -176
- package/dist/entities/organization.d.ts +0 -86
- package/dist/entities/rbac.d.ts +0 -87
- package/dist/entities/user.d.ts +0 -87
- package/dist/events.d.ts +0 -689
- package/dist/identity-rbac.feature.d.ts +0 -11
- package/dist/index.d.ts +0 -11
- package/dist/policies/engine.d.ts +0 -132
- package/dist/policies/index.d.ts +0 -2
- package/dist/schema/dist/EnumType.js +0 -2
- package/dist/schema/dist/FieldType.js +0 -49
- package/dist/schema/dist/ScalarTypeEnum.js +0 -236
- package/dist/schema/dist/SchemaModel.js +0 -34
- package/dist/schema/dist/entity/defineEntity.js +0 -236
- package/dist/schema/dist/entity/index.js +0 -2
- package/dist/schema/dist/entity/types.js +0 -1
- package/dist/schema/dist/index.js +0 -6
package/dist/contracts/user.js
CHANGED
|
@@ -1,335 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SchemaModel } from "../schema/dist/SchemaModel.js";
|
|
3
|
-
import "../schema/dist/index.js";
|
|
4
|
-
import { defineCommand, defineQuery } from "./dist/spec.js";
|
|
5
|
-
import "./dist/index.js";
|
|
6
|
-
|
|
7
|
-
//#region src/contracts/user.ts
|
|
8
|
-
const OWNERS = ["platform.identity-rbac"];
|
|
9
|
-
const UserProfileModel = new SchemaModel({
|
|
10
|
-
name: "UserProfile",
|
|
11
|
-
description: "User profile information",
|
|
12
|
-
fields: {
|
|
13
|
-
id: {
|
|
14
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
15
|
-
isOptional: false
|
|
16
|
-
},
|
|
17
|
-
email: {
|
|
18
|
-
type: ScalarTypeEnum.EmailAddress(),
|
|
19
|
-
isOptional: false
|
|
20
|
-
},
|
|
21
|
-
emailVerified: {
|
|
22
|
-
type: ScalarTypeEnum.Boolean(),
|
|
23
|
-
isOptional: false
|
|
24
|
-
},
|
|
25
|
-
name: {
|
|
26
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
27
|
-
isOptional: true
|
|
28
|
-
},
|
|
29
|
-
firstName: {
|
|
30
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
31
|
-
isOptional: true
|
|
32
|
-
},
|
|
33
|
-
lastName: {
|
|
34
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
35
|
-
isOptional: true
|
|
36
|
-
},
|
|
37
|
-
locale: {
|
|
38
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
39
|
-
isOptional: true
|
|
40
|
-
},
|
|
41
|
-
timezone: {
|
|
42
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
43
|
-
isOptional: true
|
|
44
|
-
},
|
|
45
|
-
imageUrl: {
|
|
46
|
-
type: ScalarTypeEnum.URL(),
|
|
47
|
-
isOptional: true
|
|
48
|
-
},
|
|
49
|
-
role: {
|
|
50
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
51
|
-
isOptional: true
|
|
52
|
-
},
|
|
53
|
-
onboardingCompleted: {
|
|
54
|
-
type: ScalarTypeEnum.Boolean(),
|
|
55
|
-
isOptional: false
|
|
56
|
-
},
|
|
57
|
-
createdAt: {
|
|
58
|
-
type: ScalarTypeEnum.DateTime(),
|
|
59
|
-
isOptional: false
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
const CreateUserInputModel = new SchemaModel({
|
|
64
|
-
name: "CreateUserInput",
|
|
65
|
-
description: "Input for creating a new user",
|
|
66
|
-
fields: {
|
|
67
|
-
email: {
|
|
68
|
-
type: ScalarTypeEnum.EmailAddress(),
|
|
69
|
-
isOptional: false
|
|
70
|
-
},
|
|
71
|
-
name: {
|
|
72
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
73
|
-
isOptional: true
|
|
74
|
-
},
|
|
75
|
-
firstName: {
|
|
76
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
77
|
-
isOptional: true
|
|
78
|
-
},
|
|
79
|
-
lastName: {
|
|
80
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
81
|
-
isOptional: true
|
|
82
|
-
},
|
|
83
|
-
password: {
|
|
84
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
85
|
-
isOptional: true
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
const UpdateUserInputModel = new SchemaModel({
|
|
90
|
-
name: "UpdateUserInput",
|
|
91
|
-
description: "Input for updating a user profile",
|
|
92
|
-
fields: {
|
|
93
|
-
name: {
|
|
94
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
95
|
-
isOptional: true
|
|
96
|
-
},
|
|
97
|
-
firstName: {
|
|
98
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
99
|
-
isOptional: true
|
|
100
|
-
},
|
|
101
|
-
lastName: {
|
|
102
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
103
|
-
isOptional: true
|
|
104
|
-
},
|
|
105
|
-
locale: {
|
|
106
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
107
|
-
isOptional: true
|
|
108
|
-
},
|
|
109
|
-
timezone: {
|
|
110
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
111
|
-
isOptional: true
|
|
112
|
-
},
|
|
113
|
-
imageUrl: {
|
|
114
|
-
type: ScalarTypeEnum.URL(),
|
|
115
|
-
isOptional: true
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
const DeleteUserInputModel = new SchemaModel({
|
|
120
|
-
name: "DeleteUserInput",
|
|
121
|
-
description: "Input for deleting a user",
|
|
122
|
-
fields: { confirmEmail: {
|
|
123
|
-
type: ScalarTypeEnum.EmailAddress(),
|
|
124
|
-
isOptional: false
|
|
125
|
-
} }
|
|
126
|
-
});
|
|
127
|
-
const SuccessResultModel = new SchemaModel({
|
|
128
|
-
name: "SuccessResult",
|
|
129
|
-
description: "Simple success result",
|
|
130
|
-
fields: { success: {
|
|
131
|
-
type: ScalarTypeEnum.Boolean(),
|
|
132
|
-
isOptional: false
|
|
133
|
-
} }
|
|
134
|
-
});
|
|
135
|
-
const UserDeletedPayloadModel = new SchemaModel({
|
|
136
|
-
name: "UserDeletedPayload",
|
|
137
|
-
description: "Payload for user deleted event",
|
|
138
|
-
fields: { userId: {
|
|
139
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
140
|
-
isOptional: false
|
|
141
|
-
} }
|
|
142
|
-
});
|
|
143
|
-
const ListUsersInputModel = new SchemaModel({
|
|
144
|
-
name: "ListUsersInput",
|
|
145
|
-
description: "Input for listing users",
|
|
146
|
-
fields: {
|
|
147
|
-
limit: {
|
|
148
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
149
|
-
isOptional: true
|
|
150
|
-
},
|
|
151
|
-
offset: {
|
|
152
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
153
|
-
isOptional: true
|
|
154
|
-
},
|
|
155
|
-
search: {
|
|
156
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
157
|
-
isOptional: true
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
const ListUsersOutputModel = new SchemaModel({
|
|
162
|
-
name: "ListUsersOutput",
|
|
163
|
-
description: "Output for listing users",
|
|
164
|
-
fields: {
|
|
165
|
-
users: {
|
|
166
|
-
type: UserProfileModel,
|
|
167
|
-
isOptional: false,
|
|
168
|
-
isArray: true
|
|
169
|
-
},
|
|
170
|
-
total: {
|
|
171
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
172
|
-
isOptional: false
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
/**
|
|
177
|
-
* Create a new user account.
|
|
178
|
-
*/
|
|
179
|
-
const CreateUserContract = defineCommand({
|
|
180
|
-
meta: {
|
|
181
|
-
name: "identity.user.create",
|
|
182
|
-
version: 1,
|
|
183
|
-
stability: "stable",
|
|
184
|
-
owners: [...OWNERS],
|
|
185
|
-
tags: [
|
|
186
|
-
"identity",
|
|
187
|
-
"user",
|
|
188
|
-
"create"
|
|
189
|
-
],
|
|
190
|
-
description: "Create a new user account.",
|
|
191
|
-
goal: "Register a new user in the system.",
|
|
192
|
-
context: "Used during signup flows. May trigger email verification."
|
|
193
|
-
},
|
|
194
|
-
io: {
|
|
195
|
-
input: CreateUserInputModel,
|
|
196
|
-
output: UserProfileModel,
|
|
197
|
-
errors: { EMAIL_EXISTS: {
|
|
198
|
-
description: "A user with this email already exists",
|
|
199
|
-
http: 409,
|
|
200
|
-
gqlCode: "EMAIL_EXISTS",
|
|
201
|
-
when: "Email is already registered"
|
|
202
|
-
} }
|
|
203
|
-
},
|
|
204
|
-
policy: { auth: "anonymous" },
|
|
205
|
-
sideEffects: {
|
|
206
|
-
emits: [{
|
|
207
|
-
name: "user.created",
|
|
208
|
-
version: 1,
|
|
209
|
-
when: "User is successfully created",
|
|
210
|
-
payload: UserProfileModel
|
|
211
|
-
}],
|
|
212
|
-
audit: ["user.created"]
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
/**
|
|
216
|
-
* Get the current user's profile.
|
|
217
|
-
*/
|
|
218
|
-
const GetCurrentUserContract = defineQuery({
|
|
219
|
-
meta: {
|
|
220
|
-
name: "identity.user.me",
|
|
221
|
-
version: 1,
|
|
222
|
-
stability: "stable",
|
|
223
|
-
owners: [...OWNERS],
|
|
224
|
-
tags: [
|
|
225
|
-
"identity",
|
|
226
|
-
"user",
|
|
227
|
-
"profile"
|
|
228
|
-
],
|
|
229
|
-
description: "Get the current authenticated user profile.",
|
|
230
|
-
goal: "Retrieve user profile for the authenticated session.",
|
|
231
|
-
context: "Called on app load and after profile updates."
|
|
232
|
-
},
|
|
233
|
-
io: {
|
|
234
|
-
input: null,
|
|
235
|
-
output: UserProfileModel
|
|
236
|
-
},
|
|
237
|
-
policy: { auth: "user" }
|
|
238
|
-
});
|
|
239
|
-
/**
|
|
240
|
-
* Update user profile.
|
|
241
|
-
*/
|
|
242
|
-
const UpdateUserContract = defineCommand({
|
|
243
|
-
meta: {
|
|
244
|
-
name: "identity.user.update",
|
|
245
|
-
version: 1,
|
|
246
|
-
stability: "stable",
|
|
247
|
-
owners: [...OWNERS],
|
|
248
|
-
tags: [
|
|
249
|
-
"identity",
|
|
250
|
-
"user",
|
|
251
|
-
"update"
|
|
252
|
-
],
|
|
253
|
-
description: "Update user profile information.",
|
|
254
|
-
goal: "Allow users to update their profile.",
|
|
255
|
-
context: "Self-service profile updates."
|
|
256
|
-
},
|
|
257
|
-
io: {
|
|
258
|
-
input: UpdateUserInputModel,
|
|
259
|
-
output: UserProfileModel
|
|
260
|
-
},
|
|
261
|
-
policy: { auth: "user" },
|
|
262
|
-
sideEffects: {
|
|
263
|
-
emits: [{
|
|
264
|
-
name: "user.updated",
|
|
265
|
-
version: 1,
|
|
266
|
-
when: "User profile is updated",
|
|
267
|
-
payload: UserProfileModel
|
|
268
|
-
}],
|
|
269
|
-
audit: ["user.updated"]
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
/**
|
|
273
|
-
* Delete user account.
|
|
274
|
-
*/
|
|
275
|
-
const DeleteUserContract = defineCommand({
|
|
276
|
-
meta: {
|
|
277
|
-
name: "identity.user.delete",
|
|
278
|
-
version: 1,
|
|
279
|
-
stability: "stable",
|
|
280
|
-
owners: [...OWNERS],
|
|
281
|
-
tags: [
|
|
282
|
-
"identity",
|
|
283
|
-
"user",
|
|
284
|
-
"delete"
|
|
285
|
-
],
|
|
286
|
-
description: "Delete user account and all associated data.",
|
|
287
|
-
goal: "Allow users to delete their account (GDPR compliance).",
|
|
288
|
-
context: "Self-service account deletion. Cascades to memberships, sessions, etc."
|
|
289
|
-
},
|
|
290
|
-
io: {
|
|
291
|
-
input: DeleteUserInputModel,
|
|
292
|
-
output: SuccessResultModel
|
|
293
|
-
},
|
|
294
|
-
policy: {
|
|
295
|
-
auth: "user",
|
|
296
|
-
escalate: "human_review"
|
|
297
|
-
},
|
|
298
|
-
sideEffects: {
|
|
299
|
-
emits: [{
|
|
300
|
-
name: "user.deleted",
|
|
301
|
-
version: 1,
|
|
302
|
-
when: "User account is deleted",
|
|
303
|
-
payload: UserDeletedPayloadModel
|
|
304
|
-
}],
|
|
305
|
-
audit: ["user.deleted"]
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
/**
|
|
309
|
-
* List users (admin only).
|
|
310
|
-
*/
|
|
311
|
-
const ListUsersContract = defineQuery({
|
|
312
|
-
meta: {
|
|
313
|
-
name: "identity.user.list",
|
|
314
|
-
version: 1,
|
|
315
|
-
stability: "stable",
|
|
316
|
-
owners: [...OWNERS],
|
|
317
|
-
tags: [
|
|
318
|
-
"identity",
|
|
319
|
-
"user",
|
|
320
|
-
"admin",
|
|
321
|
-
"list"
|
|
322
|
-
],
|
|
323
|
-
description: "List all users (admin only).",
|
|
324
|
-
goal: "Allow admins to browse and manage users.",
|
|
325
|
-
context: "Admin dashboard user management."
|
|
326
|
-
},
|
|
327
|
-
io: {
|
|
328
|
-
input: ListUsersInputModel,
|
|
329
|
-
output: ListUsersOutputModel
|
|
330
|
-
},
|
|
331
|
-
policy: { auth: "admin" }
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
//#endregion
|
|
335
|
-
export { CreateUserContract, CreateUserInputModel, DeleteUserContract, DeleteUserInputModel, GetCurrentUserContract, ListUsersContract, ListUsersInputModel, ListUsersOutputModel, SuccessResultModel, UpdateUserContract, UpdateUserInputModel, UserDeletedPayloadModel, UserProfileModel };
|
|
1
|
+
import{ScalarTypeEnum as e,SchemaModel as t}from"@lssm/lib.schema";import{defineCommand as n,defineQuery as r}from"@lssm/lib.contracts";const i=[`platform.identity-rbac`],a=new t({name:`UserProfile`,description:`User profile information`,fields:{id:{type:e.String_unsecure(),isOptional:!1},email:{type:e.EmailAddress(),isOptional:!1},emailVerified:{type:e.Boolean(),isOptional:!1},name:{type:e.String_unsecure(),isOptional:!0},firstName:{type:e.String_unsecure(),isOptional:!0},lastName:{type:e.String_unsecure(),isOptional:!0},locale:{type:e.String_unsecure(),isOptional:!0},timezone:{type:e.String_unsecure(),isOptional:!0},imageUrl:{type:e.URL(),isOptional:!0},role:{type:e.String_unsecure(),isOptional:!0},onboardingCompleted:{type:e.Boolean(),isOptional:!1},createdAt:{type:e.DateTime(),isOptional:!1}}}),o=new t({name:`CreateUserInput`,description:`Input for creating a new user`,fields:{email:{type:e.EmailAddress(),isOptional:!1},name:{type:e.String_unsecure(),isOptional:!0},firstName:{type:e.String_unsecure(),isOptional:!0},lastName:{type:e.String_unsecure(),isOptional:!0},password:{type:e.String_unsecure(),isOptional:!0}}}),s=new t({name:`UpdateUserInput`,description:`Input for updating a user profile`,fields:{name:{type:e.String_unsecure(),isOptional:!0},firstName:{type:e.String_unsecure(),isOptional:!0},lastName:{type:e.String_unsecure(),isOptional:!0},locale:{type:e.String_unsecure(),isOptional:!0},timezone:{type:e.String_unsecure(),isOptional:!0},imageUrl:{type:e.URL(),isOptional:!0}}}),c=new t({name:`DeleteUserInput`,description:`Input for deleting a user`,fields:{confirmEmail:{type:e.EmailAddress(),isOptional:!1}}}),l=new t({name:`SuccessResult`,description:`Simple success result`,fields:{success:{type:e.Boolean(),isOptional:!1}}}),u=new t({name:`UserDeletedPayload`,description:`Payload for user deleted event`,fields:{userId:{type:e.String_unsecure(),isOptional:!1}}}),d=new t({name:`ListUsersInput`,description:`Input for listing users`,fields:{limit:{type:e.Int_unsecure(),isOptional:!0},offset:{type:e.Int_unsecure(),isOptional:!0},search:{type:e.String_unsecure(),isOptional:!0}}}),f=new t({name:`ListUsersOutput`,description:`Output for listing users`,fields:{users:{type:a,isOptional:!1,isArray:!0},total:{type:e.Int_unsecure(),isOptional:!1}}}),p=n({meta:{name:`identity.user.create`,version:1,stability:`stable`,owners:[...i],tags:[`identity`,`user`,`create`],description:`Create a new user account.`,goal:`Register a new user in the system.`,context:`Used during signup flows. May trigger email verification.`},io:{input:o,output:a,errors:{EMAIL_EXISTS:{description:`A user with this email already exists`,http:409,gqlCode:`EMAIL_EXISTS`,when:`Email is already registered`}}},policy:{auth:`anonymous`},sideEffects:{emits:[{name:`user.created`,version:1,when:`User is successfully created`,payload:a}],audit:[`user.created`]}}),m=r({meta:{name:`identity.user.me`,version:1,stability:`stable`,owners:[...i],tags:[`identity`,`user`,`profile`],description:`Get the current authenticated user profile.`,goal:`Retrieve user profile for the authenticated session.`,context:`Called on app load and after profile updates.`},io:{input:null,output:a},policy:{auth:`user`}}),h=n({meta:{name:`identity.user.update`,version:1,stability:`stable`,owners:[...i],tags:[`identity`,`user`,`update`],description:`Update user profile information.`,goal:`Allow users to update their profile.`,context:`Self-service profile updates.`},io:{input:s,output:a},policy:{auth:`user`},sideEffects:{emits:[{name:`user.updated`,version:1,when:`User profile is updated`,payload:a}],audit:[`user.updated`]}}),g=n({meta:{name:`identity.user.delete`,version:1,stability:`stable`,owners:[...i],tags:[`identity`,`user`,`delete`],description:`Delete user account and all associated data.`,goal:`Allow users to delete their account (GDPR compliance).`,context:`Self-service account deletion. Cascades to memberships, sessions, etc.`},io:{input:c,output:l},policy:{auth:`user`,escalate:`human_review`},sideEffects:{emits:[{name:`user.deleted`,version:1,when:`User account is deleted`,payload:u}],audit:[`user.deleted`]}}),_=r({meta:{name:`identity.user.list`,version:1,stability:`stable`,owners:[...i],tags:[`identity`,`user`,`admin`,`list`],description:`List all users (admin only).`,goal:`Allow admins to browse and manage users.`,context:`Admin dashboard user management.`},io:{input:d,output:f},policy:{auth:`admin`}});export{p as CreateUserContract,o as CreateUserInputModel,g as DeleteUserContract,c as DeleteUserInputModel,m as GetCurrentUserContract,_ as ListUsersContract,d as ListUsersInputModel,f as ListUsersOutputModel,l as SuccessResultModel,h as UpdateUserContract,s as UpdateUserInputModel,u as UserDeletedPayloadModel,a as UserProfileModel};
|
package/dist/entities/index.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { InvitationEntity, MemberEntity, OrganizationEntity, OrganizationTypeEnum, TeamEntity, TeamMemberEntity } from "./organization.js";
|
|
3
|
-
import { ApiKeyEntity, PasskeyEntity, PermissionEntity, PolicyBindingEntity, RoleEntity } from "./rbac.js";
|
|
4
|
-
|
|
5
|
-
//#region src/entities/index.ts
|
|
6
|
-
/**
|
|
7
|
-
* All identity-rbac entities for schema composition.
|
|
8
|
-
*/
|
|
9
|
-
const identityRbacEntities = [
|
|
10
|
-
UserEntity,
|
|
11
|
-
SessionEntity,
|
|
12
|
-
AccountEntity,
|
|
13
|
-
VerificationEntity,
|
|
14
|
-
OrganizationEntity,
|
|
15
|
-
MemberEntity,
|
|
16
|
-
InvitationEntity,
|
|
17
|
-
TeamEntity,
|
|
18
|
-
TeamMemberEntity,
|
|
19
|
-
RoleEntity,
|
|
20
|
-
PermissionEntity,
|
|
21
|
-
PolicyBindingEntity,
|
|
22
|
-
ApiKeyEntity,
|
|
23
|
-
PasskeyEntity
|
|
24
|
-
];
|
|
25
|
-
/**
|
|
26
|
-
* Module schema contribution for identity-rbac.
|
|
27
|
-
*/
|
|
28
|
-
const identityRbacSchemaContribution = {
|
|
29
|
-
moduleId: "@lssm/lib.identity-rbac",
|
|
30
|
-
entities: identityRbacEntities,
|
|
31
|
-
enums: [OrganizationTypeEnum]
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { AccountEntity, ApiKeyEntity, InvitationEntity, MemberEntity, OrganizationEntity, OrganizationTypeEnum, PasskeyEntity, PermissionEntity, PolicyBindingEntity, RoleEntity, SessionEntity, TeamEntity, TeamMemberEntity, UserEntity, VerificationEntity, identityRbacEntities, identityRbacSchemaContribution };
|
|
1
|
+
import{AccountEntity as e,SessionEntity as t,UserEntity as n,VerificationEntity as r}from"./user.js";import{InvitationEntity as i,MemberEntity as a,OrganizationEntity as o,OrganizationTypeEnum as s,TeamEntity as c,TeamMemberEntity as l}from"./organization.js";import{ApiKeyEntity as u,PasskeyEntity as d,PermissionEntity as f,PolicyBindingEntity as p,RoleEntity as m}from"./rbac.js";const h=[n,t,e,r,o,a,i,c,l,m,f,p,u,d],g={moduleId:`@lssm/lib.identity-rbac`,entities:h,enums:[s]};export{e as AccountEntity,u as ApiKeyEntity,i as InvitationEntity,a as MemberEntity,o as OrganizationEntity,s as OrganizationTypeEnum,d as PasskeyEntity,f as PermissionEntity,p as PolicyBindingEntity,m as RoleEntity,t as SessionEntity,c as TeamEntity,l as TeamMemberEntity,n as UserEntity,r as VerificationEntity,h as identityRbacEntities,g as identityRbacSchemaContribution};
|
|
@@ -1,151 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../schema/dist/index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/entities/organization.ts
|
|
5
|
-
/**
|
|
6
|
-
* Organization type enum.
|
|
7
|
-
*/
|
|
8
|
-
const OrganizationTypeEnum = defineEntityEnum({
|
|
9
|
-
name: "OrganizationType",
|
|
10
|
-
values: ["PLATFORM_ADMIN", "CONTRACT_SPEC_CUSTOMER"],
|
|
11
|
-
schema: "lssm_sigil",
|
|
12
|
-
description: "Type of organization in the platform."
|
|
13
|
-
});
|
|
14
|
-
/**
|
|
15
|
-
* Organization entity - tenant/company grouping.
|
|
16
|
-
*/
|
|
17
|
-
const OrganizationEntity = defineEntity({
|
|
18
|
-
name: "Organization",
|
|
19
|
-
description: "An organization is a tenant boundary grouping users.",
|
|
20
|
-
schema: "lssm_sigil",
|
|
21
|
-
map: "organization",
|
|
22
|
-
fields: {
|
|
23
|
-
id: field.id({ description: "Unique organization identifier" }),
|
|
24
|
-
name: field.string({ description: "Organization display name" }),
|
|
25
|
-
slug: field.string({
|
|
26
|
-
isOptional: true,
|
|
27
|
-
isUnique: true,
|
|
28
|
-
description: "URL-friendly identifier"
|
|
29
|
-
}),
|
|
30
|
-
logo: field.url({
|
|
31
|
-
isOptional: true,
|
|
32
|
-
description: "Organization logo URL"
|
|
33
|
-
}),
|
|
34
|
-
description: field.string({
|
|
35
|
-
isOptional: true,
|
|
36
|
-
description: "Organization description"
|
|
37
|
-
}),
|
|
38
|
-
metadata: field.json({
|
|
39
|
-
isOptional: true,
|
|
40
|
-
description: "Arbitrary organization metadata"
|
|
41
|
-
}),
|
|
42
|
-
type: field.enum("OrganizationType", { description: "Organization type" }),
|
|
43
|
-
onboardingCompleted: field.boolean({ default: false }),
|
|
44
|
-
onboardingStep: field.string({ isOptional: true }),
|
|
45
|
-
referralCode: field.string({
|
|
46
|
-
isOptional: true,
|
|
47
|
-
isUnique: true,
|
|
48
|
-
description: "Unique referral code"
|
|
49
|
-
}),
|
|
50
|
-
referredBy: field.string({
|
|
51
|
-
isOptional: true,
|
|
52
|
-
description: "ID of referring user"
|
|
53
|
-
}),
|
|
54
|
-
createdAt: field.createdAt(),
|
|
55
|
-
updatedAt: field.updatedAt(),
|
|
56
|
-
members: field.hasMany("Member"),
|
|
57
|
-
invitations: field.hasMany("Invitation"),
|
|
58
|
-
teams: field.hasMany("Team"),
|
|
59
|
-
policyBindings: field.hasMany("PolicyBinding")
|
|
60
|
-
},
|
|
61
|
-
enums: [OrganizationTypeEnum]
|
|
62
|
-
});
|
|
63
|
-
/**
|
|
64
|
-
* Member entity - user membership in an organization.
|
|
65
|
-
*/
|
|
66
|
-
const MemberEntity = defineEntity({
|
|
67
|
-
name: "Member",
|
|
68
|
-
description: "Membership of a user in an organization with a role.",
|
|
69
|
-
schema: "lssm_sigil",
|
|
70
|
-
map: "member",
|
|
71
|
-
fields: {
|
|
72
|
-
id: field.id(),
|
|
73
|
-
userId: field.foreignKey(),
|
|
74
|
-
organizationId: field.foreignKey(),
|
|
75
|
-
role: field.string({ description: "Role in organization (owner, admin, member)" }),
|
|
76
|
-
createdAt: field.createdAt(),
|
|
77
|
-
user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" }),
|
|
78
|
-
organization: field.belongsTo("Organization", ["organizationId"], ["id"], { onDelete: "Cascade" })
|
|
79
|
-
},
|
|
80
|
-
indexes: [index.unique(["userId", "organizationId"])]
|
|
81
|
-
});
|
|
82
|
-
/**
|
|
83
|
-
* Invitation entity - pending organization invites.
|
|
84
|
-
*/
|
|
85
|
-
const InvitationEntity = defineEntity({
|
|
86
|
-
name: "Invitation",
|
|
87
|
-
description: "An invitation to join an organization.",
|
|
88
|
-
schema: "lssm_sigil",
|
|
89
|
-
map: "invitation",
|
|
90
|
-
fields: {
|
|
91
|
-
id: field.id(),
|
|
92
|
-
organizationId: field.foreignKey(),
|
|
93
|
-
email: field.email({ description: "Invited email address" }),
|
|
94
|
-
role: field.string({
|
|
95
|
-
isOptional: true,
|
|
96
|
-
description: "Role to assign on acceptance"
|
|
97
|
-
}),
|
|
98
|
-
status: field.string({
|
|
99
|
-
default: "\"pending\"",
|
|
100
|
-
description: "Invitation status"
|
|
101
|
-
}),
|
|
102
|
-
acceptedAt: field.dateTime({ isOptional: true }),
|
|
103
|
-
expiresAt: field.dateTime({ isOptional: true }),
|
|
104
|
-
inviterId: field.foreignKey({ description: "User who sent the invitation" }),
|
|
105
|
-
teamId: field.string({ isOptional: true }),
|
|
106
|
-
createdAt: field.createdAt(),
|
|
107
|
-
updatedAt: field.updatedAt(),
|
|
108
|
-
organization: field.belongsTo("Organization", ["organizationId"], ["id"], { onDelete: "Cascade" }),
|
|
109
|
-
inviter: field.belongsTo("User", ["inviterId"], ["id"], { onDelete: "Cascade" }),
|
|
110
|
-
team: field.belongsTo("Team", ["teamId"], ["id"], { onDelete: "Cascade" })
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
/**
|
|
114
|
-
* Team entity - team within an organization.
|
|
115
|
-
*/
|
|
116
|
-
const TeamEntity = defineEntity({
|
|
117
|
-
name: "Team",
|
|
118
|
-
description: "Team within an organization.",
|
|
119
|
-
schema: "lssm_sigil",
|
|
120
|
-
map: "team",
|
|
121
|
-
fields: {
|
|
122
|
-
id: field.id(),
|
|
123
|
-
name: field.string({ description: "Team name" }),
|
|
124
|
-
organizationId: field.foreignKey(),
|
|
125
|
-
createdAt: field.createdAt(),
|
|
126
|
-
updatedAt: field.updatedAt(),
|
|
127
|
-
organization: field.belongsTo("Organization", ["organizationId"], ["id"], { onDelete: "Cascade" }),
|
|
128
|
-
members: field.hasMany("TeamMember"),
|
|
129
|
-
invitations: field.hasMany("Invitation")
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
/**
|
|
133
|
-
* TeamMember entity - user's team membership.
|
|
134
|
-
*/
|
|
135
|
-
const TeamMemberEntity = defineEntity({
|
|
136
|
-
name: "TeamMember",
|
|
137
|
-
description: "Team membership for a user.",
|
|
138
|
-
schema: "lssm_sigil",
|
|
139
|
-
map: "team_member",
|
|
140
|
-
fields: {
|
|
141
|
-
id: field.id(),
|
|
142
|
-
teamId: field.foreignKey(),
|
|
143
|
-
userId: field.foreignKey(),
|
|
144
|
-
createdAt: field.createdAt(),
|
|
145
|
-
team: field.belongsTo("Team", ["teamId"], ["id"], { onDelete: "Cascade" }),
|
|
146
|
-
user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
//#endregion
|
|
151
|
-
export { InvitationEntity, MemberEntity, OrganizationEntity, OrganizationTypeEnum, TeamEntity, TeamMemberEntity };
|
|
1
|
+
import{defineEntity as e,defineEntityEnum as t,field as n,index as r}from"@lssm/lib.schema";const i=t({name:`OrganizationType`,values:[`PLATFORM_ADMIN`,`CONTRACT_SPEC_CUSTOMER`],schema:`lssm_sigil`,description:`Type of organization in the platform.`}),a=e({name:`Organization`,description:`An organization is a tenant boundary grouping users.`,schema:`lssm_sigil`,map:`organization`,fields:{id:n.id({description:`Unique organization identifier`}),name:n.string({description:`Organization display name`}),slug:n.string({isOptional:!0,isUnique:!0,description:`URL-friendly identifier`}),logo:n.url({isOptional:!0,description:`Organization logo URL`}),description:n.string({isOptional:!0,description:`Organization description`}),metadata:n.json({isOptional:!0,description:`Arbitrary organization metadata`}),type:n.enum(`OrganizationType`,{description:`Organization type`}),onboardingCompleted:n.boolean({default:!1}),onboardingStep:n.string({isOptional:!0}),referralCode:n.string({isOptional:!0,isUnique:!0,description:`Unique referral code`}),referredBy:n.string({isOptional:!0,description:`ID of referring user`}),createdAt:n.createdAt(),updatedAt:n.updatedAt(),members:n.hasMany(`Member`),invitations:n.hasMany(`Invitation`),teams:n.hasMany(`Team`),policyBindings:n.hasMany(`PolicyBinding`)},enums:[i]}),o=e({name:`Member`,description:`Membership of a user in an organization with a role.`,schema:`lssm_sigil`,map:`member`,fields:{id:n.id(),userId:n.foreignKey(),organizationId:n.foreignKey(),role:n.string({description:`Role in organization (owner, admin, member)`}),createdAt:n.createdAt(),user:n.belongsTo(`User`,[`userId`],[`id`],{onDelete:`Cascade`}),organization:n.belongsTo(`Organization`,[`organizationId`],[`id`],{onDelete:`Cascade`})},indexes:[r.unique([`userId`,`organizationId`])]}),s=e({name:`Invitation`,description:`An invitation to join an organization.`,schema:`lssm_sigil`,map:`invitation`,fields:{id:n.id(),organizationId:n.foreignKey(),email:n.email({description:`Invited email address`}),role:n.string({isOptional:!0,description:`Role to assign on acceptance`}),status:n.string({default:`"pending"`,description:`Invitation status`}),acceptedAt:n.dateTime({isOptional:!0}),expiresAt:n.dateTime({isOptional:!0}),inviterId:n.foreignKey({description:`User who sent the invitation`}),teamId:n.string({isOptional:!0}),createdAt:n.createdAt(),updatedAt:n.updatedAt(),organization:n.belongsTo(`Organization`,[`organizationId`],[`id`],{onDelete:`Cascade`}),inviter:n.belongsTo(`User`,[`inviterId`],[`id`],{onDelete:`Cascade`}),team:n.belongsTo(`Team`,[`teamId`],[`id`],{onDelete:`Cascade`})}}),c=e({name:`Team`,description:`Team within an organization.`,schema:`lssm_sigil`,map:`team`,fields:{id:n.id(),name:n.string({description:`Team name`}),organizationId:n.foreignKey(),createdAt:n.createdAt(),updatedAt:n.updatedAt(),organization:n.belongsTo(`Organization`,[`organizationId`],[`id`],{onDelete:`Cascade`}),members:n.hasMany(`TeamMember`),invitations:n.hasMany(`Invitation`)}}),l=e({name:`TeamMember`,description:`Team membership for a user.`,schema:`lssm_sigil`,map:`team_member`,fields:{id:n.id(),teamId:n.foreignKey(),userId:n.foreignKey(),createdAt:n.createdAt(),team:n.belongsTo(`Team`,[`teamId`],[`id`],{onDelete:`Cascade`}),user:n.belongsTo(`User`,[`userId`],[`id`],{onDelete:`Cascade`})}});export{s as InvitationEntity,o as MemberEntity,a as OrganizationEntity,i as OrganizationTypeEnum,c as TeamEntity,l as TeamMemberEntity};
|
package/dist/entities/rbac.js
CHANGED
|
@@ -1,138 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../schema/dist/index.js";
|
|
3
|
-
|
|
4
|
-
//#region src/entities/rbac.ts
|
|
5
|
-
/**
|
|
6
|
-
* Role entity - named set of permissions.
|
|
7
|
-
*/
|
|
8
|
-
const RoleEntity = defineEntity({
|
|
9
|
-
name: "Role",
|
|
10
|
-
description: "A role defines a named set of permissions.",
|
|
11
|
-
schema: "lssm_sigil",
|
|
12
|
-
map: "role",
|
|
13
|
-
fields: {
|
|
14
|
-
id: field.id(),
|
|
15
|
-
name: field.string({
|
|
16
|
-
isUnique: true,
|
|
17
|
-
description: "Unique role name"
|
|
18
|
-
}),
|
|
19
|
-
description: field.string({
|
|
20
|
-
isOptional: true,
|
|
21
|
-
description: "Role description"
|
|
22
|
-
}),
|
|
23
|
-
permissions: field.string({
|
|
24
|
-
isArray: true,
|
|
25
|
-
description: "Array of permission names"
|
|
26
|
-
}),
|
|
27
|
-
createdAt: field.createdAt(),
|
|
28
|
-
updatedAt: field.updatedAt(),
|
|
29
|
-
policyBindings: field.hasMany("PolicyBinding")
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
/**
|
|
33
|
-
* Permission entity - atomic access right.
|
|
34
|
-
*/
|
|
35
|
-
const PermissionEntity = defineEntity({
|
|
36
|
-
name: "Permission",
|
|
37
|
-
description: "A permission represents an atomic access right.",
|
|
38
|
-
schema: "lssm_sigil",
|
|
39
|
-
map: "permission",
|
|
40
|
-
fields: {
|
|
41
|
-
id: field.id(),
|
|
42
|
-
name: field.string({
|
|
43
|
-
isUnique: true,
|
|
44
|
-
description: "Unique permission name"
|
|
45
|
-
}),
|
|
46
|
-
description: field.string({
|
|
47
|
-
isOptional: true,
|
|
48
|
-
description: "Permission description"
|
|
49
|
-
}),
|
|
50
|
-
createdAt: field.createdAt(),
|
|
51
|
-
updatedAt: field.updatedAt()
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
/**
|
|
55
|
-
* PolicyBinding entity - binds roles to principals.
|
|
56
|
-
*/
|
|
57
|
-
const PolicyBindingEntity = defineEntity({
|
|
58
|
-
name: "PolicyBinding",
|
|
59
|
-
description: "Binds roles to principals (users or organizations).",
|
|
60
|
-
schema: "lssm_sigil",
|
|
61
|
-
map: "policy_binding",
|
|
62
|
-
fields: {
|
|
63
|
-
id: field.id(),
|
|
64
|
-
roleId: field.foreignKey(),
|
|
65
|
-
targetType: field.string({ description: "\"user\" or \"organization\"" }),
|
|
66
|
-
targetId: field.string({ description: "ID of User or Organization" }),
|
|
67
|
-
expiresAt: field.dateTime({
|
|
68
|
-
isOptional: true,
|
|
69
|
-
description: "When binding expires"
|
|
70
|
-
}),
|
|
71
|
-
createdAt: field.createdAt(),
|
|
72
|
-
userId: field.string({ isOptional: true }),
|
|
73
|
-
organizationId: field.string({ isOptional: true }),
|
|
74
|
-
role: field.belongsTo("Role", ["roleId"], ["id"], { onDelete: "Cascade" }),
|
|
75
|
-
user: field.belongsTo("User", ["userId"], ["id"]),
|
|
76
|
-
organization: field.belongsTo("Organization", ["organizationId"], ["id"])
|
|
77
|
-
},
|
|
78
|
-
indexes: [index.on(["targetType", "targetId"])]
|
|
79
|
-
});
|
|
80
|
-
/**
|
|
81
|
-
* ApiKey entity - API keys for programmatic access.
|
|
82
|
-
*/
|
|
83
|
-
const ApiKeyEntity = defineEntity({
|
|
84
|
-
name: "ApiKey",
|
|
85
|
-
description: "API keys for programmatic access.",
|
|
86
|
-
schema: "lssm_sigil",
|
|
87
|
-
map: "api_key",
|
|
88
|
-
fields: {
|
|
89
|
-
id: field.id(),
|
|
90
|
-
name: field.string({ description: "API key name" }),
|
|
91
|
-
start: field.string({ description: "Starting characters for identification" }),
|
|
92
|
-
prefix: field.string({ description: "API key prefix" }),
|
|
93
|
-
key: field.string({ description: "Hashed API key" }),
|
|
94
|
-
userId: field.foreignKey(),
|
|
95
|
-
refillInterval: field.int({ description: "Refill interval in ms" }),
|
|
96
|
-
refillAmount: field.int({ description: "Amount to refill" }),
|
|
97
|
-
lastRefillAt: field.dateTime(),
|
|
98
|
-
remaining: field.int({ description: "Remaining requests" }),
|
|
99
|
-
requestCount: field.int({ description: "Total requests made" }),
|
|
100
|
-
lastRequest: field.dateTime(),
|
|
101
|
-
enabled: field.boolean({ default: true }),
|
|
102
|
-
rateLimitEnabled: field.boolean({ default: true }),
|
|
103
|
-
rateLimitTimeWindow: field.int({ description: "Rate limit window in ms" }),
|
|
104
|
-
rateLimitMax: field.int({ description: "Max requests in window" }),
|
|
105
|
-
expiresAt: field.dateTime(),
|
|
106
|
-
permissions: field.string({ isArray: true }),
|
|
107
|
-
metadata: field.json({ isOptional: true }),
|
|
108
|
-
createdAt: field.createdAt(),
|
|
109
|
-
updatedAt: field.updatedAt(),
|
|
110
|
-
user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
/**
|
|
114
|
-
* Passkey entity - WebAuthn passkeys.
|
|
115
|
-
*/
|
|
116
|
-
const PasskeyEntity = defineEntity({
|
|
117
|
-
name: "Passkey",
|
|
118
|
-
description: "WebAuthn passkeys for passwordless authentication.",
|
|
119
|
-
schema: "lssm_sigil",
|
|
120
|
-
map: "passkey",
|
|
121
|
-
fields: {
|
|
122
|
-
id: field.id(),
|
|
123
|
-
name: field.string({ description: "Passkey name" }),
|
|
124
|
-
publicKey: field.string({ description: "Public key" }),
|
|
125
|
-
userId: field.foreignKey(),
|
|
126
|
-
credentialID: field.string({ description: "Credential ID" }),
|
|
127
|
-
counter: field.int({ description: "Counter" }),
|
|
128
|
-
deviceType: field.string({ description: "Device type" }),
|
|
129
|
-
backedUp: field.boolean({ description: "Whether passkey is backed up" }),
|
|
130
|
-
transports: field.string({ description: "Transports" }),
|
|
131
|
-
aaguid: field.string({ description: "Authenticator GUID" }),
|
|
132
|
-
createdAt: field.createdAt(),
|
|
133
|
-
user: field.belongsTo("User", ["userId"], ["id"], { onDelete: "Cascade" })
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
//#endregion
|
|
138
|
-
export { ApiKeyEntity, PasskeyEntity, PermissionEntity, PolicyBindingEntity, RoleEntity };
|
|
1
|
+
import{defineEntity as e,field as t,index as n}from"@lssm/lib.schema";const r=e({name:`Role`,description:`A role defines a named set of permissions.`,schema:`lssm_sigil`,map:`role`,fields:{id:t.id(),name:t.string({isUnique:!0,description:`Unique role name`}),description:t.string({isOptional:!0,description:`Role description`}),permissions:t.string({isArray:!0,description:`Array of permission names`}),createdAt:t.createdAt(),updatedAt:t.updatedAt(),policyBindings:t.hasMany(`PolicyBinding`)}}),i=e({name:`Permission`,description:`A permission represents an atomic access right.`,schema:`lssm_sigil`,map:`permission`,fields:{id:t.id(),name:t.string({isUnique:!0,description:`Unique permission name`}),description:t.string({isOptional:!0,description:`Permission description`}),createdAt:t.createdAt(),updatedAt:t.updatedAt()}}),a=e({name:`PolicyBinding`,description:`Binds roles to principals (users or organizations).`,schema:`lssm_sigil`,map:`policy_binding`,fields:{id:t.id(),roleId:t.foreignKey(),targetType:t.string({description:`"user" or "organization"`}),targetId:t.string({description:`ID of User or Organization`}),expiresAt:t.dateTime({isOptional:!0,description:`When binding expires`}),createdAt:t.createdAt(),userId:t.string({isOptional:!0}),organizationId:t.string({isOptional:!0}),role:t.belongsTo(`Role`,[`roleId`],[`id`],{onDelete:`Cascade`}),user:t.belongsTo(`User`,[`userId`],[`id`]),organization:t.belongsTo(`Organization`,[`organizationId`],[`id`])},indexes:[n.on([`targetType`,`targetId`])]}),o=e({name:`ApiKey`,description:`API keys for programmatic access.`,schema:`lssm_sigil`,map:`api_key`,fields:{id:t.id(),name:t.string({description:`API key name`}),start:t.string({description:`Starting characters for identification`}),prefix:t.string({description:`API key prefix`}),key:t.string({description:`Hashed API key`}),userId:t.foreignKey(),refillInterval:t.int({description:`Refill interval in ms`}),refillAmount:t.int({description:`Amount to refill`}),lastRefillAt:t.dateTime(),remaining:t.int({description:`Remaining requests`}),requestCount:t.int({description:`Total requests made`}),lastRequest:t.dateTime(),enabled:t.boolean({default:!0}),rateLimitEnabled:t.boolean({default:!0}),rateLimitTimeWindow:t.int({description:`Rate limit window in ms`}),rateLimitMax:t.int({description:`Max requests in window`}),expiresAt:t.dateTime(),permissions:t.string({isArray:!0}),metadata:t.json({isOptional:!0}),createdAt:t.createdAt(),updatedAt:t.updatedAt(),user:t.belongsTo(`User`,[`userId`],[`id`],{onDelete:`Cascade`})}}),s=e({name:`Passkey`,description:`WebAuthn passkeys for passwordless authentication.`,schema:`lssm_sigil`,map:`passkey`,fields:{id:t.id(),name:t.string({description:`Passkey name`}),publicKey:t.string({description:`Public key`}),userId:t.foreignKey(),credentialID:t.string({description:`Credential ID`}),counter:t.int({description:`Counter`}),deviceType:t.string({description:`Device type`}),backedUp:t.boolean({description:`Whether passkey is backed up`}),transports:t.string({description:`Transports`}),aaguid:t.string({description:`Authenticator GUID`}),createdAt:t.createdAt(),user:t.belongsTo(`User`,[`userId`],[`id`],{onDelete:`Cascade`})}});export{o as ApiKeyEntity,s as PasskeyEntity,i as PermissionEntity,a as PolicyBindingEntity,r as RoleEntity};
|