effect-dynamodb 0.1.0 → 1.1.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 (66) hide show
  1. package/dist/DynamoClient.d.ts +3 -3
  2. package/dist/DynamoClient.d.ts.map +1 -1
  3. package/dist/DynamoClient.js +1 -3
  4. package/dist/DynamoClient.js.map +1 -1
  5. package/dist/Entity.d.ts +69 -10
  6. package/dist/Entity.d.ts.map +1 -1
  7. package/dist/Entity.js +383 -2
  8. package/dist/Entity.js.map +1 -1
  9. package/dist/KeyComposer.d.ts +14 -0
  10. package/dist/KeyComposer.d.ts.map +1 -1
  11. package/dist/KeyComposer.js +22 -1
  12. package/dist/KeyComposer.js.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/internal/EntityConfig.d.ts +33 -0
  17. package/dist/internal/EntityConfig.d.ts.map +1 -1
  18. package/dist/internal/EntitySchemas.d.ts +14 -3
  19. package/dist/internal/EntitySchemas.d.ts.map +1 -1
  20. package/dist/internal/EntitySchemas.js +41 -2
  21. package/dist/internal/EntitySchemas.js.map +1 -1
  22. package/dist/internal/EntityTypes.d.ts +35 -3
  23. package/dist/internal/EntityTypes.d.ts.map +1 -1
  24. package/dist/internal/TransactableOps.d.ts +1 -1
  25. package/dist/internal/TransactableOps.d.ts.map +1 -1
  26. package/package.json +1 -1
  27. package/dist/_AggregateCursor.d.ts +0 -44
  28. package/dist/_AggregateCursor.d.ts.map +0 -1
  29. package/dist/_AggregateCursor.js +0 -18
  30. package/dist/_AggregateCursor.js.map +0 -1
  31. package/dist/_AggregateEdges.d.ts +0 -77
  32. package/dist/_AggregateEdges.d.ts.map +0 -1
  33. package/dist/_AggregateEdges.js +0 -41
  34. package/dist/_AggregateEdges.js.map +0 -1
  35. package/dist/_AggregateSchemas.d.ts +0 -69
  36. package/dist/_AggregateSchemas.d.ts.map +0 -1
  37. package/dist/_AggregateSchemas.js +0 -194
  38. package/dist/_AggregateSchemas.js.map +0 -1
  39. package/dist/_AggregateTypes.d.ts +0 -94
  40. package/dist/_AggregateTypes.d.ts.map +0 -1
  41. package/dist/_AggregateTypes.js +0 -7
  42. package/dist/_AggregateTypes.js.map +0 -1
  43. package/dist/_EntityCombinators.d.ts +0 -155
  44. package/dist/_EntityCombinators.d.ts.map +0 -1
  45. package/dist/_EntityCombinators.js +0 -158
  46. package/dist/_EntityCombinators.js.map +0 -1
  47. package/dist/_EntityConfig.d.ts +0 -100
  48. package/dist/_EntityConfig.d.ts.map +0 -1
  49. package/dist/_EntityConfig.js +0 -7
  50. package/dist/_EntityConfig.js.map +0 -1
  51. package/dist/_EntityOps.d.ts +0 -205
  52. package/dist/_EntityOps.d.ts.map +0 -1
  53. package/dist/_EntityOps.js +0 -137
  54. package/dist/_EntityOps.js.map +0 -1
  55. package/dist/_EntitySchemas.d.ts +0 -57
  56. package/dist/_EntitySchemas.d.ts.map +0 -1
  57. package/dist/_EntitySchemas.js +0 -298
  58. package/dist/_EntitySchemas.js.map +0 -1
  59. package/dist/_EntityTypes.d.ts +0 -81
  60. package/dist/_EntityTypes.d.ts.map +0 -1
  61. package/dist/_EntityTypes.js +0 -7
  62. package/dist/_EntityTypes.js.map +0 -1
  63. package/dist/_sparse_check.d.ts +0 -2
  64. package/dist/_sparse_check.d.ts.map +0 -1
  65. package/dist/_sparse_check.js +0 -193
  66. package/dist/_sparse_check.js.map +0 -1
@@ -1,57 +0,0 @@
1
- /**
2
- * @internal Entity schema building — derived schemas and system field resolution.
3
- *
4
- * Extracted from Entity.ts for decomposition. Not part of the public API.
5
- */
6
- import { Schema } from "effect";
7
- import type { TimestampsConfig, UniqueConstraintDef, VersionedConfig } from "./_EntityConfig.js";
8
- import { type DynamoEncoding } from "./DynamoModel.js";
9
- import type { IndexDefinition } from "./KeyComposer.js";
10
- export interface ResolvedSystemFields {
11
- readonly createdAt: string | null;
12
- readonly createdAtEncoding: DynamoEncoding | null;
13
- readonly updatedAt: string | null;
14
- readonly updatedAtEncoding: DynamoEncoding | null;
15
- readonly version: string | null;
16
- }
17
- export declare const resolveSystemFields: (timestamps?: TimestampsConfig | undefined, versioned?: VersionedConfig | undefined) => ResolvedSystemFields;
18
- export declare const primaryKeyComposites: (indexes: globalThis.Record<string, IndexDefinition>) => ReadonlyArray<string>;
19
- export declare const allKeyFieldNames: (indexes: globalThis.Record<string, IndexDefinition>) => ReadonlyArray<string>;
20
- export declare const allCompositeAttributes: (indexes: globalThis.Record<string, IndexDefinition>) => ReadonlyArray<string>;
21
- export type SchemaFields = globalThis.Record<string, Schema.Top>;
22
- export declare const getFields: (model: Schema.Top) => SchemaFields;
23
- /**
24
- * Infer a default DynamoEncoding for standard Effect date schemas that lack
25
- * an explicit DynamoEncoding annotation. This enables Pattern B (pure model
26
- * with Schema.DateTimeUtcFromString etc.) to work without explicit storedAs.
27
- *
28
- * Detection uses the typeConstructor annotation from Effect's schema AST.
29
- */
30
- export declare const inferDefaultEncoding: (schema: Schema.Top) => DynamoEncoding | undefined;
31
- export interface DerivedSchemas {
32
- /** Pure model fields schema (wire format — for input validation) */
33
- readonly modelSchema: Schema.Codec<any>;
34
- /** Model fields with fromSelf for date-annotated fields (for decode after deserialization) */
35
- readonly modelDecodeSchema: Schema.Codec<any>;
36
- /** Model + system fields schema */
37
- readonly recordSchema: Schema.Codec<any>;
38
- /** Same as model (system fields auto-managed) */
39
- readonly inputSchema: Schema.Codec<any>;
40
- /** Input fields minus primary key composites — the common "create" payload */
41
- readonly createSchema: Schema.Codec<any>;
42
- /** Optional model fields minus keys and immutable */
43
- readonly updateSchema: Schema.Codec<any>;
44
- /** Primary key composites only */
45
- readonly keySchema: Schema.Codec<any>;
46
- /** Record + key attrs + __edd_e__ */
47
- readonly itemSchema: Schema.Codec<any>;
48
- /** Record fields + deletedAt for soft-deleted items */
49
- readonly deletedRecordSchema: Schema.Codec<any>;
50
- }
51
- export declare const buildDerivedSchemas: (modelFields: SchemaFields, indexes: globalThis.Record<string, IndexDefinition>, systemFields: ResolvedSystemFields, resolvedRefs?: ReadonlyArray<{
52
- readonly fieldName: string;
53
- readonly idFieldName: string;
54
- readonly identifierSchema: Schema.Top;
55
- }>) => DerivedSchemas;
56
- export declare const resolveUniqueFields: (def: UniqueConstraintDef) => ReadonlyArray<string>;
57
- //# sourceMappingURL=_EntitySchemas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_EntitySchemas.d.ts","sourceRoot":"","sources":["../src/_EntitySchemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAa,MAAM,QAAQ,CAAA;AAC1C,OAAO,KAAK,EAEV,gBAAgB,EAChB,mBAAmB,EAEnB,eAAe,EAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,cAAc,EAAsC,MAAM,kBAAkB,CAAA;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAMvD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,QAAQ,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI,CAAA;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,QAAQ,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI,CAAA;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AA0BD,eAAO,MAAM,mBAAmB,GAC9B,aAAa,gBAAgB,GAAG,SAAS,EACzC,YAAY,eAAe,GAAG,SAAS,KACtC,oBAsBF,CAAA;AAMD,eAAO,MAAM,oBAAoB,GAC/B,SAAS,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,KAClD,aAAa,CAAC,MAAM,CAOtB,CAAA;AAMD,eAAO,MAAM,gBAAgB,GAC3B,SAAS,UAAU,CAAC,MAAM,CAAC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AmB,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;CAChD;AAkBD,eAAO,MAAM,mBAAmB,GAC9B,aAAa,YAAY,EACzB,SAAS,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACnD,cAAc,oBAAoB,EAClC,eAAc,aAAa,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAAG,CAAA;CACtC,CAAM,KACN,cA6KF,CAAA;AAMD,eAAO,MAAM,mBAAmB,GAAI,KAAK,mBAAmB,KAAG,aAAa,CAAC,MAAM,CACF,CAAA"}
@@ -1,298 +0,0 @@
1
- /**
2
- * @internal Entity schema building — derived schemas and system field resolution.
3
- *
4
- * Extracted from Entity.ts for decomposition. Not part of the public API.
5
- */
6
- import { Schema, SchemaAST } from "effect";
7
- import { getEncoding, isHidden, isImmutable } from "./DynamoModel.js";
8
- /** Check if a value is a Schema (has .ast property) vs a plain config object */
9
- const isSchema = (value) => typeof value === "object" && value !== null && "ast" in value;
10
- /**
11
- * Resolve a single TimestampFieldConfig into field name + encoding.
12
- * Returns [fieldName, encoding | null].
13
- */
14
- const resolveTimestampField = (config, defaultName) => {
15
- if (config === undefined)
16
- return [defaultName, null];
17
- if (typeof config === "string")
18
- return [config, null];
19
- if (isSchema(config)) {
20
- const encoding = getEncoding(config);
21
- return [defaultName, encoding ?? null];
22
- }
23
- // Object config: { field?, schema? }
24
- const fieldName = config.field ?? defaultName;
25
- const encoding = config.schema ? (getEncoding(config.schema) ?? null) : null;
26
- return [fieldName, encoding];
27
- };
28
- export const resolveSystemFields = (timestamps, versioned) => {
29
- let createdAt = null;
30
- let createdAtEncoding = null;
31
- let updatedAt = null;
32
- let updatedAtEncoding = null;
33
- let version = null;
34
- if (timestamps === true) {
35
- createdAt = "createdAt";
36
- updatedAt = "updatedAt";
37
- }
38
- else if (typeof timestamps === "object" && timestamps !== null) {
39
- ;
40
- [createdAt, createdAtEncoding] = resolveTimestampField(timestamps.created, "createdAt");
41
- [updatedAt, updatedAtEncoding] = resolveTimestampField(timestamps.updated, "updatedAt");
42
- }
43
- if (versioned === true) {
44
- version = "version";
45
- }
46
- else if (typeof versioned === "object" && versioned !== null) {
47
- version = versioned.field ?? "version";
48
- }
49
- return { createdAt, createdAtEncoding, updatedAt, updatedAtEncoding, version };
50
- };
51
- // ---------------------------------------------------------------------------
52
- // Helper: collect primary key composite attribute names
53
- // ---------------------------------------------------------------------------
54
- export const primaryKeyComposites = (indexes) => {
55
- const primary = indexes.primary;
56
- if (!primary)
57
- return [];
58
- const composites = new Set();
59
- for (const attr of primary.pk.composite)
60
- composites.add(attr);
61
- for (const attr of primary.sk.composite)
62
- composites.add(attr);
63
- return Array.from(composites);
64
- };
65
- // ---------------------------------------------------------------------------
66
- // Helper: collect all key field names across all indexes
67
- // ---------------------------------------------------------------------------
68
- export const allKeyFieldNames = (indexes) => {
69
- const fields = new Set();
70
- for (const key of Object.keys(indexes)) {
71
- const index = indexes[key];
72
- if (index) {
73
- fields.add(index.pk.field);
74
- fields.add(index.sk.field);
75
- }
76
- }
77
- return Array.from(fields);
78
- };
79
- // ---------------------------------------------------------------------------
80
- // Helper: collect all composite attribute names across all indexes
81
- // ---------------------------------------------------------------------------
82
- export const allCompositeAttributes = (indexes) => {
83
- const attrs = new Set();
84
- for (const key of Object.keys(indexes)) {
85
- const index = indexes[key];
86
- if (index) {
87
- for (const attr of index.pk.composite)
88
- attrs.add(attr);
89
- for (const attr of index.sk.composite)
90
- attrs.add(attr);
91
- }
92
- }
93
- return Array.from(attrs);
94
- };
95
- const hasFields = (schema) => "fields" in schema && typeof schema.fields === "object";
96
- export const getFields = (model) => {
97
- if (hasFields(model))
98
- return model.fields;
99
- throw new Error("Entity model must be a Schema.Class or Schema.Struct with .fields");
100
- };
101
- /**
102
- * Infer a default DynamoEncoding for standard Effect date schemas that lack
103
- * an explicit DynamoEncoding annotation. This enables Pattern B (pure model
104
- * with Schema.DateTimeUtcFromString etc.) to work without explicit storedAs.
105
- *
106
- * Detection uses the typeConstructor annotation from Effect's schema AST.
107
- */
108
- export const inferDefaultEncoding = (schema) => {
109
- const resolved = SchemaAST.resolve(schema.ast);
110
- if (!resolved)
111
- return undefined;
112
- const tc = resolved.typeConstructor;
113
- if (tc?._tag === "effect/DateTime.Utc")
114
- return { storage: "string", domain: "DateTime.Utc" };
115
- if (tc?._tag === "effect/DateTime.Zoned")
116
- return { storage: "string", domain: "DateTime.Zoned" };
117
- // Check for native Date via meta annotation
118
- const meta = resolved.meta;
119
- if (meta?._tag === "isDateValid")
120
- return { storage: "string", domain: "Date" };
121
- return undefined;
122
- };
123
- /**
124
- * Map a DynamoEncoding domain type to its "from self" Schema.
125
- * Used in record/item schemas so Schema.decode accepts domain values
126
- * directly (after deserializeDateFields has converted storage→domain).
127
- */
128
- const dateFromSelfSchema = (encoding) => {
129
- switch (encoding.domain) {
130
- case "DateTime.Utc":
131
- return Schema.DateTimeUtc;
132
- case "DateTime.Zoned":
133
- return Schema.DateTimeZoned;
134
- case "Date":
135
- return Schema.DateValid;
136
- }
137
- };
138
- export const buildDerivedSchemas = (modelFields, indexes, systemFields, resolvedRefs = []) => {
139
- // --- Build fromSelf field map for date fields ---
140
- // These replace transform schemas with their "from self" variants so
141
- // Schema.decode accepts domain values after storage→domain conversion.
142
- // Checks both explicit DynamoEncoding annotations AND inferred defaults
143
- // from standard Effect date schemas (Pattern B: pure model).
144
- const fromSelfFields = {};
145
- for (const [fieldName, fieldSchema] of Object.entries(modelFields)) {
146
- const encoding = getEncoding(fieldSchema) ?? inferDefaultEncoding(fieldSchema);
147
- if (encoding) {
148
- fromSelfFields[fieldName] = dateFromSelfSchema(encoding);
149
- }
150
- }
151
- // --- Model Schema: pure model fields (accepts wire format for input decode) ---
152
- const modelSchema = Schema.Struct(modelFields);
153
- // --- Model Decode Schema: model fields with fromSelf for date-annotated fields ---
154
- // Used in decodeAs after deserializeDateFields has converted storage→domain.
155
- const modelDecodeSchema = Object.keys(fromSelfFields).length > 0
156
- ? Schema.Struct({ ...modelFields, ...fromSelfFields })
157
- : modelSchema;
158
- // --- Record Schema: model + system fields ---
159
- // For date-annotated fields, use "from self" schemas (accept domain values directly)
160
- const systemSchemaFields = {};
161
- if (systemFields.createdAt) {
162
- // Custom encoding → use fromSelf (deserializeDateFields handles storage→domain)
163
- // Default → use DateTimeUtcFromString (ISO string → DateTime.Utc)
164
- systemSchemaFields[systemFields.createdAt] = systemFields.createdAtEncoding
165
- ? Schema.DateTimeUtc
166
- : Schema.DateTimeUtcFromString;
167
- }
168
- if (systemFields.updatedAt) {
169
- systemSchemaFields[systemFields.updatedAt] = systemFields.updatedAtEncoding
170
- ? Schema.DateTimeUtc
171
- : Schema.DateTimeUtcFromString;
172
- }
173
- if (systemFields.version) {
174
- systemSchemaFields[systemFields.version] = Schema.Number;
175
- }
176
- const recordSchema = Schema.Struct({
177
- ...modelFields,
178
- ...fromSelfFields,
179
- ...systemSchemaFields,
180
- });
181
- // --- Input Schema: ref-aware (swap ref fields for ID fields when refs present) ---
182
- const refFieldSet = new Set(resolvedRefs.map((r) => r.fieldName));
183
- const inputSchema = resolvedRefs.length > 0
184
- ? (() => {
185
- const inputFields = {};
186
- for (const [key, field] of Object.entries(modelFields)) {
187
- if (refFieldSet.has(key))
188
- continue; // skip ref fields
189
- inputFields[key] = field;
190
- }
191
- // Add ID fields for each ref (uses the ref entity's identifier schema for branded types)
192
- for (const ref of resolvedRefs) {
193
- inputFields[ref.idFieldName] = ref.identifierSchema;
194
- }
195
- return Schema.Struct(inputFields);
196
- })()
197
- : modelSchema;
198
- // --- Create Schema: input fields minus primary key composites ---
199
- const pkComposites = new Set(primaryKeyComposites(indexes));
200
- const createFieldsAcc = {};
201
- for (const [key, field] of Object.entries(modelFields)) {
202
- if (pkComposites.has(key))
203
- continue; // skip PK composites (auto-generated)
204
- if (refFieldSet.has(key))
205
- continue; // skip ref fields (replaced by ID fields)
206
- createFieldsAcc[key] = field;
207
- }
208
- // Add ID fields for each ref (skip if the ref field IS a PK composite)
209
- for (const ref of resolvedRefs) {
210
- if (pkComposites.has(ref.fieldName))
211
- continue;
212
- createFieldsAcc[ref.idFieldName] = ref.identifierSchema;
213
- }
214
- const createSchema = Schema.Struct(createFieldsAcc);
215
- // --- Update Schema: optional model fields minus key composites & immutable ---
216
- const updateFieldsAcc = {};
217
- for (const [key, field] of Object.entries(modelFields)) {
218
- if (pkComposites.has(key))
219
- continue;
220
- if (isImmutable(field))
221
- continue;
222
- if (refFieldSet.has(key))
223
- continue; // skip ref fields in update (replaced by ID fields)
224
- updateFieldsAcc[key] = Schema.optional(field);
225
- }
226
- // Add optional ID fields for each ref in update (uses ref entity's identifier schema)
227
- for (const ref of resolvedRefs) {
228
- if (pkComposites.has(ref.fieldName))
229
- continue; // ref on PK composite — skip
230
- if (isImmutable(modelFields[ref.fieldName]))
231
- continue; // immutable ref — skip
232
- updateFieldsAcc[ref.idFieldName] = Schema.optional(ref.identifierSchema);
233
- }
234
- const updateSchema = Schema.Struct(updateFieldsAcc);
235
- // --- Key Schema: primary key composite attributes only ---
236
- const keyCompositeNames = primaryKeyComposites(indexes);
237
- const keyFields = {};
238
- for (const name of keyCompositeNames) {
239
- const field = modelFields[name];
240
- if (field)
241
- keyFields[name] = field;
242
- }
243
- const keySchema = Schema.Struct(keyFields);
244
- // --- Item Schema: record + key attrs (pk, sk, gsi*) + __edd_e__ ---
245
- const keyAttrFields = {};
246
- for (const fieldName of allKeyFieldNames(indexes)) {
247
- keyAttrFields[fieldName] = Schema.String;
248
- }
249
- const itemSchema = Schema.Struct({
250
- ...modelFields,
251
- ...fromSelfFields,
252
- ...systemSchemaFields,
253
- ...keyAttrFields,
254
- __edd_e__: Schema.String,
255
- });
256
- // --- Deleted Record Schema: record + deletedAt ---
257
- const deletedRecordSchema = Schema.Struct({
258
- ...modelFields,
259
- ...fromSelfFields,
260
- ...systemSchemaFields,
261
- deletedAt: Schema.String,
262
- });
263
- // --- Hidden-aware decode schemas: strip DynamoModel.Hidden fields from model/record ---
264
- // These are used for "model" and "record" decode modes. Hidden fields are
265
- // still present in "item" and "native" modes.
266
- const hiddenFieldNames = new Set();
267
- for (const [fieldName, fieldSchema] of Object.entries(modelFields)) {
268
- if (isHidden(fieldSchema))
269
- hiddenFieldNames.add(fieldName);
270
- }
271
- const hasHiddenFields = hiddenFieldNames.size > 0;
272
- const modelDecodeVisibleSchema = hasHiddenFields
273
- ? Schema.Struct(Object.fromEntries(Object.entries({ ...modelFields, ...fromSelfFields }).filter(([k]) => !hiddenFieldNames.has(k))))
274
- : modelDecodeSchema;
275
- const recordVisibleSchema = hasHiddenFields
276
- ? Schema.Struct(Object.fromEntries(Object.entries({
277
- ...modelFields,
278
- ...fromSelfFields,
279
- ...systemSchemaFields,
280
- }).filter(([k]) => !hiddenFieldNames.has(k))))
281
- : recordSchema;
282
- return {
283
- modelSchema: modelSchema,
284
- modelDecodeSchema: modelDecodeVisibleSchema,
285
- recordSchema: recordVisibleSchema,
286
- inputSchema: inputSchema,
287
- createSchema: createSchema,
288
- updateSchema: updateSchema,
289
- keySchema: keySchema,
290
- itemSchema: itemSchema,
291
- deletedRecordSchema: deletedRecordSchema,
292
- };
293
- };
294
- // ---------------------------------------------------------------------------
295
- // Unique constraint field resolver
296
- // ---------------------------------------------------------------------------
297
- export const resolveUniqueFields = (def) => Array.isArray(def) ? def : def.fields;
298
- //# sourceMappingURL=_EntitySchemas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_EntitySchemas.js","sourceRoot":"","sources":["../src/_EntitySchemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAQ1C,OAAO,EAAuB,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAe1F,gFAAgF;A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AAS,EAAE,SAAyB;QACpC,UAAU,EAAE,UAA0B;QACtC,mBAAmB,EAAE,mBAAmC;KACzD,CAAA;AACH,CAAC,CAAA;AAED,8EAA8E;AAC9E,mCAAmC;AACnC,8EAA8E;AAE9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAwB,EAAyB,EAAE,CACrF,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAE,GAA4C,CAAC,MAAM,CAAA"}
@@ -1,81 +0,0 @@
1
- /**
2
- * @internal Entity type-level computations — derived types for Entity operations.
3
- *
4
- * Extracted from Entity.ts for decomposition. Not part of the public API.
5
- */
6
- import type { DateTime, Schema } from "effect";
7
- import type { RefNotFound } from "./Errors.js";
8
- /** Extract the model's Type directly — preserves Schema.Class name (e.g. `User`) */
9
- export type ModelType<TModel extends Schema.Top> = Schema.Schema.Type<TModel>;
10
- /** Extract primary key composite attribute names as a string union */
11
- export type PrimaryKeyComposites<TIndexes> = TIndexes extends {
12
- readonly primary: {
13
- readonly pk: {
14
- readonly composite: infer PKC extends ReadonlyArray<string>;
15
- };
16
- readonly sk: {
17
- readonly composite: infer SKC extends ReadonlyArray<string>;
18
- };
19
- };
20
- } ? PKC[number] | SKC[number] : string;
21
- /** Compute system fields added by timestamps and versioned config */
22
- export type SystemFieldsType<TTimestamps, TVersioned> = ([TTimestamps] extends [undefined] ? {} : [TTimestamps] extends [false] ? {} : {
23
- readonly createdAt: DateTime.Utc;
24
- readonly updatedAt: DateTime.Utc;
25
- }) & ([TVersioned] extends [undefined] ? {} : [TVersioned] extends [false] ? {} : {
26
- readonly version: number;
27
- });
28
- /** Entity key type: Pick model fields by primary key composites */
29
- export type EntityKeyType<TModel extends Schema.Top, TIndexes> = Pick<ModelType<TModel>, PrimaryKeyComposites<TIndexes> & keyof ModelType<TModel>>;
30
- /** Entity record type: model fields + system fields */
31
- export type EntityRecordType<TModel extends Schema.Top, TTimestamps, TVersioned> = ModelType<TModel> & SystemFieldsType<TTimestamps, TVersioned>;
32
- /** Entity input type: same as model fields (system fields auto-managed) */
33
- export type EntityInputType<TModel extends Schema.Top> = ModelType<TModel>;
34
- /** Entity update type: partial model fields minus primary key composites */
35
- export type EntityUpdateType<TModel extends Schema.Top, TIndexes> = Partial<Omit<ModelType<TModel>, PrimaryKeyComposites<TIndexes>>>;
36
- /** Extract PK-only composite attribute names (excludes SK) */
37
- type PrimaryPkOnlyComposites<TIndexes> = TIndexes extends {
38
- readonly primary: {
39
- readonly pk: {
40
- readonly composite: infer PKC extends ReadonlyArray<string>;
41
- };
42
- };
43
- } ? PKC[number] : never;
44
- /** Extract the Entity from a ref value `{ entity: Entity, cascade?: ... }`. */
45
- export type ExtractRefEntity<R> = R extends {
46
- readonly entity: infer E;
47
- } ? E : never;
48
- /** Extract the identifier value type from a ref Entity's PK composites.
49
- * For an entity with `pk: { composite: ["id"] }` and `id: TeamId`, yields `TeamId`. */
50
- type EntityIdentifierValue<E> = ExtractRefEntity<E> extends {
51
- readonly model: infer M extends Schema.Top;
52
- readonly indexes: infer I;
53
- } ? ModelType<M>[PrimaryPkOnlyComposites<I> & keyof ModelType<M>] : string;
54
- /** Entity ref input type: when refs present, replace ref fields with branded ID fields */
55
- export type EntityRefInputType<TModel extends Schema.Top, TRefs> = [TRefs] extends [undefined] ? ModelType<TModel> : Omit<ModelType<TModel>, keyof TRefs & string> & {
56
- readonly [K in keyof TRefs & string as `${K}Id`]: EntityIdentifierValue<TRefs[K]>;
57
- };
58
- /** Entity ref update type: when refs present, swap ref fields for optional branded ID fields */
59
- export type EntityRefUpdateType<TModel extends Schema.Top, TIndexes, TRefs> = [TRefs] extends [
60
- undefined
61
- ] ? EntityUpdateType<TModel, TIndexes> : Partial<Omit<ModelType<TModel>, PrimaryKeyComposites<TIndexes> | (keyof TRefs & string)>> & {
62
- readonly [K in keyof TRefs & string as `${K}Id`]?: EntityIdentifierValue<TRefs[K]>;
63
- };
64
- /** Error type contribution from refs — never when no refs, RefNotFound when refs present */
65
- export type RefErrors<TRefs> = [TRefs] extends [undefined] ? never : RefNotFound;
66
- /** Extract pk composite names for a specific index */
67
- export type IndexPkComposites<TIndexes, K extends keyof TIndexes> = TIndexes[K] extends {
68
- readonly pk: {
69
- readonly composite: infer PKC extends ReadonlyArray<string>;
70
- };
71
- } ? PKC[number] : never;
72
- /** Extract sk composite names for a specific index */
73
- export type IndexSkComposites<TIndexes, K extends keyof TIndexes> = TIndexes[K] extends {
74
- readonly sk: {
75
- readonly composite: infer SKC extends ReadonlyArray<string>;
76
- };
77
- } ? SKC[number] : never;
78
- /** Compute the typed query input for a specific index: PK composites required, SK composites optional */
79
- export type IndexPkInput<TModel extends Schema.Top, TIndexes, K extends keyof TIndexes> = Pick<ModelType<TModel>, IndexPkComposites<TIndexes, K> & keyof ModelType<TModel>> & Partial<Pick<ModelType<TModel>, IndexSkComposites<TIndexes, K> & keyof ModelType<TModel>>>;
80
- export {};
81
- //# sourceMappingURL=_EntityTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_EntityTypes.d.ts","sourceRoot":"","sources":["../src/_EntityTypes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAM9C,oFAAoF;AACpF,MAAM,MAAM,SAAS,CAAC,MAAM,SAAS,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAE7E,sEAAsE;AACtE,MAAM,MAAM,oBAAoB,CAAC,QAAQ,IAAI,QAAQ,SAAS;IAC5D,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,EAAE,EAAE;YAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,aAAa,CAAC,MAAM,CAAC,CAAA;SAAE,CAAA;Q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AE;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,aAAa,CAAC,MAAM,CAAC,CAAA;KAAE,CAAA;CAC7E,GACG,GAAG,CAAC,MAAM,CAAC,GACX,KAAK,CAAA;AAET,yGAAyG;AACzG,MAAM,MAAM,YAAY,CAAC,MAAM,SAAS,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,SAAS,MAAM,QAAQ,IAAI,IAAI,CAC5F,SAAS,CAAC,MAAM,CAAC,EACjB,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CACzD,GACC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA"}
@@ -1,7 +0,0 @@
1
- /**
2
- * @internal Entity type-level computations — derived types for Entity operations.
3
- *
4
- * Extracted from Entity.ts for decomposition. Not part of the public API.
5
- */
6
- export {};
7
- //# sourceMappingURL=_EntityTypes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_EntityTypes.js","sourceRoot":"","sources":["../src/_EntityTypes.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=_sparse_check.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_sparse_check.d.ts","sourceRoot":"","sources":["../src/_sparse_check.ts"],"names":[],"mappings":""}