@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
@@ -0,0 +1,119 @@
1
+ import { docs } from '@ts-pf/docs';
2
+ import { mcp } from '@ts-pf/mcp/meta';
3
+ const effects = {
4
+ find: 'read',
5
+ count: 'read',
6
+ get: 'read',
7
+ list: 'read',
8
+ create: 'write',
9
+ update: 'write',
10
+ delete: 'destructive',
11
+ set: 'destructive',
12
+ };
13
+ /** The words of an identifier: `post_categories` and `postCategories` are "post categories". */
14
+ function words(name) {
15
+ return name
16
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
17
+ .split(/[\s_-]+/)
18
+ .filter((word) => word.length > 0)
19
+ .join(' ')
20
+ .toLowerCase();
21
+ }
22
+ /**
23
+ * The singular of an English plural, for the common endings only. A slug
24
+ * it gets wrong, such as `news` or `people`, declares its label.
25
+ */
26
+ function singularOf(plural) {
27
+ if (/[^aeiou]ies$/.test(plural))
28
+ return `${plural.slice(0, -3)}y`;
29
+ if (/(sses|shes|ches|xes|zzes)$/.test(plural))
30
+ return plural.slice(0, -2);
31
+ if (/(ss|us|is)$/.test(plural) || !plural.endsWith('s'))
32
+ return plural;
33
+ return plural.slice(0, -1);
34
+ }
35
+ /** A collection's label from its slug: `deal_stages` is "deal stage" and "deal stages". */
36
+ export function labelOf(slug) {
37
+ const plural = words(slug);
38
+ const last = plural.lastIndexOf(' ');
39
+ return {
40
+ singular: `${plural.slice(0, last + 1)}${singularOf(plural.slice(last + 1))}`,
41
+ plural,
42
+ };
43
+ }
44
+ const query = 'Filter with where, order with sort, and page with limit and after (the previous page’s next).';
45
+ /**
46
+ * One short sentence per operation, naming the inputs that matter. "One",
47
+ * not "a" or "an": the article depends on how the label sounds.
48
+ */
49
+ function summaryOf(described) {
50
+ const { singular, plural } = described.label;
51
+ const populate = described.populate.length === 0
52
+ ? ''
53
+ : ` populate expands ${described.populate.join(', ')} into documents.`;
54
+ switch (described.op) {
55
+ case 'find':
56
+ return `Find ${plural}. ${query}${populate}`;
57
+ case 'count':
58
+ return `Count ${plural}. Filter with where.`;
59
+ case 'get':
60
+ return `Get one ${singular} by id.${populate}`;
61
+ case 'create':
62
+ return `Create one ${singular}.`;
63
+ case 'update':
64
+ return `Update one ${singular} by id. Send only the fields to change, and null to clear an optional one.`;
65
+ case 'delete':
66
+ return `Delete one ${singular} by id.`;
67
+ case 'list':
68
+ return `List the ${words(described.relation)} of one ${singular}, by its id. ${query}${populate}`;
69
+ case 'set':
70
+ return `Replace the ${words(described.relation)} of one ${singular}, by its id. Links not given are removed.`;
71
+ }
72
+ }
73
+ /** The `lattice` meta of a generated or relation procedure. */
74
+ function latticeOf(described) {
75
+ const { slug, label } = described;
76
+ switch (described.op) {
77
+ case 'list':
78
+ case 'set':
79
+ return {
80
+ collection: slug,
81
+ label,
82
+ operation: described.op,
83
+ relation: described.relation,
84
+ target: described.target,
85
+ };
86
+ default:
87
+ return { collection: slug, label, operation: described.op };
88
+ }
89
+ }
90
+ /** The meta of a generated procedure. */
91
+ export function generatedMeta(described) {
92
+ return {
93
+ ...docs({ summary: summaryOf(described) }),
94
+ ...mcp({ effect: effects[described.op] }),
95
+ lattice: latticeOf(described),
96
+ };
97
+ }
98
+ /** The meta of a method's procedure, from its `summary` and `effect` statics. */
99
+ export function methodMeta(method) {
100
+ return {
101
+ ...docs({ summary: method.summary }),
102
+ ...mcp({ effect: method.effect }),
103
+ lattice: {
104
+ collection: method.slug,
105
+ label: method.label,
106
+ operation: 'method',
107
+ method: method.name,
108
+ },
109
+ };
110
+ }
111
+ /** A `where` entry's description for a maskable field. */
112
+ export function refusedWhere(field) {
113
+ return `Refused (VALIDATION) when the caller may not read ${field}.`;
114
+ }
115
+ /** A `sort` description for a collection with maskable fields. */
116
+ export function refusedSort(fields) {
117
+ return `Field names, "-" first for descending. Sorting on ${fields.join(', ')} is refused (VALIDATION) when the caller may not read it.`;
118
+ }
119
+ //# sourceMappingURL=describe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe.js","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,IAAI,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAkB,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAqCtD,MAAM,OAAO,GAAmD;IAC9D,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,aAAa;IACrB,GAAG,EAAE,aAAa;CACnB,CAAC;AA8CF,gGAAgG;AAChG,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,IAAI;SACR,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,KAAK,CAAC,SAAS,CAAC;SAChB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjC,IAAI,CAAC,GAAG,CAAC;SACT,WAAW,EAAE,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,MAAc;IAChC,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAClE,IAAI,4BAA4B,CAAC,I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B,CAAC;AACJ,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,UAAU,CAAuB,MAMhD;IACC,OAAO;QACL,GAAG,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QACpC,GAAG,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QACjC,OAAO,EAAE;YACP,UAAU,EAAE,MAAM,CAAC,IAAI;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,QAAQ;YACnB,MAAM,EAAE,MAAM,CAAC,IAAI;SACpB;KACF,CAAC;AACJ,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,qDAAqD,KAAK,GAAG,CAAC;AACvE,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,WAAW,CAAC,MAAyB;IACnD,OAAO,qDAAqD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,2DAA2D,CAAC;AAC3I,CAAC"}
@@ -0,0 +1,183 @@
1
+ import { z } from 'zod';
2
+ declare const issue: z.ZodObject<{
3
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
4
+ message: z.ZodString;
5
+ }, z.core.$strip>;
6
+ declare const definitions: {
7
+ VALIDATION: {
8
+ message: string;
9
+ data: z.ZodObject<{
10
+ issues: z.ZodArray<z.ZodObject<{
11
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
12
+ message: z.ZodString;
13
+ }, z.core.$strip>>;
14
+ }, z.core.$strip>;
15
+ };
16
+ UNAUTHORIZED: {
17
+ message: string;
18
+ };
19
+ FORBIDDEN: {
20
+ message: string;
21
+ };
22
+ NOT_FOUND: {
23
+ message: string;
24
+ data: z.ZodObject<{
25
+ collection: z.ZodString;
26
+ id: z.ZodString;
27
+ }, z.core.$strip>;
28
+ };
29
+ CONFLICT: {
30
+ message: string;
31
+ data: z.ZodObject<{
32
+ collection: z.ZodString;
33
+ id: z.ZodString;
34
+ }, z.core.$strip>;
35
+ };
36
+ REFERENCED: {
37
+ message: string;
38
+ data: z.ZodObject<{
39
+ collection: z.ZodString;
40
+ id: z.ZodString;
41
+ by: z.ZodObject<{
42
+ collection: z.ZodString;
43
+ field: z.ZodString;
44
+ relation: z.ZodOptional<z.ZodObject<{
45
+ collection: z.ZodString;
46
+ name: z.ZodString;
47
+ }, z.core.$strip>>;
48
+ }, z.core.$strip>;
49
+ }, z.core.$strip>;
50
+ };
51
+ };
52
+ declare const LatticeError_base: import("hexok").ErrorsHandle<"lattice", {
53
+ VALIDATION: {
54
+ message: string;
55
+ data: z.ZodObject<{
56
+ issues: z.ZodArray<z.ZodObject<{
57
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
58
+ message: z.ZodString;
59
+ }, z.core.$strip>>;
60
+ }, z.core.$strip>;
61
+ };
62
+ UNAUTHORIZED: {
63
+ message: string;
64
+ };
65
+ FORBIDDEN: {
66
+ message: string;
67
+ };
68
+ NOT_FOUND: {
69
+ message: string;
70
+ data: z.ZodObject<{
71
+ collection: z.ZodString;
72
+ id: z.ZodString;
73
+ }, z.core.$strip>;
74
+ };
75
+ CONFLICT: {
76
+ message: string;
77
+ data: z.ZodObject<{
78
+ collection: z.ZodString;
79
+ id: z.ZodString;
80
+ }, z.core.$strip>;
81
+ };
82
+ REFERENCED: {
83
+ message: string;
84
+ data: z.ZodObject<{
85
+ collection: z.ZodString;
86
+ id: z.ZodString;
87
+ by: z.ZodObject<{
88
+ collection: z.ZodString;
89
+ field: z.ZodString;
90
+ relation: z.ZodOptional<z.ZodObject<{
91
+ collection: z.ZodString;
92
+ name: z.ZodString;
93
+ }, z.core.$strip>>;
94
+ }, z.core.$strip>;
95
+ }, z.core.$strip>;
96
+ };
97
+ }>;
98
+ /** Lattice's refusals. Each reaches a ts-pf client under the same code. */
99
+ export declare class LatticeError extends LatticeError_base {
100
+ }
101
+ export type LatticeCode = keyof typeof definitions;
102
+ /** Every LatticeError code. An app may not declare one of these. */
103
+ export declare const latticeCodes: readonly string[];
104
+ /**
105
+ * The errors every procedure declares, with their statuses. VALIDATION is
106
+ * not declared: it is a ts-pf protocol code, which a contract must not
107
+ * redeclare, and clients already type its `data.issues`.
108
+ */
109
+ export declare const declaredErrors: {
110
+ UNAUTHORIZED: {
111
+ status: number;
112
+ message: string;
113
+ };
114
+ FORBIDDEN: {
115
+ status: number;
116
+ message: string;
117
+ };
118
+ NOT_FOUND: {
119
+ status: number;
120
+ message: string;
121
+ data: z.ZodObject<{
122
+ collection: z.ZodString;
123
+ id: z.ZodString;
124
+ }, z.core.$strip>;
125
+ };
126
+ CONFLICT: {
127
+ status: number;
128
+ message: string;
129
+ data: z.ZodObject<{
130
+ collection: z.ZodString;
131
+ id: z.ZodString;
132
+ }, z.core.$strip>;
133
+ };
134
+ REFERENCED: {
135
+ status: number;
136
+ message: string;
137
+ data: z.ZodObject<{
138
+ collection: z.ZodString;
139
+ id: z.ZodString;
140
+ by: z.ZodObject<{
141
+ collection: z.ZodString;
142
+ field: z.ZodString;
143
+ relation: z.ZodOptional<z.ZodObject<{
144
+ collection: z.ZodString;
145
+ name: z.ZodString;
146
+ }, z.core.$strip>>;
147
+ }, z.core.$strip>;
148
+ }, z.core.$strip>;
149
+ };
150
+ };
151
+ export type Issue = z.output<typeof issue>;
152
+ /**
153
+ * A VALIDATION error for Zod issues: each issue as Zod reports it, with
154
+ * every unknown key on its own path. A field that fails two checks has two
155
+ * issues, in the order its schema declares them.
156
+ */
157
+ export declare function invalid(issues: readonly z.core.$ZodIssue[]): import("hexok").CatalogMember<"lattice", "VALIDATION", string, {
158
+ issues: {
159
+ path: (string | number)[];
160
+ message: string;
161
+ }[];
162
+ }>;
163
+ /** `value` parsed by `schema`, or a VALIDATION error naming each path. */
164
+ export declare function parse<S extends z.core.$ZodType>(schema: S, value: unknown): z.output<S>;
165
+ /**
166
+ * An expected refusal, and the fields that describe it: a member of any
167
+ * hexok `Errors` catalog, LatticeError included, or a hexok `CodedError`
168
+ * VALIDATION. The caller can act on it, so it is not a failure. Whether a
169
+ * client sees it is `toClientError`'s decision.
170
+ */
171
+ export declare function refusal(error: unknown): {
172
+ catalog?: unknown;
173
+ code: unknown;
174
+ } | undefined;
175
+ /**
176
+ * The error a client receives. A LatticeError keeps its code, message, data
177
+ * and status. A hexok VALIDATION becomes the protocol VALIDATION. Anything
178
+ * else goes through the app's `map`; what that returns unchanged, ts-pf
179
+ * sends as INTERNAL.
180
+ */
181
+ export declare function toClientError(error: unknown, map: (error: unknown) => unknown): unknown;
182
+ export {};
183
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,KAAK;;;iBAGT,CAAC;AAIH,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBhB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,2EAA2E;AAC3E,qBAAa,YAAa,SAAQ,iBAA8B;CAAG;AAEnE,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,WAAW,CAAC;AAEnD,oEAAoE;AACpE,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAA6B,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMP,CAAC;AAErB,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,KAAK,CAAC,CAAC;AAE3C;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE;;;;;GAiB1D;AAED,0EAA0E;AAC1E,wBAAgB,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,EAC7C,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,OAAO,GACb,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAIb;AAOD;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,OAAO,GACb;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAOlD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GAC/B,OAAO,CA2BT"}
package/dist/errors.js ADDED
@@ -0,0 +1,150 @@
1
+ import { toValidationIssues } from '@ts-pf/contract';
2
+ import { PFError } from '@ts-pf/protocol';
3
+ import { CodedError, catalogBrand, Errors } from 'hexok';
4
+ import { z } from 'zod';
5
+ const issue = z.object({
6
+ path: z.array(z.union([z.string(), z.number()])),
7
+ message: z.string(),
8
+ });
9
+ const target = z.object({ collection: z.string(), id: z.string() });
10
+ const definitions = {
11
+ VALIDATION: {
12
+ message: 'Validation failed',
13
+ data: z.object({ issues: z.array(issue) }),
14
+ },
15
+ UNAUTHORIZED: { message: 'The actor is missing or invalid' },
16
+ FORBIDDEN: { message: 'The actor may not do this' },
17
+ NOT_FOUND: { message: 'No document with this id', data: target },
18
+ CONFLICT: { message: 'A document with this id already exists', data: target },
19
+ REFERENCED: {
20
+ message: 'Other documents refer to this one',
21
+ data: target.extend({
22
+ // A join collection is not in the catalog: `relation` names the
23
+ // parent collection's relation that derived it.
24
+ by: z.object({
25
+ collection: z.string(),
26
+ field: z.string(),
27
+ relation: z
28
+ .object({ collection: z.string(), name: z.string() })
29
+ .optional(),
30
+ }),
31
+ }),
32
+ },
33
+ };
34
+ /** Lattice's refusals. Each reaches a ts-pf client under the same code. */
35
+ export class LatticeError extends Errors('lattice', definitions) {
36
+ }
37
+ /** Every LatticeError code. An app may not declare one of these. */
38
+ export const latticeCodes = Object.keys(definitions);
39
+ /**
40
+ * The errors every procedure declares, with their statuses. VALIDATION is
41
+ * not declared: it is a ts-pf protocol code, which a contract must not
42
+ * redeclare, and clients already type its `data.issues`.
43
+ */
44
+ export const declaredErrors = {
45
+ UNAUTHORIZED: { ...definitions.UNAUTHORIZED, status: 401 },
46
+ FORBIDDEN: { ...definitions.FORBIDDEN, status: 403 },
47
+ NOT_FOUND: { ...definitions.NOT_FOUND, status: 404 },
48
+ CONFLICT: { ...definitions.CONFLICT, status: 409 },
49
+ REFERENCED: { ...definitions.REFERENCED, status: 409 },
50
+ };
51
+ /**
52
+ * A VALIDATION error for Zod issues: each issue as Zod reports it, with
53
+ * every unknown key on its own path. A field that fails two checks has two
54
+ * issues, in the order its schema declares them.
55
+ */
56
+ export function invalid(issues) {
57
+ return LatticeError.VALIDATION({
58
+ issues: issues.flatMap((issue) => {
59
+ const path = issue.path.map((key) => typeof key === 'symbol' ? String(key) : key);
60
+ // Zod reports every unknown key of one object as one issue. Split them
61
+ // so each path names the field or operator that is not allowed.
62
+ if (issue.code === 'unrecognized_keys') {
63
+ return issue.keys.map((key) => ({
64
+ path: [...path, key],
65
+ message: `"${key}" is not a field or not allowed on this field`,
66
+ }));
67
+ }
68
+ return [{ path, message: issue.message }];
69
+ }),
70
+ });
71
+ }
72
+ /** `value` parsed by `schema`, or a VALIDATION error naming each path. */
73
+ export function parse(schema, value) {
74
+ const result = z.safeParse(schema, value);
75
+ if (!result.success)
76
+ throw invalid(result.error.issues);
77
+ return result.data;
78
+ }
79
+ /** hexok's schema-check failure, such as `Entity.parse` or `validationError`. */
80
+ function isCodedValidation(error) {
81
+ return error instanceof CodedError && error.code === 'VALIDATION';
82
+ }
83
+ /**
84
+ * An expected refusal, and the fields that describe it: a member of any
85
+ * hexok `Errors` catalog, LatticeError included, or a hexok `CodedError`
86
+ * VALIDATION. The caller can act on it, so it is not a failure. Whether a
87
+ * client sees it is `toClientError`'s decision.
88
+ */
89
+ export function refusal(error) {
90
+ if (isCodedValidation(error))
91
+ return { code: error.code };
92
+ if (!(error instanceof Error) || !(catalogBrand in error))
93
+ return undefined;
94
+ return {
95
+ catalog: error[catalogBrand],
96
+ code: 'code' in error ? error.code : undefined,
97
+ };
98
+ }
99
+ /**
100
+ * The error a client receives. A LatticeError keeps its code, message, data
101
+ * and status. A hexok VALIDATION becomes the protocol VALIDATION. Anything
102
+ * else goes through the app's `map`; what that returns unchanged, ts-pf
103
+ * sends as INTERNAL.
104
+ */
105
+ export function toClientError(error, map) {
106
+ if (LatticeError.is(error)) {
107
+ if (error.code === 'VALIDATION') {
108
+ return new PFError({
109
+ code: error.code,
110
+ message: error.message,
111
+ data: error.data,
112
+ cause: error,
113
+ });
114
+ }
115
+ return new PFError({
116
+ code: error.code,
117
+ message: error.message,
118
+ status: declaredErrors[error.code].status,
119
+ ...('data' in error ? { data: error.data } : {}),
120
+ cause: error,
121
+ });
122
+ }
123
+ if (isCodedValidation(error)) {
124
+ return new PFError({
125
+ code: 'VALIDATION',
126
+ message: error.message,
127
+ data: { issues: toValidationIssues(issuesOf(error.data)) },
128
+ cause: error,
129
+ });
130
+ }
131
+ return map(error);
132
+ }
133
+ /** The Standard Schema issues in a hexok VALIDATION's `data`. */
134
+ function issuesOf(data) {
135
+ if (typeof data !== 'object' || data === null || !('issues' in data)) {
136
+ return [];
137
+ }
138
+ const { issues } = data;
139
+ return Array.isArray(issues) ? issues.filter(isIssue) : [];
140
+ }
141
+ function isIssue(value) {
142
+ return (typeof value === 'object' &&
143
+ value !== null &&
144
+ 'message' in value &&
145
+ typeof value.message === 'string' &&
146
+ (!('path' in value) ||
147
+ value.path === undefined ||
148
+ Array.isArray(value.path)));
149
+ }
150
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,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IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,EAAE,CAAC;QACrE,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QACjC,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC;YACjB,KAAK,CAAC,IAAI,KAAK,SAAS;YACxB,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAC7B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,80 @@
1
+ import type { Logger } from '@hexok/logger';
2
+ import type { McpEffect } from '@ts-pf/mcp/meta';
3
+ import { type StandardSchemaV1, UseCase } from 'hexok';
4
+ import { z } from 'zod';
5
+ import { CallAccess } from './access.js';
6
+ import type { AnyCollection } from './collection.js';
7
+ import { type Tenant } from './tenancy.js';
8
+ /**
9
+ * The statics every use case in a Lattice family declares. A method also
10
+ * declares `summary` (one sentence on what it does) and `effect`, which
11
+ * become its procedure's docs and MCP meta. An override declares neither:
12
+ * it keeps the operation's own.
13
+ */
14
+ export type FamilySpec = {
15
+ readonly collection: AnyCollection;
16
+ readonly input?: z.core.$ZodType;
17
+ readonly output?: z.core.$ZodType;
18
+ readonly summary?: string;
19
+ readonly effect?: McpEffect;
20
+ };
21
+ /**
22
+ * What a caller gives each call: the edge's context function, a
23
+ * `createLocalClient` context, or `build().context()`. The edge passes
24
+ * `rootLogger.child({ requestId })`; workers and tests pass their own.
25
+ */
26
+ export type CallContext<Actor> = {
27
+ readonly actor: Actor;
28
+ readonly logger: Logger;
29
+ };
30
+ /**
31
+ * The per-call context of a Lattice family: the caller's, plus the call's
32
+ * access, which Lattice adds (0023).
33
+ */
34
+ export type FamilyContext<Actor> = CallContext<Actor> & {
35
+ readonly access: CallAccess;
36
+ };
37
+ /**
38
+ * A Lattice family: a hexok `UseCase.context` factory, its actor schema, the
39
+ * id of an actor as log lines and the generated events carry it, and the
40
+ * actor's tenant. `Tenanted` is true when the family has `tenantOf`, so a
41
+ * tenanted collection in a family without it is a compile error.
42
+ */
43
+ export type Family<Actor, Tenanted extends boolean = boolean> = UseCase.ContextFactory<FamilyContext<Actor>, FamilySpec> & {
44
+ readonly actor: StandardSchemaV1<unknown, Actor>;
45
+ readonly actorId: (actor: Actor) => string;
46
+ readonly tenantOf: ((actor: Actor) => Tenant) | undefined;
47
+ /** Type-only. */
48
+ readonly '~tenanted'?: Tenanted;
49
+ };
50
+ /**
51
+ * The fields that say who made a call, for its log lines: the actor's id,
52
+ * and its tenant id or `tenancy: 'bypass'`.
53
+ */
54
+ export declare function callerFields<Actor>(family: Pick<Family<Actor>, 'actorId' | 'tenantOf'>, actor: Actor): Readonly<Record<string, string>>;
55
+ /** How a family logged an error: at info as a refusal, or at error. */
56
+ export type Logged = 'refused' | 'failed';
57
+ /** How a family logged `error`, or undefined when no family did. */
58
+ export declare function loggedByFamily(error: unknown): Logged | undefined;
59
+ /**
60
+ * Builds the app's one use case family on hexok `UseCase.context`. Before
61
+ * any member's `execute` runs, the actor must parse against `actor`, the
62
+ * input against the member's `input` static, and `ctx.access` must allow
63
+ * the member's action. Each call writes one line
64
+ * through a child of `ctx.logger`: info when it returns or a guard or
65
+ * `execute` refuses it, error when it throws anything else.
66
+ */
67
+ export declare function family<A extends StandardSchemaV1, T extends Tenant = never>(options: {
68
+ actor: A;
69
+ /** The id the call's log lines and the generated events carry as `actorId`. */
70
+ actorId: (actor: StandardSchemaV1.InferOutput<A>) => string;
71
+ /**
72
+ * The actor's tenant id, or `tenancy.bypass` for a platform actor that
73
+ * reads across tenants. Required by a framework with a tenanted
74
+ * collection.
75
+ */
76
+ tenantOf?: (actor: StandardSchemaV1.InferOutput<A>) => T;
77
+ }): Family<StandardSchemaV1.InferOutput<A>, [
78
+ T
79
+ ] extends [never] ? false : true>;
80
+ //# sourceMappingURL=family.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"family.d.ts","sourceRoot":"","sources":["../src/family.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,gBAAgB,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,cAAc,CAAC;AAGpD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,CAAC,KAAK,IAAI;IAC/B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;G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