@latticecms/core 0.0.0 → 0.2.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 (113) hide show
  1. package/README.md +1297 -2
  2. package/dist/access.d.ts +209 -0
  3. package/dist/access.d.ts.map +1 -0
  4. package/dist/access.js +241 -0
  5. package/dist/access.js.map +1 -0
  6. package/dist/build.d.ts +555 -0
  7. package/dist/build.d.ts.map +1 -0
  8. package/dist/build.js +655 -0
  9. package/dist/build.js.map +1 -0
  10. package/dist/collection.d.ts +480 -0
  11. package/dist/collection.d.ts.map +1 -0
  12. package/dist/collection.js +351 -0
  13. package/dist/collection.js.map +1 -0
  14. package/dist/crud.d.ts +46 -0
  15. package/dist/crud.d.ts.map +1 -0
  16. package/dist/crud.js +527 -0
  17. package/dist/crud.js.map +1 -0
  18. package/dist/describe.d.ts +89 -0
  19. package/dist/describe.d.ts.map +1 -0
  20. package/dist/describe.js +119 -0
  21. package/dist/describe.js.map +1 -0
  22. package/dist/errors.d.ts +183 -0
  23. package/dist/errors.d.ts.map +1 -0
  24. package/dist/errors.js +150 -0
  25. package/dist/errors.js.map +1 -0
  26. package/dist/family.d.ts +80 -0
  27. package/dist/family.d.ts.map +1 -0
  28. package/dist/family.js +227 -0
  29. package/dist/family.js.map +1 -0
  30. package/dist/index.d.ts +14 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +10 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/marker.d.ts +15 -0
  35. package/dist/marker.d.ts.map +1 -0
  36. package/dist/marker.js +28 -0
  37. package/dist/marker.js.map +1 -0
  38. package/dist/mask.d.ts +69 -0
  39. package/dist/mask.d.ts.map +1 -0
  40. package/dist/mask.js +277 -0
  41. package/dist/mask.js.map +1 -0
  42. package/dist/populate.d.ts +39 -0
  43. package/dist/populate.d.ts.map +1 -0
  44. package/dist/populate.js +72 -0
  45. package/dist/populate.js.map +1 -0
  46. package/dist/relations.d.ts +144 -0
  47. package/dist/relations.d.ts.map +1 -0
  48. package/dist/relations.js +144 -0
  49. package/dist/relations.js.map +1 -0
  50. package/dist/repo.d.ts +99 -0
  51. package/dist/repo.d.ts.map +1 -0
  52. package/dist/repo.js +92 -0
  53. package/dist/repo.js.map +1 -0
  54. package/dist/sort.d.ts +86 -0
  55. package/dist/sort.d.ts.map +1 -0
  56. package/dist/sort.js +187 -0
  57. package/dist/sort.js.map +1 -0
  58. package/dist/store/conformance.d.ts +15 -0
  59. package/dist/store/conformance.d.ts.map +1 -0
  60. package/dist/store/conformance.js +811 -0
  61. package/dist/store/conformance.js.map +1 -0
  62. package/dist/store/index.d.ts +9 -0
  63. package/dist/store/index.d.ts.map +1 -0
  64. package/dist/store/index.js +8 -0
  65. package/dist/store/index.js.map +1 -0
  66. package/dist/store.d.ts +119 -0
  67. package/dist/store.d.ts.map +1 -0
  68. package/dist/store.js +176 -0
  69. package/dist/store.js.map +1 -0
  70. package/dist/tenancy.d.ts +66 -0
  71. package/dist/tenancy.d.ts.map +1 -0
  72. package/dist/tenancy.js +69 -0
  73. package/dist/tenancy.js.map +1 -0
  74. package/dist/tracing.d.ts +12 -0
  75. package/dist/tracing.d.ts.map +1 -0
  76. package/dist/tracing.js +27 -0
  77. package/dist/tracing.js.map +1 -0
  78. package/dist/where.d.ts +95 -0
  79. package/dist/where.d.ts.map +1 -0
  80. package/dist/where.js +308 -0
  81. package/dist/where.js.map +1 -0
  82. package/package.json +80 -2
  83. package/skills/lattice/SKILL.md +106 -0
  84. package/skills/lattice/references/access.md +90 -0
  85. package/skills/lattice/references/cli.md +87 -0
  86. package/skills/lattice/references/collection.md +94 -0
  87. package/skills/lattice/references/event-handler.md +88 -0
  88. package/skills/lattice/references/masking.md +72 -0
  89. package/skills/lattice/references/method.md +88 -0
  90. package/skills/lattice/references/override.md +160 -0
  91. package/skills/lattice/references/relations.md +91 -0
  92. package/skills/lattice/references/tenancy.md +82 -0
  93. package/skills/lattice/references/testing.md +75 -0
  94. package/src/access.ts +449 -0
  95. package/src/build.ts +1888 -0
  96. package/src/collection.ts +1025 -0
  97. package/src/crud.ts +797 -0
  98. package/src/describe.ts +232 -0
  99. package/src/errors.ts +174 -0
  100. package/src/family.ts +334 -0
  101. package/src/index.ts +44 -0
  102. package/src/marker.ts +54 -0
  103. package/src/mask.ts +336 -0
  104. package/src/populate.ts +103 -0
  105. package/src/relations.ts +370 -0
  106. package/src/repo.ts +218 -0
  107. package/src/sort.ts +271 -0
  108. package/src/store/conformance.ts +1179 -0
  109. package/src/store/index.ts +22 -0
  110. package/src/store.ts +315 -0
  111. package/src/tenancy.ts +124 -0
  112. package/src/tracing.ts +29 -0
  113. package/src/where.ts +463 -0
package/dist/family.js ADDED
@@ -0,0 +1,227 @@
1
+ import { SpanKind } from '@opentelemetry/api';
2
+ import { UseCase } from 'hexok';
3
+ import { z } from 'zod';
4
+ import { CallAccess } from './access.js';
5
+ import { invalid, LatticeError, parse, refusal } from './errors.js';
6
+ import { refuseWithheld } from './mask.js';
7
+ import { tenancy } from './tenancy.js';
8
+ import { failed, tracer } from './tracing.js';
9
+ /**
10
+ * The fields that say who made a call, for its log lines: the actor's id,
11
+ * and its tenant id or `tenancy: 'bypass'`.
12
+ */
13
+ export function callerFields(family, actor) {
14
+ const actorId = family.actorId(actor);
15
+ const tenant = family.tenantOf?.(actor);
16
+ if (tenant === undefined)
17
+ return { actorId };
18
+ if (tenant === tenancy.bypass)
19
+ return { actorId, tenancy: 'bypass' };
20
+ return { actorId, tenantId: tenant };
21
+ }
22
+ /**
23
+ * The errors a family has logged, its guards' rejections and what `onCatch`
24
+ * saw, with how. The procedure middleware skips both outcomes; the edge's
25
+ * `onError` skips only failures, so a refusal the client sees as INTERNAL
26
+ * still reaches it. A WeakMap keeps the error object as it is and holds it
27
+ * no longer than the caller.
28
+ */
29
+ const logged = new WeakMap();
30
+ /** How a family logged `error`, or undefined when no family did. */
31
+ export function loggedByFamily(error) {
32
+ return typeof error === 'object' && error !== null
33
+ ? logged.get(error)
34
+ : undefined;
35
+ }
36
+ /** The action of `token`: a generated operation's or a method's name. */
37
+ function actionOf(spec, token) {
38
+ const { slug } = spec.collection;
39
+ return token.startsWith(`${slug}.`) ? token.slice(slug.length + 1) : token;
40
+ }
41
+ /**
42
+ * The logger of one call: `ctx.logger` with the call's collection, action
43
+ * and, once the actor has parsed, its id and tenant. Every family log line
44
+ * goes through it, so the fields cannot drift.
45
+ */
46
+ function callLogger(logger, spec, token, caller) {
47
+ return logger.child({
48
+ collection: spec.collection.slug,
49
+ action: actionOf(spec, token),
50
+ ...caller,
51
+ });
52
+ }
53
+ /**
54
+ * Logs a thrown value once and records it: info for a refusal, error for
55
+ * anything else. Returns it, so a guard can throw it.
56
+ */
57
+ function logThrown(log, token, error, durationMs) {
58
+ const timing = durationMs === undefined ? {} : { durationMs };
59
+ const refused = refusal(error);
60
+ if (refused !== undefined) {
61
+ log.info(token, { outcome: 'refused', ...refused, ...timing });
62
+ }
63
+ else if (error instanceof Error) {
64
+ log.error(error, { outcome: 'failed', ...timing });
65
+ }
66
+ else {
67
+ log.error(token, { outcome: 'failed', thrown: error, ...timing });
68
+ }
69
+ if (typeof error === 'object' && error !== null) {
70
+ logged.set(error, refused === undefined ? 'failed' : 'refused');
71
+ }
72
+ return error;
73
+ }
74
+ /**
75
+ * Builds the app's one use case family on hexok `UseCase.context`. Before
76
+ * any member's `execute` runs, the actor must parse against `actor`, the
77
+ * input against the member's `input` static, and `ctx.access` must allow
78
+ * the member's action. Each call writes one line
79
+ * through a child of `ctx.logger`: info when it returns or a guard or
80
+ * `execute` refuses it, error when it throws anything else.
81
+ */
82
+ export function family(options) {
83
+ const caller = (actor) => callerFields({ actorId: options.actorId, tenantOf: options.tenantOf }, actor);
84
+ const factory = UseCase.context()
85
+ // Guards run outside hexok's hooks, so each logs its own rejection.
86
+ .guard(({ ctx, spec, token }) => {
87
+ // The call's context parsed the actor once (familyContext), so this
88
+ // guard reads that parse rather than repeating it. The issues describe
89
+ // the caller's credentials, so they stay out of the error and the log.
90
+ if (!CallAccess.parsed(ctx.access, ctx.actor)) {
91
+ const log = callLogger(ctx.logger, spec, token, undefined);
92
+ throw logThrown(log, token, LatticeError.UNAUTHORIZED());
93
+ }
94
+ })
95
+ .guard(({ ctx, spec, token, input }) => {
96
+ // hexok hands execute the caller's input, not the parsed value. So a
97
+ // method's input schema uses no defaults or transforms; a generated use
98
+ // case parses its own input inside execute to strip unknown keys and
99
+ // apply defaults.
100
+ if (spec.input === undefined)
101
+ return;
102
+ const result = z.safeParse(spec.input, input);
103
+ if (!result.success) {
104
+ const log = callLogger(ctx.logger, spec, token, caller(ctx.actor));
105
+ throw logThrown(log, token, invalid(result.error.issues));
106
+ }
107
+ })
108
+ // Access, after the actor and the input are known good. Generated
109
+ // operations, overrides and methods all pass here, so none can skip the
110
+ // FORBIDDEN check. The answer stays on ctx.access for execute's scope.
111
+ .guard(async ({ ctx, spec, token, input }) => {
112
+ const action = actionOf(spec, token);
113
+ // Create's function receives the parsed input, as the create body
114
+ // will see it. The generated create's input schema is the collection's
115
+ // schema (operations() in collection.ts), for the generated create and
116
+ // an override alike, so this parse and the body's come from one
117
+ // schema; building the operations here would rebuild every schema on
118
+ // every call.
119
+ try {
120
+ const data = action === 'create'
121
+ ? parse(spec.collection.schema, input)
122
+ : undefined;
123
+ await ctx.access.scope(spec.collection, action, data);
124
+ }
125
+ catch (error) {
126
+ const log = callLogger(ctx.logger, spec, token, caller(ctx.actor));
127
+ throw logThrown(log, token, error);
128
+ }
129
+ })
130
+ // A where or a sort on a field the caller's rules withhold would reveal
131
+ // it through which rows match or their order, and an update would change
132
+ // a value the caller cannot see (0035), so each is refused, on every
133
+ // path. Output masking happens where a client receives the result.
134
+ .guard(async ({ ctx, spec, token, input }) => {
135
+ try {
136
+ await refuseWithheld(ctx.access, spec.collection, actionOf(spec, token), input);
137
+ }
138
+ catch (error) {
139
+ const log = callLogger(ctx.logger, spec, token, caller(ctx.actor));
140
+ throw logThrown(log, token, error);
141
+ }
142
+ })
143
+ .hooks({
144
+ preExecute: ({ ctx, spec, token }) => {
145
+ const fields = caller(ctx.actor);
146
+ return {
147
+ log: callLogger(ctx.logger, spec, token, fields),
148
+ started: performance.now(),
149
+ span: useCaseSpan(spec, token, fields),
150
+ };
151
+ },
152
+ // The span ends in postExecute and onCatch, beside the log line,
153
+ // rather than in its own onFinally: each hook is one more await on
154
+ // every call, traced or not.
155
+ postExecute: ({ token }, { log, started, span }) => {
156
+ log.info(token, { outcome: 'ok', durationMs: since(started) });
157
+ if (span.isRecording())
158
+ span.setAttribute('lattice.outcome', 'ok');
159
+ span.end();
160
+ },
161
+ onCatch: ({ ctx, spec, token, error }, state) => {
162
+ // State is undefined only when preExecute itself threw.
163
+ if (state === undefined) {
164
+ logThrown(callLogger(ctx.logger, spec, token, undefined), token, error);
165
+ }
166
+ else {
167
+ logThrown(state.log, token, error, since(state.started));
168
+ const refused = refusal(error);
169
+ if (refused === undefined) {
170
+ failed(state.span, error);
171
+ }
172
+ else if (state.span.isRecording()) {
173
+ // A refusal is not a failure: the status stays UNSET.
174
+ state.span.setAttributes({
175
+ 'lattice.outcome': 'refused',
176
+ 'lattice.code': String(refused.code),
177
+ });
178
+ }
179
+ state.span.end();
180
+ }
181
+ },
182
+ });
183
+ // The generated use cases and the procedure middleware read these, so the
184
+ // app states them once.
185
+ return Object.assign(factory, {
186
+ actor: options.actor,
187
+ actorId: options.actorId,
188
+ tenantOf: options.tenantOf,
189
+ });
190
+ }
191
+ /**
192
+ * The use case's span: a child of the active span, the procedure's or a
193
+ * direct caller's. hexok has no around hook, so this span cannot be made
194
+ * active for execute: the store calls execute makes are its siblings, not
195
+ * its children. Its attributes are set only when a span records, so
196
+ * without an SDK they cost nothing.
197
+ */
198
+ function useCaseSpan(spec, token, caller) {
199
+ const span = tracer.startSpan(token, { kind: SpanKind.INTERNAL });
200
+ if (span.isRecording())
201
+ span.setAttributes(spanFields(spec, token, caller));
202
+ return span;
203
+ }
204
+ /**
205
+ * A use case span's attributes: what ran and for whom, never its input or
206
+ * a document. The caller's fields are its log line's.
207
+ */
208
+ function spanFields(spec, token, caller) {
209
+ return {
210
+ 'lattice.use_case': token,
211
+ 'lattice.collection': spec.collection.slug,
212
+ 'lattice.action': actionOf(spec, token),
213
+ ...(caller.actorId === undefined
214
+ ? {}
215
+ : { 'lattice.actor_id': caller.actorId }),
216
+ ...(caller.tenantId === undefined
217
+ ? {}
218
+ : { 'lattice.tenant_id': caller.tenantId }),
219
+ ...(caller.tenancy === undefined
220
+ ? {}
221
+ : { 'lattice.tenancy': caller.tenancy }),
222
+ };
223
+ }
224
+ function since(started) {
225
+ return Math.round(performance.now() - started);
226
+ }
227
+ //# sourceMappingURL=family.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"family.js","sourceRoot":"","sources":["../src/family.ts"],"names":[],"mappings":"AACA,OAAO,EAA8B,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAyB,OAAO,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAe,OAAO,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAmD9C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAmD,EACnD,KAAY;IAEZ,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC;IACxC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,OAAO,EAAE,CAAC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AAC;QAC3C,GAAG,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS;YAC/B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,mBAAmB,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC7C,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,SAAS;YAC9B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,iBAAiB,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,OAAe;IAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,14 @@
1
+ export { Access, type AccessRequest, type CallAccess, unscoped, } from './access.js';
2
+ export { type Contract, type CreateInput, type Framework, framework, type ReadUseCase, reservedNames, type UpdateInput, } from './build.js';
3
+ export { type Collection, collection, type RelationsOf, reservedFields, } from './collection.js';
4
+ export { type LatticeMeta, labelOf } from './describe.js';
5
+ export { LatticeError } from './errors.js';
6
+ export { type CallContext, type Family, type FamilyContext, family, } from './family.js';
7
+ export type { Withheld } from './populate.js';
8
+ export { type JoinShape, type Many, type ManyOnDelete, many, type OnDelete, type Ref, ref, } from './relations.js';
9
+ export type { ClientDoc, Doc, Repo } from './repo.js';
10
+ export type { Sort } from './sort.js';
11
+ export { CollectionStore, MemoryStore } from './store.js';
12
+ export { type Scope, tenancy } from './tenancy.js';
13
+ export type { Where } from './where.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,SAAS,EACT,KAAK,WAAW,EAChB,aAAa,EACb,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,UAAU,EACf,UAAU,EACV,KAAK,WAAW,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,MAAM,GACP,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,IAAI,EACJ,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,GAAG,GACJ,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtD,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,KAAK,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export { Access, unscoped, } from './access.js';
2
+ export { framework, reservedNames, } from './build.js';
3
+ export { collection, reservedFields, } from './collection.js';
4
+ export { labelOf } from './describe.js';
5
+ export { LatticeError } from './errors.js';
6
+ export { family, } from './family.js';
7
+ export { many, ref, } from './relations.js';
8
+ export { CollectionStore, MemoryStore } from './store.js';
9
+ export { tenancy } from './tenancy.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAGN,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,SAAS,EAET,aAAa,GAEd,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,UAAU,EAEV,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAoB,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAIL,MAAM,GACP,MAAM,aAAa,CAAC;AAErB,OAAO,EAIL,IAAI,EAGJ,GAAG,GACJ,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAc,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ /** A maskable field as the marker records it: its collection and name. */
3
+ export type Masked = {
4
+ readonly collection: string;
5
+ readonly field: string;
6
+ };
7
+ /** The field a schema node is marked as, or undefined. */
8
+ export declare function markOf(schema: z.core.$ZodType): Masked | undefined;
9
+ /**
10
+ * `schema` with the mask marker added: a clone, never the app's schema. The
11
+ * clone keeps the app's meta, such as a `title`, and adds
12
+ * `x-lattice-maskable`, so the field's JSON Schema says it may be withheld.
13
+ */
14
+ export declare function marked<T extends z.core.$ZodType>(schema: T, masked: Masked): T;
15
+ //# sourceMappingURL=marker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marker.d.ts","sourceRoot":"","sources":["../src/marker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0EAA0E;AAC1E,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAiB7E,0DAA0D;AAC1D,wBAAgB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,MAAM,GAAG,SAAS,CAElE;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,EAC9C,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,MAAM,GACb,CAAC,CAoBH"}
package/dist/marker.js ADDED
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ function isMaskMarker(check) {
3
+ return (typeof check === 'object' && check !== null && '~lattice-mask' in check);
4
+ }
5
+ /** The field a schema node is marked as, or undefined. */
6
+ export function markOf(schema) {
7
+ return (schema._zod.def.checks ?? []).find(isMaskMarker)?.['~lattice-mask'];
8
+ }
9
+ /**
10
+ * `schema` with the mask marker added: a clone, never the app's schema. The
11
+ * clone keeps the app's meta, such as a `title`, and adds
12
+ * `x-lattice-maskable`, so the field's JSON Schema says it may be withheld.
13
+ */
14
+ export function marked(schema, masked) {
15
+ const marker = Object.assign(z.check(() => { }), {
16
+ '~lattice-mask': masked,
17
+ });
18
+ const { def } = schema._zod;
19
+ // `parent` makes the clone inherit the schema's meta, as Zod's own
20
+ // methods do.
21
+ const clone = z.core.util.clone(schema, { ...def, checks: [...(def.checks ?? []), marker] }, { parent: true });
22
+ z.globalRegistry.add(clone, {
23
+ ...z.globalRegistry.get(clone),
24
+ 'x-lattice-maskable': true,
25
+ });
26
+ return clone;
27
+ }
28
+ //# sourceMappingURL=marker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marker.js","sourceRoot":"","sources":["../src/marker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,eAAe,IAAI,KAAK,CACxE,CAAC;AACJ,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,MAAM,CAAC,MAAuB;IAC5C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;AAC9E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM,CACpB,MAAS,EACT,MAAc;IAEd,MAAM,MAAM,GAAe,MAAM,CAAC,MAAM,CACtC,CAAC,CAAC,KAAK,CAAU,GAAG,EAAE,GAAE,CAAC,CAAC,EAC1B;QACE,eAAe,EAAE,MAAM;KACxB,CACF,CAAC;IACF,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;IAC5B,mEAAmE;IACnE,cAAc;IACd,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAC7B,MAAM,EACN,EAAE,GAAG,GAAG,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,EACnD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB,CAAC;IACF,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE;QAC1B,GAAG,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC;QAC9B,oBAAoB,EAAE,IAAI;KAC3B,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/mask.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+ import { CallAccess } from './access.js';
3
+ import { type Masked } from './marker.js';
4
+ /** `Shape` with each maskable field optional, as a client may receive it. */
5
+ export type MaskShape<Shape extends z.core.$ZodShape, M extends string> = {
6
+ [K in keyof Shape]: K extends M ? z.ZodOptional<Shape[K]> : Shape[K];
7
+ };
8
+ /**
9
+ * The shapes a collection's outputs are built from: `stored`, with each
10
+ * maskable field marked, and `client`, with each marked and optional.
11
+ */
12
+ export declare function maskShapes<Shape extends z.core.$ZodShape, M extends string>(slug: string, shape: Shape, maskable: readonly M[]): {
13
+ readonly stored: Shape;
14
+ readonly client: MaskShape<Shape, M>;
15
+ };
16
+ /**
17
+ * Where in an output a withheld field is removed. Built once per procedure
18
+ * from its output schema; only the parts that hold a masked field.
19
+ */
20
+ export type MaskPlan = {
21
+ readonly kind: 'object';
22
+ readonly keys: ReadonlyMap<string, {
23
+ readonly masked?: Masked;
24
+ readonly child?: MaskPlan;
25
+ }>;
26
+ } | {
27
+ readonly kind: 'array';
28
+ readonly item: MaskPlan;
29
+ } | {
30
+ readonly kind: 'record';
31
+ readonly value: MaskPlan;
32
+ } | {
33
+ readonly kind: 'tuple';
34
+ readonly items: readonly (MaskPlan | undefined)[];
35
+ readonly rest: MaskPlan | undefined;
36
+ } | {
37
+ readonly kind: 'each';
38
+ readonly plans: readonly MaskPlan[];
39
+ };
40
+ /**
41
+ * The mask plan of an output schema, or undefined when nothing in it is
42
+ * masked. `where` names the procedure, for errors. It sees through objects,
43
+ * arrays, records, tuples, unions, intersections and the optional, nullable,
44
+ * default, readonly and catch wrappers. A schema it cannot see through
45
+ * throws, so no masked field can hide inside one. A masked field must be
46
+ * optional where it sits: a client may not receive it.
47
+ */
48
+ export declare function maskPlan(schema: z.core.$ZodType, where: string): MaskPlan | undefined;
49
+ /** The collections a plan masks fields of. */
50
+ export declare function maskedCollections(plan: MaskPlan): Set<string>;
51
+ /**
52
+ * `value` with each field `withheld` says to remove taken out, where `plan`
53
+ * puts one. It copies what it changes, so a document the use case still
54
+ * holds is not changed.
55
+ */
56
+ export declare function applyMask(plan: MaskPlan, value: unknown, withheld: (masked: Masked) => boolean): unknown;
57
+ /**
58
+ * Refuses, as VALIDATION, a `where` or `sort` on find or count, or an
59
+ * update patch, that names a field withheld from the caller (0031, 0035).
60
+ * A query would reveal it through which rows match or their order, and an
61
+ * update would change a value the caller cannot see. The family guard runs
62
+ * it on every use case, and the generated bodies run it again (0036), so a
63
+ * body called from an override skips nothing.
64
+ */
65
+ export declare function refuseWithheld(access: CallAccess, collection: {
66
+ readonly slug: string;
67
+ readonly maskable: readonly string[];
68
+ }, action: string, input: unknown): Promise<void>;
69
+ //# sourceMappingURL=mask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../src/mask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,KAAK,MAAM,EAAkB,MAAM,aAAa,CAAC;AAG1D,6EAA6E;AAC7E,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,SAAS,MAAM,IAAI;KACvE,CAAC,IAAI,MAAM,KAAK,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;CACrE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,SAAS,MAAM,EACzE,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,SAAS,CAAC,EAAE,GACrB;IAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;CAAE,CAAC;AAqBpE;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAChB;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,WAAW,CACxB,MAAM,EACN;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAA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