@classytic/access 0.2.0 → 0.4.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.
@@ -0,0 +1,358 @@
1
+ import { DomainEvent, EventMeta } from "@classytic/primitives/events";
2
+ import { z } from "zod";
3
+ //#region src/events/event-constants.d.ts
4
+ /** ACCESS_EVENTS — the event names `@classytic/access` publishes. Subscribe by constant, never by literal. */
5
+ declare const ACCESS_EVENTS: {
6
+ readonly GRANTED: "access:granted";
7
+ readonly EXTENDED: "access:extended";
8
+ readonly SUSPENDED: "access:suspended";
9
+ readonly RESUMED: "access:resumed";
10
+ readonly REVOKED: "access:revoked";
11
+ readonly EXPIRED: "access:expired";
12
+ readonly CONSUMED: "access:consumed";
13
+ readonly EXHAUSTED: "access:exhausted";
14
+ readonly REFUNDED: "access:refunded";
15
+ };
16
+ type AccessEventName = (typeof ACCESS_EVENTS)[keyof typeof ACCESS_EVENTS];
17
+ //#endregion
18
+ //#region src/events/event-catalog.d.ts
19
+ /** The payload JSON Schema — the object shape event registries (arc's `EventSchema`) accept. */
20
+ interface AccessEventSchema {
21
+ type: 'object';
22
+ properties?: Record<string, {
23
+ type?: string;
24
+ [key: string]: unknown;
25
+ }>;
26
+ required?: string[];
27
+ [key: string]: unknown;
28
+ }
29
+ interface AccessEventDefinition<TSchema extends z.ZodType = z.ZodType> {
30
+ name: AccessEventName;
31
+ version: number;
32
+ description: string;
33
+ zodSchema: TSchema;
34
+ /** The same schema, under the name event registries validate with. */
35
+ payloadSchema: TSchema;
36
+ schema: AccessEventSchema;
37
+ create(payload: z.infer<TSchema>, meta?: Partial<EventMeta>): DomainEvent<z.infer<TSchema>>;
38
+ }
39
+ declare const Granted: AccessEventDefinition<z.ZodObject<{
40
+ entitlementId: z.ZodString;
41
+ organizationId: z.ZodOptional<z.ZodString>;
42
+ subjectRef: z.ZodString;
43
+ subjectModel: z.ZodString;
44
+ resourceRef: z.ZodString;
45
+ resourceType: z.ZodString;
46
+ scopeKey: z.ZodString;
47
+ status: z.ZodEnum<{
48
+ active: "active";
49
+ expired: "expired";
50
+ suspended: "suspended";
51
+ revoked: "revoked";
52
+ refunded: "refunded";
53
+ consumed: "consumed";
54
+ }>;
55
+ allowed: z.ZodBoolean;
56
+ reason: z.ZodEnum<{
57
+ active: "active";
58
+ not_found: "not_found";
59
+ not_yet_active: "not_yet_active";
60
+ expired: "expired";
61
+ suspended: "suspended";
62
+ revoked: "revoked";
63
+ refunded: "refunded";
64
+ consumed: "consumed";
65
+ quota_exhausted: "quota_exhausted";
66
+ invalid_grant: "invalid_grant";
67
+ }>;
68
+ originModel: z.ZodOptional<z.ZodString>;
69
+ originRef: z.ZodOptional<z.ZodString>;
70
+ accessExpiresAt: z.ZodOptional<z.ZodISODateTime>;
71
+ usageLimit: z.ZodOptional<z.ZodNumber>;
72
+ usageUsed: z.ZodOptional<z.ZodNumber>;
73
+ }, z.core.$strip>>;
74
+ declare const Extended: AccessEventDefinition<z.ZodObject<{
75
+ entitlementId: z.ZodString;
76
+ organizationId: z.ZodOptional<z.ZodString>;
77
+ subjectRef: z.ZodString;
78
+ subjectModel: z.ZodString;
79
+ resourceRef: z.ZodString;
80
+ resourceType: z.ZodString;
81
+ scopeKey: z.ZodString;
82
+ status: z.ZodEnum<{
83
+ active: "active";
84
+ expired: "expired";
85
+ suspended: "suspended";
86
+ revoked: "revoked";
87
+ refunded: "refunded";
88
+ consumed: "consumed";
89
+ }>;
90
+ allowed: z.ZodBoolean;
91
+ reason: z.ZodEnum<{
92
+ active: "active";
93
+ not_found: "not_found";
94
+ not_yet_active: "not_yet_active";
95
+ expired: "expired";
96
+ suspended: "suspended";
97
+ revoked: "revoked";
98
+ refunded: "refunded";
99
+ consumed: "consumed";
100
+ quota_exhausted: "quota_exhausted";
101
+ invalid_grant: "invalid_grant";
102
+ }>;
103
+ originModel: z.ZodOptional<z.ZodString>;
104
+ originRef: z.ZodOptional<z.ZodString>;
105
+ accessExpiresAt: z.ZodOptional<z.ZodISODateTime>;
106
+ usageLimit: z.ZodOptional<z.ZodNumber>;
107
+ usageUsed: z.ZodOptional<z.ZodNumber>;
108
+ }, z.core.$strip>>;
109
+ declare const Suspended: AccessEventDefinition<z.ZodObject<{
110
+ entitlementId: z.ZodString;
111
+ organizationId: z.ZodOptional<z.ZodString>;
112
+ subjectRef: z.ZodString;
113
+ subjectModel: z.ZodString;
114
+ resourceRef: z.ZodString;
115
+ resourceType: z.ZodString;
116
+ scopeKey: z.ZodString;
117
+ status: z.ZodEnum<{
118
+ active: "active";
119
+ expired: "expired";
120
+ suspended: "suspended";
121
+ revoked: "revoked";
122
+ refunded: "refunded";
123
+ consumed: "consumed";
124
+ }>;
125
+ allowed: z.ZodBoolean;
126
+ reason: z.ZodEnum<{
127
+ active: "active";
128
+ not_found: "not_found";
129
+ not_yet_active: "not_yet_active";
130
+ expired: "expired";
131
+ suspended: "suspended";
132
+ revoked: "revoked";
133
+ refunded: "refunded";
134
+ consumed: "consumed";
135
+ quota_exhausted: "quota_exhausted";
136
+ invalid_grant: "invalid_grant";
137
+ }>;
138
+ originModel: z.ZodOptional<z.ZodString>;
139
+ originRef: z.ZodOptional<z.ZodString>;
140
+ accessExpiresAt: z.ZodOptional<z.ZodISODateTime>;
141
+ usageLimit: z.ZodOptional<z.ZodNumber>;
142
+ usageUsed: z.ZodOptional<z.ZodNumber>;
143
+ }, z.core.$strip>>;
144
+ declare const Resumed: AccessEventDefinition<z.ZodObject<{
145
+ entitlementId: z.ZodString;
146
+ organizationId: z.ZodOptional<z.ZodString>;
147
+ subjectRef: z.ZodString;
148
+ subjectModel: z.ZodString;
149
+ resourceRef: z.ZodString;
150
+ resourceType: z.ZodString;
151
+ scopeKey: z.ZodString;
152
+ status: z.ZodEnum<{
153
+ active: "active";
154
+ expired: "expired";
155
+ suspended: "suspended";
156
+ revoked: "revoked";
157
+ refunded: "refunded";
158
+ consumed: "consumed";
159
+ }>;
160
+ allowed: z.ZodBoolean;
161
+ reason: z.ZodEnum<{
162
+ active: "active";
163
+ not_found: "not_found";
164
+ not_yet_active: "not_yet_active";
165
+ expired: "expired";
166
+ suspended: "suspended";
167
+ revoked: "revoked";
168
+ refunded: "refunded";
169
+ consumed: "consumed";
170
+ quota_exhausted: "quota_exhausted";
171
+ invalid_grant: "invalid_grant";
172
+ }>;
173
+ originModel: z.ZodOptional<z.ZodString>;
174
+ originRef: z.ZodOptional<z.ZodString>;
175
+ accessExpiresAt: z.ZodOptional<z.ZodISODateTime>;
176
+ usageLimit: z.ZodOptional<z.ZodNumber>;
177
+ usageUsed: z.ZodOptional<z.ZodNumber>;
178
+ }, z.core.$strip>>;
179
+ declare const Revoked: AccessEventDefinition<z.ZodObject<{
180
+ entitlementId: z.ZodString;
181
+ organizationId: z.ZodOptional<z.ZodString>;
182
+ subjectRef: z.ZodString;
183
+ subjectModel: z.ZodString;
184
+ resourceRef: z.ZodString;
185
+ resourceType: z.ZodString;
186
+ scopeKey: z.ZodString;
187
+ status: z.ZodEnum<{
188
+ active: "active";
189
+ expired: "expired";
190
+ suspended: "suspended";
191
+ revoked: "revoked";
192
+ refunded: "refunded";
193
+ consumed: "consumed";
194
+ }>;
195
+ allowed: z.ZodBoolean;
196
+ reason: z.ZodEnum<{
197
+ active: "active";
198
+ not_found: "not_found";
199
+ not_yet_active: "not_yet_active";
200
+ expired: "expired";
201
+ suspended: "suspended";
202
+ revoked: "revoked";
203
+ refunded: "refunded";
204
+ consumed: "consumed";
205
+ quota_exhausted: "quota_exhausted";
206
+ invalid_grant: "invalid_grant";
207
+ }>;
208
+ originModel: z.ZodOptional<z.ZodString>;
209
+ originRef: z.ZodOptional<z.ZodString>;
210
+ accessExpiresAt: z.ZodOptional<z.ZodISODateTime>;
211
+ usageLimit: z.ZodOptional<z.ZodNumber>;
212
+ usageUsed: z.ZodOptional<z.ZodNumber>;
213
+ }, z.core.$strip>>;
214
+ declare const Expired: AccessEventDefinition<z.ZodObject<{
215
+ entitlementId: z.ZodString;
216
+ organizationId: z.ZodOptional<z.ZodString>;
217
+ subjectRef: z.ZodString;
218
+ subjectModel: z.ZodString;
219
+ resourceRef: z.ZodString;
220
+ resourceType: z.ZodString;
221
+ scopeKey: z.ZodString;
222
+ status: z.ZodEnum<{
223
+ active: "active";
224
+ expired: "expired";
225
+ suspended: "suspended";
226
+ revoked: "revoked";
227
+ refunded: "refunded";
228
+ consumed: "consumed";
229
+ }>;
230
+ allowed: z.ZodBoolean;
231
+ reason: z.ZodEnum<{
232
+ active: "active";
233
+ not_found: "not_found";
234
+ not_yet_active: "not_yet_active";
235
+ expired: "expired";
236
+ suspended: "suspended";
237
+ revoked: "revoked";
238
+ refunded: "refunded";
239
+ consumed: "consumed";
240
+ quota_exhausted: "quota_exhausted";
241
+ invalid_grant: "invalid_grant";
242
+ }>;
243
+ originModel: z.ZodOptional<z.ZodString>;
244
+ originRef: z.ZodOptional<z.ZodString>;
245
+ accessExpiresAt: z.ZodOptional<z.ZodISODateTime>;
246
+ usageLimit: z.ZodOptional<z.ZodNumber>;
247
+ usageUsed: z.ZodOptional<z.ZodNumber>;
248
+ }, z.core.$strip>>;
249
+ declare const Consumed: AccessEventDefinition<z.ZodObject<{
250
+ entitlementId: z.ZodString;
251
+ organizationId: z.ZodOptional<z.ZodString>;
252
+ subjectRef: z.ZodString;
253
+ subjectModel: z.ZodString;
254
+ resourceRef: z.ZodString;
255
+ resourceType: z.ZodString;
256
+ scopeKey: z.ZodString;
257
+ status: z.ZodEnum<{
258
+ active: "active";
259
+ expired: "expired";
260
+ suspended: "suspended";
261
+ revoked: "revoked";
262
+ refunded: "refunded";
263
+ consumed: "consumed";
264
+ }>;
265
+ allowed: z.ZodBoolean;
266
+ reason: z.ZodEnum<{
267
+ active: "active";
268
+ not_found: "not_found";
269
+ not_yet_active: "not_yet_active";
270
+ expired: "expired";
271
+ suspended: "suspended";
272
+ revoked: "revoked";
273
+ refunded: "refunded";
274
+ consumed: "consumed";
275
+ quota_exhausted: "quota_exhausted";
276
+ invalid_grant: "invalid_grant";
277
+ }>;
278
+ originModel: z.ZodOptional<z.ZodString>;
279
+ originRef: z.ZodOptional<z.ZodString>;
280
+ accessExpiresAt: z.ZodOptional<z.ZodISODateTime>;
281
+ usageLimit: z.ZodOptional<z.ZodNumber>;
282
+ usageUsed: z.ZodOptional<z.ZodNumber>;
283
+ consumptionKey: z.ZodString;
284
+ amount: z.ZodNumber;
285
+ }, z.core.$strip>>;
286
+ declare const Exhausted: AccessEventDefinition<z.ZodObject<{
287
+ entitlementId: z.ZodString;
288
+ organizationId: z.ZodOptional<z.ZodString>;
289
+ subjectRef: z.ZodString;
290
+ subjectModel: z.ZodString;
291
+ resourceRef: z.ZodString;
292
+ resourceType: z.ZodString;
293
+ scopeKey: z.ZodString;
294
+ status: z.ZodEnum<{
295
+ active: "active";
296
+ expired: "expired";
297
+ suspended: "suspended";
298
+ revoked: "revoked";
299
+ refunded: "refunded";
300
+ consumed: "consumed";
301
+ }>;
302
+ allowed: z.ZodBoolean;
303
+ reason: z.ZodEnum<{
304
+ active: "active";
305
+ not_found: "not_found";
306
+ not_yet_active: "not_yet_active";
307
+ expired: "expired";
308
+ suspended: "suspended";
309
+ revoked: "revoked";
310
+ refunded: "refunded";
311
+ consumed: "consumed";
312
+ quota_exhausted: "quota_exhausted";
313
+ invalid_grant: "invalid_grant";
314
+ }>;
315
+ originModel: z.ZodOptional<z.ZodString>;
316
+ originRef: z.ZodOptional<z.ZodString>;
317
+ accessExpiresAt: z.ZodOptional<z.ZodISODateTime>;
318
+ usageLimit: z.ZodOptional<z.ZodNumber>;
319
+ usageUsed: z.ZodOptional<z.ZodNumber>;
320
+ }, z.core.$strip>>;
321
+ declare const Refunded: AccessEventDefinition<z.ZodObject<{
322
+ entitlementId: z.ZodString;
323
+ organizationId: z.ZodOptional<z.ZodString>;
324
+ subjectRef: z.ZodString;
325
+ subjectModel: z.ZodString;
326
+ resourceRef: z.ZodString;
327
+ resourceType: z.ZodString;
328
+ scopeKey: z.ZodString;
329
+ status: z.ZodEnum<{
330
+ active: "active";
331
+ expired: "expired";
332
+ suspended: "suspended";
333
+ revoked: "revoked";
334
+ refunded: "refunded";
335
+ consumed: "consumed";
336
+ }>;
337
+ allowed: z.ZodBoolean;
338
+ reason: z.ZodEnum<{
339
+ active: "active";
340
+ not_found: "not_found";
341
+ not_yet_active: "not_yet_active";
342
+ expired: "expired";
343
+ suspended: "suspended";
344
+ revoked: "revoked";
345
+ refunded: "refunded";
346
+ consumed: "consumed";
347
+ quota_exhausted: "quota_exhausted";
348
+ invalid_grant: "invalid_grant";
349
+ }>;
350
+ originModel: z.ZodOptional<z.ZodString>;
351
+ originRef: z.ZodOptional<z.ZodString>;
352
+ accessExpiresAt: z.ZodOptional<z.ZodISODateTime>;
353
+ usageLimit: z.ZodOptional<z.ZodNumber>;
354
+ usageUsed: z.ZodOptional<z.ZodNumber>;
355
+ }, z.core.$strip>>;
356
+ declare const accessEventDefinitions: ReadonlyArray<AccessEventDefinition>;
357
+ //#endregion
358
+ export { Expired as a, Refunded as c, Suspended as d, accessEventDefinitions as f, Exhausted as i, Resumed as l, AccessEventName as m, AccessEventSchema as n, Extended as o, ACCESS_EVENTS as p, Consumed as r, Granted as s, AccessEventDefinition as t, Revoked as u };
@@ -1,2 +1,2 @@
1
- import { a as Extended, c as Resumed, d as accessEventDefinitions, i as Expired, l as Revoked, n as AccessEventSchema, o as Granted, r as Exhausted, s as Refunded, t as AccessEventDefinition, u as Suspended } from "../event-catalog-Dxo3cxR3.mjs";
2
- export { AccessEventDefinition, AccessEventSchema, Exhausted, Expired, Extended, Granted, Refunded, Resumed, Revoked, Suspended, accessEventDefinitions };
1
+ import { a as Expired, c as Refunded, d as Suspended, f as accessEventDefinitions, i as Exhausted, l as Resumed, n as AccessEventSchema, o as Extended, r as Consumed, s as Granted, t as AccessEventDefinition, u as Revoked } from "../event-catalog-CkIizOxb.mjs";
2
+ export { AccessEventDefinition, AccessEventSchema, Consumed, Exhausted, Expired, Extended, Granted, Refunded, Resumed, Revoked, Suspended, accessEventDefinitions };
@@ -1,2 +1,2 @@
1
- import { a as Refunded, c as Suspended, i as Granted, l as accessEventDefinitions, n as Expired, o as Resumed, r as Extended, s as Revoked, t as Exhausted } from "../event-catalog-BVD_rFlc.mjs";
2
- export { Exhausted, Expired, Extended, Granted, Refunded, Resumed, Revoked, Suspended, accessEventDefinitions };
1
+ import "../domain/access-decision.mjs";
2
+ export { t as Consumed, n as Exhausted, r as Expired, i as Extended, a as Granted, o as Refunded, s as Resumed, c as Revoked, l as Suspended, u as accessEventDefinitions } from "../event-catalog-CIxQavRC.mjs";