@substrat-run/engine-absence 0.4.7 → 0.5.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,333 @@
1
+ import { z } from '@substrat-run/contracts';
2
+ /**
3
+ * engine-absence' schemas — what it ACCEPTS and what it ANSWERS (#707/#896).
4
+ *
5
+ * The inputs were exported from `index.ts` beside the in-scope functions that
6
+ * parse them; the published projections were three hand-written
7
+ * `export interface`s. Both moved here because `defineOperations` declares an
8
+ * operation's `input` and `output` as schemas and a TypeScript interface cannot
9
+ * be one — the alternative is a zod schema next to each interface saying the same
10
+ * thing twice, which is the two-descriptions defect the model exists to delete.
11
+ *
12
+ * Own file rather than inside `operations.ts`, for the reason `entities.ts` is
13
+ * one: `index.ts` needs these too, and a declaration file importing the
14
+ * implementation is a cycle. Nothing here imports `index.ts`.
15
+ *
16
+ * Row versus published, the distinction `entities.ts` already draws: a
17
+ * `LeaveTypeRow` stores `active` as 0/1 because SQLite has no boolean, and the
18
+ * ledger stores a subject as `subject_type` / `subject_id`. What is ANSWERED is
19
+ * `active: boolean` and one `EntityRef` — `toLeaveType` / `toEntry` / `toRequest`
20
+ * in `index.ts` are the one crossing.
21
+ */
22
+ export declare const isoDate: z.ZodString;
23
+ export declare const posDecimal: z.ZodString;
24
+ export declare const signedDecimal: z.ZodString;
25
+ /**
26
+ * Every write names its subject: the vertical's opaque noun + the erasure key.
27
+ *
28
+ * The `ref` here is what #896 is about. Its `entityType` is the VERTICAL's —
29
+ * Meridian passes `employee` — and this engine has no name for it, cannot declare
30
+ * one, and is built not to know: *"It knows NOTHING about who a subject is (the
31
+ * vertical owns the directory)."* An operation narrowing to it declares
32
+ * `refFrom` and points at the field, because the field carries the type.
33
+ */
34
+ export declare const absenceSubject: z.ZodObject<{
35
+ ref: z.ZodObject<{
36
+ entityType: z.ZodString;
37
+ entityId: z.ZodString;
38
+ }, z.core.$strip>;
39
+ dataSubjectId: z.core.$ZodBranded<z.ZodString, "DataSubjectId", "out">;
40
+ }, z.core.$strip>;
41
+ export type AbsenceSubject = z.infer<typeof absenceSubject>;
42
+ export declare const leaveType: z.ZodObject<{
43
+ key: z.ZodString;
44
+ floor: z.ZodString;
45
+ active: z.ZodBoolean;
46
+ createdAt: z.ZodString;
47
+ }, z.core.$strip>;
48
+ export type LeaveType = z.infer<typeof leaveType>;
49
+ export declare const entryKind: z.ZodEnum<{
50
+ accrual: "accrual";
51
+ booking: "booking";
52
+ carryover: "carryover";
53
+ correction: "correction";
54
+ reversal: "reversal";
55
+ }>;
56
+ export declare const absenceEntry: z.ZodObject<{
57
+ id: z.ZodString;
58
+ subject: z.ZodObject<{
59
+ entityType: z.ZodString;
60
+ entityId: z.ZodString;
61
+ }, z.core.$strip>;
62
+ leaveTypeKey: z.ZodString;
63
+ entryKind: z.ZodEnum<{
64
+ accrual: "accrual";
65
+ booking: "booking";
66
+ carryover: "carryover";
67
+ correction: "correction";
68
+ reversal: "reversal";
69
+ }>;
70
+ delta: z.ZodString;
71
+ effectiveDate: z.ZodString;
72
+ requestId: z.ZodNullable<z.ZodString>;
73
+ note: z.ZodNullable<z.ZodString>;
74
+ createdBy: z.ZodString;
75
+ createdAt: z.ZodString;
76
+ }, z.core.$strip>;
77
+ export type AbsenceEntry = z.infer<typeof absenceEntry>;
78
+ export declare const requestStatus: z.ZodEnum<{
79
+ approved: "approved";
80
+ cancelled: "cancelled";
81
+ rejected: "rejected";
82
+ requested: "requested";
83
+ }>;
84
+ export declare const absenceRequest: z.ZodObject<{
85
+ id: z.ZodString;
86
+ subject: z.ZodObject<{
87
+ entityType: z.ZodString;
88
+ entityId: z.ZodString;
89
+ }, z.core.$strip>;
90
+ leaveTypeKey: z.ZodString;
91
+ startDate: z.ZodString;
92
+ endDate: z.ZodString;
93
+ days: z.ZodString;
94
+ status: z.ZodEnum<{
95
+ approved: "approved";
96
+ cancelled: "cancelled";
97
+ rejected: "rejected";
98
+ requested: "requested";
99
+ }>;
100
+ note: z.ZodNullable<z.ZodString>;
101
+ decidedBy: z.ZodNullable<z.ZodString>;
102
+ decidedAt: z.ZodNullable<z.ZodString>;
103
+ createdBy: z.ZodString;
104
+ createdAt: z.ZodString;
105
+ }, z.core.$strip>;
106
+ export type AbsenceRequest = z.infer<typeof absenceRequest>;
107
+ /** One calendar day an approved request covers (D-C). */
108
+ export declare const absenceDay: z.ZodObject<{
109
+ date: z.ZodString;
110
+ leaveTypeKey: z.ZodString;
111
+ requestId: z.ZodString;
112
+ }, z.core.$strip>;
113
+ export type AbsenceDay = z.infer<typeof absenceDay>;
114
+ export declare const balanceAnswer: z.ZodObject<{
115
+ balance: z.ZodString;
116
+ }, z.core.$strip>;
117
+ export declare const decideAnswer: z.ZodObject<{
118
+ request: z.ZodObject<{
119
+ id: z.ZodString;
120
+ subject: z.ZodObject<{
121
+ entityType: z.ZodString;
122
+ entityId: z.ZodString;
123
+ }, z.core.$strip>;
124
+ leaveTypeKey: z.ZodString;
125
+ startDate: z.ZodString;
126
+ endDate: z.ZodString;
127
+ days: z.ZodString;
128
+ status: z.ZodEnum<{
129
+ approved: "approved";
130
+ cancelled: "cancelled";
131
+ rejected: "rejected";
132
+ requested: "requested";
133
+ }>;
134
+ note: z.ZodNullable<z.ZodString>;
135
+ decidedBy: z.ZodNullable<z.ZodString>;
136
+ decidedAt: z.ZodNullable<z.ZodString>;
137
+ createdBy: z.ZodString;
138
+ createdAt: z.ZodString;
139
+ }, z.core.$strip>;
140
+ booking: z.ZodNullable<z.ZodObject<{
141
+ id: z.ZodString;
142
+ subject: z.ZodObject<{
143
+ entityType: z.ZodString;
144
+ entityId: z.ZodString;
145
+ }, z.core.$strip>;
146
+ leaveTypeKey: z.ZodString;
147
+ entryKind: z.ZodEnum<{
148
+ accrual: "accrual";
149
+ booking: "booking";
150
+ carryover: "carryover";
151
+ correction: "correction";
152
+ reversal: "reversal";
153
+ }>;
154
+ delta: z.ZodString;
155
+ effectiveDate: z.ZodString;
156
+ requestId: z.ZodNullable<z.ZodString>;
157
+ note: z.ZodNullable<z.ZodString>;
158
+ createdBy: z.ZodString;
159
+ createdAt: z.ZodString;
160
+ }, z.core.$strip>>;
161
+ }, z.core.$strip>;
162
+ export declare const cancelAnswer: z.ZodObject<{
163
+ request: z.ZodObject<{
164
+ id: z.ZodString;
165
+ subject: z.ZodObject<{
166
+ entityType: z.ZodString;
167
+ entityId: z.ZodString;
168
+ }, z.core.$strip>;
169
+ leaveTypeKey: z.ZodString;
170
+ startDate: z.ZodString;
171
+ endDate: z.ZodString;
172
+ days: z.ZodString;
173
+ status: z.ZodEnum<{
174
+ approved: "approved";
175
+ cancelled: "cancelled";
176
+ rejected: "rejected";
177
+ requested: "requested";
178
+ }>;
179
+ note: z.ZodNullable<z.ZodString>;
180
+ decidedBy: z.ZodNullable<z.ZodString>;
181
+ decidedAt: z.ZodNullable<z.ZodString>;
182
+ createdBy: z.ZodString;
183
+ createdAt: z.ZodString;
184
+ }, z.core.$strip>;
185
+ reversal: z.ZodNullable<z.ZodObject<{
186
+ id: z.ZodString;
187
+ subject: z.ZodObject<{
188
+ entityType: z.ZodString;
189
+ entityId: z.ZodString;
190
+ }, z.core.$strip>;
191
+ leaveTypeKey: z.ZodString;
192
+ entryKind: z.ZodEnum<{
193
+ accrual: "accrual";
194
+ booking: "booking";
195
+ carryover: "carryover";
196
+ correction: "correction";
197
+ reversal: "reversal";
198
+ }>;
199
+ delta: z.ZodString;
200
+ effectiveDate: z.ZodString;
201
+ requestId: z.ZodNullable<z.ZodString>;
202
+ note: z.ZodNullable<z.ZodString>;
203
+ createdBy: z.ZodString;
204
+ createdAt: z.ZodString;
205
+ }, z.core.$strip>>;
206
+ }, z.core.$strip>;
207
+ export declare const availabilityAnswer: z.ZodObject<{
208
+ days: z.ZodArray<z.ZodObject<{
209
+ date: z.ZodString;
210
+ leaveTypeKey: z.ZodString;
211
+ requestId: z.ZodString;
212
+ }, z.core.$strip>>;
213
+ requests: z.ZodArray<z.ZodObject<{
214
+ id: z.ZodString;
215
+ subject: z.ZodObject<{
216
+ entityType: z.ZodString;
217
+ entityId: z.ZodString;
218
+ }, z.core.$strip>;
219
+ leaveTypeKey: z.ZodString;
220
+ startDate: z.ZodString;
221
+ endDate: z.ZodString;
222
+ days: z.ZodString;
223
+ status: z.ZodEnum<{
224
+ approved: "approved";
225
+ cancelled: "cancelled";
226
+ rejected: "rejected";
227
+ requested: "requested";
228
+ }>;
229
+ note: z.ZodNullable<z.ZodString>;
230
+ decidedBy: z.ZodNullable<z.ZodString>;
231
+ decidedAt: z.ZodNullable<z.ZodString>;
232
+ createdBy: z.ZodString;
233
+ createdAt: z.ZodString;
234
+ }, z.core.$strip>>;
235
+ }, z.core.$strip>;
236
+ export declare const expiredAnswer: z.ZodObject<{
237
+ expired: z.ZodNumber;
238
+ }, z.core.$strip>;
239
+ export declare const configureLeaveTypeInput: z.ZodObject<{
240
+ key: z.ZodString;
241
+ floor: z.ZodOptional<z.ZodString>;
242
+ active: z.ZodOptional<z.ZodBoolean>;
243
+ }, z.core.$strip>;
244
+ export type ConfigureLeaveTypeInput = z.infer<typeof configureLeaveTypeInput>;
245
+ export declare const recordEntryInput: z.ZodObject<{
246
+ subject: z.ZodObject<{
247
+ ref: z.ZodObject<{
248
+ entityType: z.ZodString;
249
+ entityId: z.ZodString;
250
+ }, z.core.$strip>;
251
+ dataSubjectId: z.core.$ZodBranded<z.ZodString, "DataSubjectId", "out">;
252
+ }, z.core.$strip>;
253
+ leaveTypeKey: z.ZodString;
254
+ entryKind: z.ZodEnum<{
255
+ accrual: "accrual";
256
+ carryover: "carryover";
257
+ correction: "correction";
258
+ }>;
259
+ delta: z.ZodString;
260
+ effectiveDate: z.ZodString;
261
+ note: z.ZodOptional<z.ZodString>;
262
+ }, z.core.$strip>;
263
+ export type RecordEntryInput = z.infer<typeof recordEntryInput>;
264
+ export declare const requestAbsenceInput: z.ZodObject<{
265
+ subject: z.ZodObject<{
266
+ ref: z.ZodObject<{
267
+ entityType: z.ZodString;
268
+ entityId: z.ZodString;
269
+ }, z.core.$strip>;
270
+ dataSubjectId: z.core.$ZodBranded<z.ZodString, "DataSubjectId", "out">;
271
+ }, z.core.$strip>;
272
+ leaveTypeKey: z.ZodString;
273
+ startDate: z.ZodString;
274
+ endDate: z.ZodString;
275
+ days: z.ZodString;
276
+ note: z.ZodOptional<z.ZodString>;
277
+ }, z.core.$strip>;
278
+ export type RequestAbsenceInput = z.infer<typeof requestAbsenceInput>;
279
+ export declare const decideAbsenceInput: z.ZodObject<{
280
+ requestId: z.ZodString;
281
+ decision: z.ZodEnum<{
282
+ approve: "approve";
283
+ reject: "reject";
284
+ }>;
285
+ note: z.ZodOptional<z.ZodString>;
286
+ }, z.core.$strip>;
287
+ export type DecideAbsenceInput = z.infer<typeof decideAbsenceInput>;
288
+ export declare const cancelAbsenceInput: z.ZodObject<{
289
+ requestId: z.ZodString;
290
+ reason: z.ZodOptional<z.ZodString>;
291
+ }, z.core.$strip>;
292
+ export type CancelAbsenceInput = z.infer<typeof cancelAbsenceInput>;
293
+ /** The reads. Each carries the subject WHOLE, which is what `refFrom` names. */
294
+ export declare const balanceInput: z.ZodObject<{
295
+ subject: z.ZodObject<{
296
+ entityType: z.ZodString;
297
+ entityId: z.ZodString;
298
+ }, z.core.$strip>;
299
+ leaveTypeKey: z.ZodString;
300
+ asOf: z.ZodOptional<z.ZodString>;
301
+ }, z.core.$strip>;
302
+ export declare const availabilityInput: z.ZodObject<{
303
+ subject: z.ZodObject<{
304
+ entityType: z.ZodString;
305
+ entityId: z.ZodString;
306
+ }, z.core.$strip>;
307
+ from: z.ZodString;
308
+ to: z.ZodString;
309
+ }, z.core.$strip>;
310
+ export declare const listEntriesInput: z.ZodObject<{
311
+ subject: z.ZodObject<{
312
+ entityType: z.ZodString;
313
+ entityId: z.ZodString;
314
+ }, z.core.$strip>;
315
+ leaveTypeKey: z.ZodOptional<z.ZodString>;
316
+ }, z.core.$strip>;
317
+ /**
318
+ * `subject` is OPTIONAL here, and that is why this read declares a node check
319
+ * rather than a narrowed one — see the note in `operations.ts`.
320
+ */
321
+ export declare const listRequestsInput: z.ZodObject<{
322
+ subject: z.ZodOptional<z.ZodObject<{
323
+ entityType: z.ZodString;
324
+ entityId: z.ZodString;
325
+ }, z.core.$strip>>;
326
+ status: z.ZodOptional<z.ZodEnum<{
327
+ approved: "approved";
328
+ cancelled: "cancelled";
329
+ rejected: "rejected";
330
+ requested: "requested";
331
+ }>>;
332
+ }, z.core.$strip>;
333
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,CAAC,EAAE,MAAM,yBAAyB,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,eAAO,MAAM,OAAO,aAAgE,CAAC;AACrF,eAAO,MAAM,UAAU,aAA0E,CAAC;AAClG,eAAO,MAAM,aAAa,aAA+D,CAAC;AAE1F;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc;;;;;;iBAGzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAM5D,eAAO,MAAM,SAAS;;;;;iBAKpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,eAAO,MAAM,SAAS;;;;;;EAAwE,CAAC;AAE/F,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;iBAWvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,eAAO,MAAM,aAAa;;;;;EAA6D,CAAC;AAExF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;iBAazB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAA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BAI5B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;iBAG3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;iBAG5B,CAAC"}
@@ -0,0 +1,154 @@
1
+ import { compareDecimal, dataSubjectId, entityRef, z } from '@substrat-run/contracts';
2
+ /**
3
+ * engine-absence' schemas — what it ACCEPTS and what it ANSWERS (#707/#896).
4
+ *
5
+ * The inputs were exported from `index.ts` beside the in-scope functions that
6
+ * parse them; the published projections were three hand-written
7
+ * `export interface`s. Both moved here because `defineOperations` declares an
8
+ * operation's `input` and `output` as schemas and a TypeScript interface cannot
9
+ * be one — the alternative is a zod schema next to each interface saying the same
10
+ * thing twice, which is the two-descriptions defect the model exists to delete.
11
+ *
12
+ * Own file rather than inside `operations.ts`, for the reason `entities.ts` is
13
+ * one: `index.ts` needs these too, and a declaration file importing the
14
+ * implementation is a cycle. Nothing here imports `index.ts`.
15
+ *
16
+ * Row versus published, the distinction `entities.ts` already draws: a
17
+ * `LeaveTypeRow` stores `active` as 0/1 because SQLite has no boolean, and the
18
+ * ledger stores a subject as `subject_type` / `subject_id`. What is ANSWERED is
19
+ * `active: boolean` and one `EntityRef` — `toLeaveType` / `toEntry` / `toRequest`
20
+ * in `index.ts` are the one crossing.
21
+ */
22
+ // ---------------------------------------------------------------------------
23
+ // Primitives
24
+ // ---------------------------------------------------------------------------
25
+ export const isoDate = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'must be YYYY-MM-DD');
26
+ export const posDecimal = z.string().regex(/^\d+(\.\d{1,6})?$/, 'must be a non-negative decimal');
27
+ export const signedDecimal = z.string().regex(/^-?\d+(\.\d{1,6})?$/, 'must be a decimal');
28
+ /**
29
+ * Every write names its subject: the vertical's opaque noun + the erasure key.
30
+ *
31
+ * The `ref` here is what #896 is about. Its `entityType` is the VERTICAL's —
32
+ * Meridian passes `employee` — and this engine has no name for it, cannot declare
33
+ * one, and is built not to know: *"It knows NOTHING about who a subject is (the
34
+ * vertical owns the directory)."* An operation narrowing to it declares
35
+ * `refFrom` and points at the field, because the field carries the type.
36
+ */
37
+ export const absenceSubject = z.object({
38
+ ref: entityRef,
39
+ dataSubjectId,
40
+ });
41
+ // ---------------------------------------------------------------------------
42
+ // What it answers
43
+ // ---------------------------------------------------------------------------
44
+ export const leaveType = z.object({
45
+ key: z.string(),
46
+ floor: z.string(),
47
+ active: z.boolean(),
48
+ createdAt: z.string(),
49
+ });
50
+ export const entryKind = z.enum(['accrual', 'booking', 'correction', 'carryover', 'reversal']);
51
+ export const absenceEntry = z.object({
52
+ id: z.string(),
53
+ subject: entityRef,
54
+ leaveTypeKey: z.string(),
55
+ entryKind,
56
+ delta: z.string(),
57
+ effectiveDate: z.string(),
58
+ requestId: z.string().nullable(),
59
+ note: z.string().nullable(),
60
+ createdBy: z.string(),
61
+ createdAt: z.string(),
62
+ });
63
+ export const requestStatus = z.enum(['requested', 'approved', 'rejected', 'cancelled']);
64
+ export const absenceRequest = z.object({
65
+ id: z.string(),
66
+ subject: entityRef,
67
+ leaveTypeKey: z.string(),
68
+ startDate: z.string(),
69
+ endDate: z.string(),
70
+ days: z.string(),
71
+ status: requestStatus,
72
+ note: z.string().nullable(),
73
+ decidedBy: z.string().nullable(),
74
+ decidedAt: z.string().nullable(),
75
+ createdBy: z.string(),
76
+ createdAt: z.string(),
77
+ });
78
+ /** One calendar day an approved request covers (D-C). */
79
+ export const absenceDay = z.object({
80
+ date: z.string(),
81
+ leaveTypeKey: z.string(),
82
+ requestId: z.string(),
83
+ });
84
+ export const balanceAnswer = z.object({ balance: z.string() });
85
+ export const decideAnswer = z.object({
86
+ request: absenceRequest,
87
+ booking: absenceEntry.nullable(),
88
+ });
89
+ export const cancelAnswer = z.object({
90
+ request: absenceRequest,
91
+ reversal: absenceEntry.nullable(),
92
+ });
93
+ export const availabilityAnswer = z.object({
94
+ days: z.array(absenceDay),
95
+ requests: z.array(absenceRequest),
96
+ });
97
+ export const expiredAnswer = z.object({ expired: z.number() });
98
+ // ---------------------------------------------------------------------------
99
+ // What it accepts
100
+ // ---------------------------------------------------------------------------
101
+ export const configureLeaveTypeInput = z.object({
102
+ key: z.string().min(1),
103
+ floor: signedDecimal.optional(),
104
+ active: z.boolean().optional(),
105
+ });
106
+ export const recordEntryInput = z.object({
107
+ subject: absenceSubject,
108
+ leaveTypeKey: z.string().min(1),
109
+ entryKind: z.enum(['accrual', 'correction', 'carryover']),
110
+ delta: signedDecimal,
111
+ effectiveDate: isoDate,
112
+ note: z.string().optional(),
113
+ });
114
+ export const requestAbsenceInput = z.object({
115
+ subject: absenceSubject,
116
+ leaveTypeKey: z.string().min(1),
117
+ startDate: isoDate,
118
+ endDate: isoDate,
119
+ days: posDecimal.refine((d) => compareDecimal(d, '0') > 0, 'days must be positive'),
120
+ note: z.string().optional(),
121
+ });
122
+ export const decideAbsenceInput = z.object({
123
+ requestId: z.string().min(1),
124
+ decision: z.enum(['approve', 'reject']),
125
+ note: z.string().optional(),
126
+ });
127
+ export const cancelAbsenceInput = z.object({
128
+ requestId: z.string().min(1),
129
+ reason: z.string().optional(),
130
+ });
131
+ /** The reads. Each carries the subject WHOLE, which is what `refFrom` names. */
132
+ export const balanceInput = z.object({
133
+ subject: entityRef,
134
+ leaveTypeKey: z.string().min(1),
135
+ asOf: isoDate.optional(),
136
+ });
137
+ export const availabilityInput = z.object({
138
+ subject: entityRef,
139
+ from: isoDate,
140
+ to: isoDate,
141
+ });
142
+ export const listEntriesInput = z.object({
143
+ subject: entityRef,
144
+ leaveTypeKey: z.string().min(1).optional(),
145
+ });
146
+ /**
147
+ * `subject` is OPTIONAL here, and that is why this read declares a node check
148
+ * rather than a narrowed one — see the note in `operations.ts`.
149
+ */
150
+ export const listRequestsInput = z.object({
151
+ subject: entityRef.optional(),
152
+ status: requestStatus.optional(),
153
+ });
154
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[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,MAAM,CAAC;IACnC,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE;CACzB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,OAAO;IACb,EAAE,EAAE,OAAO;CACZ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,SAAS,CAAC,QAAQ,EAAE;IAC7B,MAAM,EAAE,aAAa,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@substrat-run/engine-absence",
3
- "version": "0.4.7",
3
+ "version": "0.5.0",
4
4
  "description": "Substrat engine: approved absence — an append-only entry ledger over an opaque subject, balance as a fold, approval as a state machine",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -25,19 +25,23 @@
25
25
  "access": "public"
26
26
  },
27
27
  "dependencies": {
28
- "@substrat-run/contracts": "^0.87.0",
29
- "@substrat-run/kernel": "^0.87.0"
28
+ "@substrat-run/kernel": "^0.88.0",
29
+ "@substrat-run/contracts": "^0.88.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "typescript": "^7.0.0",
33
33
  "vitest": "^3.2.7",
34
34
  "zod": "^4.4.3",
35
- "@substrat-run/model-emit": "0.7.3",
36
- "@substrat-run/engine-test-kit": "^0.3.14"
35
+ "@substrat-run/contract-tests": "^0.88.0",
36
+ "@substrat-run/engine-test-kit": "^0.3.15",
37
+ "@substrat-run/model-emit": "0.8.0"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "zod": "^4.4.0"
40
41
  },
42
+ "substrat": {
43
+ "conformance": "test/conformance.ts"
44
+ },
41
45
  "scripts": {
42
46
  "build": "tsc -p tsconfig.json",
43
47
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",