@webda/models 0.0.0-stage → 4.0.0-beta.3

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 (51) hide show
  1. package/LICENSE +166 -0
  2. package/README.md +146 -2
  3. package/lib/index.d.ts +11 -0
  4. package/lib/index.d.ts.map +1 -0
  5. package/lib/index.js +11 -0
  6. package/lib/index.js.map +1 -0
  7. package/lib/mock.d.ts +72 -0
  8. package/lib/mock.d.ts.map +1 -0
  9. package/lib/mock.js +83 -0
  10. package/lib/mock.js.map +1 -0
  11. package/lib/model.model.d.ts +247 -0
  12. package/lib/model.model.d.ts.map +1 -0
  13. package/lib/model.model.js +277 -0
  14. package/lib/model.model.js.map +1 -0
  15. package/lib/relations.d.ts +705 -0
  16. package/lib/relations.d.ts.map +1 -0
  17. package/lib/relations.js +938 -0
  18. package/lib/relations.js.map +1 -0
  19. package/lib/repositories/abstract.d.ts +124 -0
  20. package/lib/repositories/abstract.d.ts.map +1 -0
  21. package/lib/repositories/abstract.js +249 -0
  22. package/lib/repositories/abstract.js.map +1 -0
  23. package/lib/repositories/conformance.d.ts +40 -0
  24. package/lib/repositories/conformance.d.ts.map +1 -0
  25. package/lib/repositories/conformance.js +38 -0
  26. package/lib/repositories/conformance.js.map +1 -0
  27. package/lib/repositories/event.d.ts +100 -0
  28. package/lib/repositories/event.d.ts.map +1 -0
  29. package/lib/repositories/event.js +226 -0
  30. package/lib/repositories/event.js.map +1 -0
  31. package/lib/repositories/hooks.d.ts +88 -0
  32. package/lib/repositories/hooks.d.ts.map +1 -0
  33. package/lib/repositories/hooks.js +105 -0
  34. package/lib/repositories/hooks.js.map +1 -0
  35. package/lib/repositories/memory.d.ts +208 -0
  36. package/lib/repositories/memory.d.ts.map +1 -0
  37. package/lib/repositories/memory.js +446 -0
  38. package/lib/repositories/memory.js.map +1 -0
  39. package/lib/repositories/repository.d.ts +238 -0
  40. package/lib/repositories/repository.d.ts.map +1 -0
  41. package/lib/repositories/repository.js +19 -0
  42. package/lib/repositories/repository.js.map +1 -0
  43. package/lib/storable.d.ts +200 -0
  44. package/lib/storable.d.ts.map +1 -0
  45. package/lib/storable.js +66 -0
  46. package/lib/storable.js.map +1 -0
  47. package/lib/types.d.ts +230 -0
  48. package/lib/types.d.ts.map +1 -0
  49. package/lib/types.js +12 -0
  50. package/lib/types.js.map +1 -0
  51. package/package.json +60 -3
package/lib/types.d.ts ADDED
@@ -0,0 +1,230 @@
1
+ import { Attributes, FilterAttributes, Merge } from "@webda/tsc-esm";
2
+ /** Any function signature. */
3
+ type AnyMethod = (...args: any[]) => any;
4
+ /**
5
+ * Extract only data properties from T, filtering out symbol keys and methods.
6
+ */
7
+ type HelperProperties<T> = {
8
+ [K in keyof T as K extends symbol ? never : T[K] extends AnyMethod ? never : K]: T[K];
9
+ };
10
+ /**
11
+ * Default helper shape for a model.
12
+ *
13
+ * Filters out functions and symbol keys, leaving only data properties.
14
+ */
15
+ export type DefaultHelper<T extends object> = HelperProperties<T>;
16
+ /**
17
+ * Allow passing objects with values that can be deserialized into the original type.
18
+ */
19
+ export type Helpers<T extends object> = DefaultHelper<T>;
20
+ /**
21
+ * Proxy type for models that will define getters/setters for any properties that have
22
+ * more than one possible type (like Date which can be a string, number or Date)
23
+ *
24
+ * Will need to use dynamic module and type to generate the ProxyInterface at build time
25
+ * Goal is to use a 'webda.d.ts' file that will be generated at build time and use a @webda/types module
26
+ * for virtual import
27
+ *
28
+ * for now we just return the original type
29
+ */
30
+ /**
31
+ * Proxy helper type for models.
32
+ *
33
+ * Intended to expose properties with multiple input forms (e.g. `Date | string | number`).
34
+ * Currently returns the original type.
35
+ */
36
+ export type ProxiedHelpers<T extends object> = T;
37
+ /**
38
+ * Define Webda fields on a class
39
+ *
40
+ * - Requires to have the .webda/module.d.ts file in your tsconfig "types" array
41
+ * - Webda will automatically pick up the fields defined here for serialization, deserialization, validation, etc.
42
+ *
43
+ * @returns The same class constructor, unchanged.
44
+ */
45
+ export declare function WebdaFieldsMixIn<T extends object>(clazz: {
46
+ new (...args: any[]): T;
47
+ }): {
48
+ new (...args: any[]): T;
49
+ };
50
+ /**
51
+ * Parameters accepted by `Model.load`, combining model properties and helper overrides.
52
+ */
53
+ export type LoadParameters<Model extends object, Helpers extends object = DefaultHelper<Model>> = Partial<Merge<Model, Helpers>>;
54
+ /**
55
+ * JSON-friendly view of a type.
56
+ *
57
+ * If the object has `toJSON()`, use its return type; otherwise, fallback to
58
+ * attributes-only object or the original type.
59
+ */
60
+ export type JSONed<T> = T extends {
61
+ toJSON: () => any;
62
+ } ? ReturnType<T["toJSON"]> : T extends Array<any> ? T : T extends object ? Pick<T, Extract<Attributes<T>, string>> : T;
63
+ /**
64
+ * Return keys of T whose value extends U (inverse of FilterOutAttributes).
65
+ */
66
+ type FilterOutAttributes2<T, U> = {
67
+ [K in keyof T]: T[K] extends U ? K : never;
68
+ }[keyof T];
69
+ /**
70
+ * DTO representation of a type, respecting `toDTO()` if available.
71
+ */
72
+ export type DTO<T> = T extends {
73
+ toDTO: () => infer R;
74
+ } ? R : SelfDTO<T>;
75
+ /**
76
+ * Deep DTO representation of objects, converting properties recursively and respecting `toDTO()` if available.
77
+ * If `toDTO()` is present, its return type is used directly without further recursion.
78
+ */
79
+ export type SelfDTO<T> = T extends bigint ? string : T extends Array<infer U> ? Array<SelfDTO<U>> : T extends Map<string, infer MV> ? Record<string, SelfDTO<MV>> : T extends Set<infer US> ? Array<SelfDTO<US>> : T extends RegExp ? string : T extends object ? {
80
+ [K in Extract<FilterOutAttributes2<T, Function>, string>]: T[K] extends bigint ? string : T[K] extends Array<infer U> ? Array<SelfDTO<U>> : T[K] extends Map<string, infer MV> ? Record<string, SelfDTO<MV>> : T[K] extends Set<infer US> ? Array<SelfDTO<US>> : T[K] extends RegExp ? string : T[K] extends object ? SelfDTO<T[K]> : T[K];
81
+ } : T;
82
+ /**
83
+ * Serialized representation of a type, respecting `toJSON()` if available.
84
+ */
85
+ export type Serialized<T> = T extends {
86
+ toJSON: () => infer R;
87
+ } ? R : SelfSerialized<T>;
88
+ /**
89
+ * Deep serialization of objects into JSON-compatible shapes.
90
+ */
91
+ export type SelfSerialized<T> = T extends bigint ? string : T extends Array<infer U> ? Array<SelfSerialized<U>> : T extends Map<string, infer MV> ? Record<string, SelfSerialized<MV>> : T extends Set<infer US> ? Array<SelfSerialized<US>> : T extends RegExp ? string : T extends object ? {
92
+ [K in Extract<FilterOutAttributes2<T, Function>, string>]: T[K] extends bigint ? string : T[K] extends Array<infer U> ? Array<SelfSerialized<U>> : T[K] extends Map<string, infer MV> ? Record<string, SelfSerialized<MV>> : T[K] extends Set<infer US> ? Array<SelfSerialized<US>> : T[K] extends RegExp ? string : T[K] extends object ? SelfSerialized<T[K]> : T[K];
93
+ } : T;
94
+ /**
95
+ * JSON-safe mapping of a model's attributes.
96
+ */
97
+ export type SelfJSONed<T extends object> = {
98
+ [K in Extract<Attributes<T>, string>]: JSONed<T[K]>;
99
+ };
100
+ /**
101
+ * Map of custom deserializers per attribute.
102
+ */
103
+ export type Deserializers<T extends {
104
+ load: (data: T) => any;
105
+ }> = {
106
+ [K in Attributes<T>]?: (v: any) => T[K];
107
+ };
108
+ /**
109
+ * Return all properties of a type that are not functions.
110
+ */
111
+ type PropertyNames<T extends object> = {
112
+ [K in keyof T]: T[K] extends Function ? never : K;
113
+ }[keyof T];
114
+ /**
115
+ * Return dot-notated paths for non-function properties, recursing into sub-objects.
116
+ *
117
+ * If Filter type is specified, only returns paths where the property type extends Filter.
118
+ *
119
+ * Example: { a: { b: string } } -> "a" | "a.b"
120
+ * Example with Filter=string: { a: string, b: { c: string, d: number } } -> "a" | "b.c"
121
+ */
122
+ export type PropertyPaths<T extends object, Filter = never> = [Filter] extends [never] ? _NonFunctionPropertyPaths<T> : _FilteredPropertyPaths<T, Filter>;
123
+ /** JavaScript primitive types. */
124
+ type Primitive = string | number | boolean | bigint | symbol | null | undefined;
125
+ /** Recursively builds dot-notated paths for non-function properties. */
126
+ type _NonFunctionPropertyPaths<T> = {
127
+ [K in Extract<keyof T, string>]: T[K] extends Function ? never : T[K] extends Primitive | Date | RegExp ? K : T[K] extends Array<any> | Map<any, any> | Set<any> ? K : T[K] extends object ? K | `${K}.${_NonFunctionPropertyPaths<T[K]>}` : K;
128
+ }[Extract<keyof T, string>];
129
+ /** Recursively builds dot-notated paths for properties whose type extends Filter. */
130
+ type _FilteredPropertyPaths<T, Filter> = {
131
+ [K in Extract<keyof T, string>]: T[K] extends Function ? never : (T[K] extends Filter ? K : never) | (T[K] extends object ? `${K}.${_FilteredPropertyPaths<T[K], Filter>}` : never);
132
+ }[Extract<keyof T, string>];
133
+ /**
134
+ * Return dot-notated paths for non-function properties, recursing into sub-objects.
135
+ *
136
+ * Example: { a: { b: number }, c: number } -> "a.b" | "c"
137
+ */
138
+ export type NumericPropertyPaths<T extends object> = PropertyPaths<T, number>;
139
+ /** Resolve the type at a dot-notated path K in T. */
140
+ type _PropertyPathType<T, K extends string> = K extends `${infer Head}.${infer Tail}` ? Head extends keyof T ? _PropertyPathType<T[Head], Tail> : never : K extends keyof T ? T[K] : never;
141
+ /**
142
+ * Get the type of the property at the given dot-notation path K in T.
143
+ * e.g. PropertyPathType<{ a: { b: number } }, "a.b"> → number
144
+ */
145
+ export type PropertyPathType<T extends object, K extends PropertyPaths<T>> = _PropertyPathType<T, K>;
146
+ /**
147
+ * Detect whether `T` is `any`.
148
+ */
149
+ export type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
150
+ /**
151
+ * Determine whether `Key` is optional in `Type`.
152
+ */
153
+ export type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
154
+ /**
155
+ * Extract optional keys from a type.
156
+ */
157
+ export type OptionalKeysOf<Type extends object> = Type extends unknown ? keyof {
158
+ [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never;
159
+ } & keyof Type : never;
160
+ /** Non-optional, non-function property keys of a type. */
161
+ type RequiredAttributes<Type extends object> = Exclude<Exclude<PropertyNames<Type>, OptionalKeysOf<Type>>, undefined>;
162
+ /**
163
+ * Extract the parameter type accepted by `Model.load`.
164
+ */
165
+ export type PartialModelParameters<T extends {
166
+ load: (data: any) => any;
167
+ }> = Parameters<T["load"]>[0];
168
+ /**
169
+ * Parameters for `Model.load`, with required keys enforced.
170
+ */
171
+ export type ModelParameters<T extends {
172
+ load: (data: any) => any;
173
+ }, K extends keyof T = RequiredAttributes<T>> = Required<Pick<PartialModelParameters<T>, K>> | Partial<Omit<PartialModelParameters<T>, K>>;
174
+ /**
175
+ * Map type to only numeric properties.
176
+ */
177
+ export type OnlyNumbers<T> = {
178
+ [K in keyof T as T[K] extends number ? K : never]: T[K];
179
+ };
180
+ /**
181
+ * Plain JSON-able object representation of a type.
182
+ */
183
+ export type Pojo<T extends object> = {
184
+ [P in Extract<keyof Omit<T, FilterAttributes<T, Function>>, string | number>]: JSONed<T[P]>;
185
+ };
186
+ /**
187
+ * Extract the parameter type of a `set()` method if present.
188
+ */
189
+ type SetMethodParam<T> = T extends {
190
+ set(value: infer V): any;
191
+ } ? V : never;
192
+ /**
193
+ * Coercion rules: widen known types that accept alternate input forms.
194
+ * Mirrors DEFAULT_COERCIONS from @webda/content-mapper.
195
+ */
196
+ type Coerce<T> = T extends Date ? string | number | Date : never;
197
+ /**
198
+ * Resolve what a property setter accepts.
199
+ *
200
+ * 1. If the type has a set() method → use its parameter type (union with T)
201
+ * 2. If the type is a known coercion target (Date) → widen
202
+ * 3. Otherwise → T unchanged
203
+ */
204
+ type SetterOf<T> = [SetMethodParam<T>] extends [never] ? [Coerce<T>] extends [never] ? T : Coerce<T> : SetMethodParam<T> | T;
205
+ /**
206
+ * The "setter view" of an object: each data property is mapped
207
+ * to the type it accepts on assignment.
208
+ */
209
+ export type Settable<T extends object> = {
210
+ [K in Extract<keyof T, string> as T[K] extends Function ? never : K]: SetterOf<T[K]>;
211
+ };
212
+ /**
213
+ * Marker interface to opt a class into automatic accessor generation.
214
+ *
215
+ * Classes implementing this interface will have their properties whose types
216
+ * have a `set` method (or are in the coercion registry) transformed into
217
+ * getter/setter pairs — just like model classes.
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * class MFA implements Accessors {
222
+ * secret!: SecretString; // SecretString has set(value: string)
223
+ * // → getter returns SecretString, setter accepts string | SecretString
224
+ * }
225
+ * ```
226
+ */
227
+ export interface Accessors {
228
+ }
229
+ export {};
230
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAuB,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE1F,8BAA8B;AAC9B,KAAK,SAAS,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAEzC;;GAEG;AACH,KAAK,gBAAgB,CAAC,CAAC,IAAI;KACxB,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACtF,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAKlE;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;AAEzD;;;;;;;;;GASG;AACH;;;;;GAKG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC;AACjD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE;IAAE,KAAK,GAAG,IAAI,EAAE,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AAI;KACtC,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,KAAK,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACrF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,SAAS;CAAG"}
package/lib/types.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Define Webda fields on a class
3
+ *
4
+ * - Requires to have the .webda/module.d.ts file in your tsconfig "types" array
5
+ * - Webda will automatically pick up the fields defined here for serialization, deserialization, validation, etc.
6
+ *
7
+ * @returns The same class constructor, unchanged.
8
+ */
9
+ export function WebdaFieldsMixIn(clazz) {
10
+ return clazz;
11
+ }
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA4CA;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAmB,KAAkC;IACnF,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "@webda/models",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "4.0.0-beta.3",
4
+ "description": "Webda Models implementation",
5
+ "main": "lib/index.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/loopingz/webda.io.git"
9
+ },
10
+ "keywords": [
11
+ "webda",
12
+ "modda"
13
+ ],
14
+ "files": [
15
+ "lib",
16
+ "package.json"
17
+ ],
18
+ "author": "loopingz",
19
+ "license": "LGPL-3.0-only",
20
+ "bugs": {
21
+ "url": "https://github.com/loopingz/webda.io/issues"
22
+ },
23
+ "homepage": "https://github.com/loopingz/webda.io#readme",
24
+ "dependencies": {
25
+ "@types/mocha": "^10.0.10"
26
+ },
27
+ "peerDependencies": {
28
+ "@webda/ql": "4.0.0-beta.3",
29
+ "@webda/utils": "4.0.0-beta.3"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "25.5.0",
36
+ "@vitest/coverage-v8": "^4.1.2",
37
+ "skott": "^0.35.8",
38
+ "type-fest": "^5.5.0",
39
+ "vitest": "^4.1.2",
40
+ "vite": "^6.0.0",
41
+ "@webda/serialize": "^4.0.0-beta.3",
42
+ "@webda/test": "^4.0.0-beta.3",
43
+ "@webda/tsc-esm": "4.0.0-beta.3",
44
+ "@webda/compiler": "^4.0.0-beta.3"
45
+ },
46
+ "type": "module",
47
+ "engines": {
48
+ "node": ">=22.0.0"
49
+ },
50
+ "scripts": {
51
+ "build": "webdac build",
52
+ "build:watch": "webdac build --watch",
53
+ "lint": "eslint",
54
+ "lint:fix": "eslint --fix",
55
+ "test": "vitest run",
56
+ "test:watch": "vitest",
57
+ "test:coverage": "vitest run --coverage",
58
+ "format": "prettier --check src/**/*",
59
+ "format:fix": "prettier --write src/**/*",
60
+ "deps:graph": "skott --showCircularDependencies --no-trackTypeOnlyDependencies --displayMode=raw -e .ts",
61
+ "codemod": "jscodeshift --parser=ts --extensions=tsx,ts -t ../codemod/current.mjs src"
62
+ }
6
63
  }