@based/schema 5.0.0-alpha.8 → 5.0.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 (49) hide show
  1. package/dist/def/addEdges.js +30 -3
  2. package/dist/def/createEmptyDef.d.ts +13 -9
  3. package/dist/def/createEmptyDef.js +7 -3
  4. package/dist/def/defaultMap.d.ts +3 -0
  5. package/dist/def/defaultMap.js +31 -0
  6. package/dist/def/fillEmptyMain.d.ts +2 -2
  7. package/dist/def/fillEmptyMain.js +14 -8
  8. package/dist/def/index.d.ts +2 -1
  9. package/dist/def/index.js +2 -1
  10. package/dist/def/makeSeparateSort.js +6 -6
  11. package/dist/def/makeSeparateTextSort.js +12 -12
  12. package/dist/def/refSet.d.ts +7 -0
  13. package/dist/def/refSet.js +25 -0
  14. package/dist/def/selvaBuffer.js +77 -28
  15. package/dist/def/typeDef.d.ts +9 -3
  16. package/dist/def/typeDef.js +143 -56
  17. package/dist/def/typeIndexes.d.ts +40 -0
  18. package/dist/def/typeIndexes.js +50 -0
  19. package/dist/def/types.d.ts +38 -60
  20. package/dist/def/types.js +24 -61
  21. package/dist/def/utils.d.ts +5 -3
  22. package/dist/def/utils.js +44 -2
  23. package/dist/def/validation.d.ts +7 -0
  24. package/dist/def/validation.js +261 -0
  25. package/dist/index.d.ts +3 -1
  26. package/dist/index.js +3 -1
  27. package/dist/infer.d.ts +82 -0
  28. package/dist/infer.js +5 -0
  29. package/dist/lang.d.ts +3 -1
  30. package/dist/lang.js +6 -0
  31. package/dist/parse/assert.d.ts +4 -0
  32. package/dist/parse/assert.js +19 -2
  33. package/dist/parse/index.d.ts +2 -0
  34. package/dist/parse/index.js +58 -4
  35. package/dist/parse/props.d.ts +1 -0
  36. package/dist/parse/props.js +171 -54
  37. package/dist/serialize.d.ts +14 -0
  38. package/dist/serialize.js +543 -0
  39. package/dist/types.d.ts +75 -19
  40. package/dist/types.js +3 -1
  41. package/package.json +7 -5
  42. package/dist/def/getPropLen.d.ts +0 -3
  43. package/dist/def/getPropLen.js +0 -23
  44. package/dist/def/makePacked.d.ts +0 -3
  45. package/dist/def/makePacked.js +0 -50
  46. package/dist/def/readFromPacked.d.ts +0 -3
  47. package/dist/def/readFromPacked.js +0 -137
  48. package/dist/mermaid.d.ts +0 -3
  49. package/dist/mermaid.js +0 -24
package/dist/types.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { LangName } from './lang.js';
1
+ import type { LangName } from './lang.js';
2
+ import type { Validation } from './def/validation.js';
2
3
  type Role = 'title' | 'source' | 'media' | string;
3
4
  export declare const numberDisplays: readonly ["short", "human", "ratio", "bytes", "euro", "dollar", "pound", "meter"];
4
5
  export declare const dateDisplays: readonly ["date", "date-time", "date-time-text", "date-time-human", "time", "time-precise"];
5
- export declare const stringFormats: readonly ["alpha", "alphaLocales", "alphanumeric", "alphanumericLocales", "ascii", "base32", "base58", "base64", "BIC", "btcAddress", "clike", "code", "creditCard", "css", "currency", "dataURI", "EAN", "email", "ethereumAddress", "FQDN", "hexadecimal", "hexColor", "HSL", "html", "IBAN", "identityCard", "IMEI", "IP", "IPRange", "ISBN", "ISIN", "ISO31661Alpha2", "ISO31661Alpha3", "ISO4217", "ISO6391", "ISO8601", "ISRC", "ISSN", "javascript", "json", "JWT", "latLong", "licensePlate", "lowercase", "luhnNumber", "MACAddress", "magnetURI", "markdown", "MD5", "mimeType", "mobilePhone", "mobilePhoneLocales", "octal", "passportNumber", "port", "postalCode", "postalCodeLocales", "python", "RFC3339", "rgbColor", "rust", "semVer", "slug", "strongPassword", "surrogatePair", "taxID", "typescript", "uppercase", "URL", "UUID", "VAT", "multiline"];
6
+ export declare const stringFormats: readonly ["alpha", "alphaLocales", "alphanumeric", "alphanumericLocales", "ascii", "base32", "base58", "base64", "BIC", "btcAddress", "clike", "code", "creditCard", "css", "currency", "dataURI", "EAN", "email", "ethereumAddress", "FQDN", "hexadecimal", "hexColor", "HSL", "html", "IBAN", "identityCard", "IMEI", "IP", "IPRange", "ISBN", "ISIN", "ISO31661Alpha2", "ISO31661Alpha3", "ISO4217", "ISO6391", "ISO8601", "ISRC", "ISSN", "javascript", "json", "JWT", "latLong", "licensePlate", "lowercase", "luhnNumber", "MACAddress", "magnetURI", "markdown", "MD5", "mimeType", "mobilePhone", "mobilePhoneLocales", "octal", "password", "passportNumber", "port", "postalCode", "postalCodeLocales", "python", "RFC3339", "rgbColor", "rust", "semVer", "slug", "surrogatePair", "taxID", "typescript", "uppercase", "URL", "UUID", "VAT", "multiline"];
6
7
  type DateDisplay = (typeof dateDisplays)[number];
7
8
  type NumberDisplay = (typeof numberDisplays)[number] | `round-${number}`;
8
9
  type StringFormat = (typeof stringFormats)[number];
@@ -14,6 +15,7 @@ type QueryFn = Function;
14
15
  type PropValues = {
15
16
  type?: string;
16
17
  default?: any;
18
+ validation?: Validation;
17
19
  };
18
20
  type Prop<V extends PropValues> = {
19
21
  required?: boolean;
@@ -24,6 +26,7 @@ type Prop<V extends PropValues> = {
24
26
  role?: Role;
25
27
  readOnly?: boolean;
26
28
  examples?: string[];
29
+ validation?: Validation;
27
30
  } & V;
28
31
  type EnumItem = string | number | boolean;
29
32
  type NeverInItems = {
@@ -31,16 +34,19 @@ type NeverInItems = {
31
34
  };
32
35
  export type SchemaReferences = Prop<{
33
36
  type?: 'references';
37
+ default?: number[];
34
38
  items: SchemaReference & NeverInItems;
35
39
  }>;
36
40
  export type SchemaReferencesOneWay = Prop<{
37
41
  type?: 'references';
42
+ default?: number[];
38
43
  items: SchemaReferenceOneWay & NeverInItems;
39
44
  }>;
40
45
  export type SchemaText = Prop<{
41
46
  type: 'text';
42
47
  default?: Record<string, string>;
43
48
  format?: StringFormat;
49
+ compression?: 'none' | 'deflate';
44
50
  }>;
45
51
  type NumberType = 'number' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32';
46
52
  export type SchemaNumber = Prop<{
@@ -66,7 +72,7 @@ export type SchemaString = Prop<{
66
72
  }>;
67
73
  export type SchemaBinary = Prop<{
68
74
  type: 'binary';
69
- default?: ArrayBuffer;
75
+ default?: Uint8Array;
70
76
  maxBytes?: number;
71
77
  mime?: Mime;
72
78
  format?: StringFormat;
@@ -81,31 +87,56 @@ export type SchemaBoolean = Prop<{
81
87
  }>;
82
88
  export type SchemaCardinality = Prop<{
83
89
  type: 'cardinality';
84
- default?: string;
85
90
  maxBytes?: number;
86
91
  mime?: Mime;
87
92
  format?: NumberDisplay;
88
93
  }>;
94
+ type VectorDefaultType = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
95
+ export type SchemaVectorBaseType = NumberType | 'float32' | 'float64';
89
96
  export type SchemaVector = Prop<{
90
97
  type: 'vector';
91
- default?: Float32Array;
98
+ default?: VectorDefaultType;
99
+ /**
100
+ * Number of elements in the vector.
101
+ */
92
102
  size: number;
103
+ /**
104
+ * Base type of the vector.
105
+ * float64 == number
106
+ */
107
+ baseType?: SchemaVectorBaseType;
108
+ }>;
109
+ export type SchemaColvec = Prop<{
110
+ type: 'colvec';
111
+ default?: VectorDefaultType;
112
+ /**
113
+ * Number of elements in the vector.
114
+ */
115
+ size: number;
116
+ /**
117
+ * Base type of the vector.
118
+ * float64 == number
119
+ */
120
+ baseType?: SchemaVectorBaseType;
93
121
  }>;
94
122
  export type SchemaTimestamp = Prop<{
95
123
  type: 'timestamp';
96
- default?: number | Date;
124
+ default?: number | Date | string;
97
125
  on?: 'create' | 'update';
98
126
  display?: DateDisplay;
127
+ min?: number | string;
128
+ max?: number | string;
129
+ step?: number | 'any' | string;
99
130
  }>;
100
131
  export type SchemaReferenceOneWay = Prop<{
101
132
  type?: 'reference';
102
- default?: string;
133
+ default?: number;
103
134
  ref: string;
104
135
  mime?: Mime;
105
136
  }>;
106
137
  export type SchemaReference = Prop<{
107
138
  type?: 'reference';
108
- default?: string;
139
+ default?: number;
109
140
  ref: string;
110
141
  prop: string;
111
142
  dependent?: boolean;
@@ -127,7 +158,7 @@ export type SchemaReferencesWithQuery = SchemaReferencesOneWay & {
127
158
  };
128
159
  export type SchemaEnum = Prop<{
129
160
  type?: 'enum';
130
- default?: EnumItem;
161
+ default?: EnumItem | undefined;
131
162
  enum: EnumItem[];
132
163
  }>;
133
164
  export type SchemaAlias = Omit<SchemaString, 'type'> & {
@@ -142,21 +173,34 @@ export type SchemaSet<ItemsType extends SetItems = SetItems> = Prop<{
142
173
  } ? ItemsType['default'][] : undefined;
143
174
  items: ItemsType & NeverInItems;
144
175
  }>;
145
- type NonRefSchemaProps<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaAlias | SchemaText | SchemaEnum | SchemaJson | SchemaBinary | SchemaCardinality | SchemaVector | (isStrict extends true ? SchemaSet<SetItems<true>> : SchemaPropShorthand | SchemaSet);
176
+ type NonRefSchemaProps<isStrict = false> = SchemaTimestamp | SchemaBoolean | SchemaNumber | SchemaString | SchemaAlias | SchemaText | SchemaEnum | SchemaJson | SchemaBinary | SchemaCardinality | SchemaVector | SchemaColvec | (isStrict extends true ? SchemaSet<SetItems<true>> : SchemaPropShorthand | SchemaSet);
146
177
  export type SchemaProp<isStrict = false> = SchemaReferencesWithQuery | SchemaReferenceWithQuery | NonRefSchemaProps<isStrict> | SchemaReferences | SchemaReference | SchemaObject | SchemaBinary;
147
178
  export type SchemaPropOneWay<isStrict = false> = SchemaReferencesOneWay | SchemaReferenceOneWay | SchemaObjectOneWay | NonRefSchemaProps<isStrict>;
148
179
  export type SchemaAnyProp = SchemaPropOneWay | SchemaProp;
149
- export type SchemaHook = string | Function;
150
180
  export type SchemaProps<isStrict = false> = Record<AllowedKey, SchemaProp<isStrict>> & {
151
181
  id?: never;
152
182
  };
183
+ type BasedDbQuery = any;
184
+ type Operator = string;
185
+ export type SchemaHooks = {
186
+ create?: (payload: Record<string, any>) => void | Record<string, any>;
187
+ update?: (payload: Record<string, any>) => void | Record<string, any>;
188
+ read?: (result: Record<string, any>) => void | null | Record<string, any>;
189
+ search?: (query: BasedDbQuery, fields: Set<string>) => void;
190
+ include?: (query: BasedDbQuery, fields: Map<string, {
191
+ field: string;
192
+ opts?: any;
193
+ }>) => void;
194
+ filter?: (query: BasedDbQuery, field: string, operator: Operator, value: any) => void;
195
+ groupBy?: (query: BasedDbQuery, field: string) => void;
196
+ aggregate?: (query: BasedDbQuery, fields: Set<string>) => void;
197
+ };
153
198
  type GenericSchemaType<isStrict = false> = {
154
- hooks?: {
155
- create?: SchemaHook;
156
- update?: SchemaHook;
157
- delete?: SchemaHook;
158
- };
199
+ hooks?: SchemaHooks;
159
200
  id?: number;
201
+ blockCapacity?: number;
202
+ insertOnly?: boolean;
203
+ partial?: boolean;
160
204
  props: SchemaProps<isStrict>;
161
205
  };
162
206
  export type StrictSchemaType = GenericSchemaType<true>;
@@ -170,16 +214,25 @@ export type SchemaTypes<isStrict = false> = Record<SchemaTypeName, SchemaType<is
170
214
  export type SchemaPropsOneWay<isStrict = false> = Record<AllowedKey, SchemaPropOneWay<isStrict>> & {
171
215
  id?: never;
172
216
  };
217
+ type MigrateFn = (node: Record<string, any>) => Record<string, any> | [string, Record<string, any>];
218
+ export type MigrateFns = Record<string, MigrateFn>;
173
219
  type GenericSchema<isStrict = false> = {
220
+ version?: string;
174
221
  types?: SchemaTypes<isStrict>;
175
222
  props?: SchemaPropsOneWay<isStrict>;
176
223
  locales?: Partial<SchemaLocales>;
224
+ defaultTimezone?: string;
225
+ migrations?: {
226
+ version: string;
227
+ migrate: MigrateFns;
228
+ }[];
177
229
  };
178
230
  export type StrictSchema = GenericSchema<true>;
179
- export type Schema = GenericSchema<false> | StrictSchema;
180
- export type SchemaLocales = Record<LangName, {
231
+ export type NonStrictSchema = GenericSchema<false>;
232
+ export type Schema = NonStrictSchema | StrictSchema;
233
+ export type SchemaLocales = Record<LangName, true | {
181
234
  required?: boolean;
182
- fallback?: LangName[];
235
+ fallback?: LangName;
183
236
  }>;
184
237
  export type SchemaPropTypeMap = {
185
238
  references: SchemaReferences;
@@ -196,8 +249,11 @@ export type SchemaPropTypeMap = {
196
249
  binary: SchemaBinary;
197
250
  cardinality: SchemaCardinality;
198
251
  vector: SchemaVector;
252
+ colvec: SchemaColvec;
199
253
  } & Record<NumberType, SchemaNumber>;
200
254
  export type SchemaPropTypes = keyof SchemaPropTypeMap;
201
255
  export declare const isPropType: <T extends SchemaPropTypes>(type: T, prop: SchemaProp) => prop is SchemaPropTypeMap[T];
256
+ export declare const MAX_ID = 4294967295;
257
+ export declare const MIN_ID = 1;
202
258
  export {};
203
259
  //# sourceMappingURL=types.d.ts.map
package/dist/types.js CHANGED
@@ -71,6 +71,7 @@ export const stringFormats = [
71
71
  'mobilePhone',
72
72
  'mobilePhoneLocales',
73
73
  'octal',
74
+ 'password',
74
75
  'passportNumber',
75
76
  'port',
76
77
  'postalCode',
@@ -81,7 +82,6 @@ export const stringFormats = [
81
82
  'rust',
82
83
  'semVer',
83
84
  'slug',
84
- 'strongPassword',
85
85
  'surrogatePair',
86
86
  'taxID',
87
87
  'typescript',
@@ -95,4 +95,6 @@ export const stringFormats = [
95
95
  export const isPropType = (type, prop) => {
96
96
  return getPropType(prop) === type;
97
97
  };
98
+ export const MAX_ID = 4294967295;
99
+ export const MIN_ID = 1;
98
100
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@based/schema",
3
- "version": "5.0.0-alpha.8",
4
- "license": "MIT",
3
+ "version": "5.0.0",
5
4
  "files": [
6
5
  "dist",
7
6
  "README.md",
@@ -11,6 +10,8 @@
11
10
  "main": "./dist/index.js",
12
11
  "exports": {
13
12
  "./def": "./dist/def/index.js",
13
+ "./lang": "./dist/lang.js",
14
+ "./prop-types": "./dist/def/typeIndexes.js",
14
15
  ".": "./dist/index.js"
15
16
  },
16
17
  "scripts": {
@@ -24,12 +25,13 @@
24
25
  "devDependencies": {
25
26
  "@saulx/prettier-config": "2.0.0",
26
27
  "@saulx/tsconfig": "^1.1.0",
27
- "@types/node": "22.5.3",
28
+ "@types/node": "^22.5.3",
28
29
  "tsx": "^4.19.0",
29
30
  "typescript": "^5.6.3"
30
31
  },
31
32
  "dependencies": {
32
- "@saulx/utils": "^6.1.1",
33
+ "@based/utils": "^1.0.0",
34
+ "@std/semver": "npm:@jsr/std__semver@^1.0.5",
33
35
  "picocolors": "^1.1.0"
34
36
  }
35
- }
37
+ }
@@ -1,3 +0,0 @@
1
- import { SchemaProp } from '../types.js';
2
- export declare function getPropLen(schemaProp: SchemaProp): any;
3
- //# sourceMappingURL=getPropLen.d.ts.map
@@ -1,23 +0,0 @@
1
- import { getPropType } from '../parse/utils.js';
2
- import { isPropType } from '../types.js';
3
- import { SIZE_MAP } from './types.js';
4
- export function getPropLen(schemaProp) {
5
- let len = SIZE_MAP[getPropType(schemaProp)];
6
- if (isPropType('string', schemaProp) ||
7
- isPropType('alias', schemaProp) ||
8
- isPropType('cardinality', schemaProp)) {
9
- if (typeof schemaProp === 'object') {
10
- if (schemaProp.maxBytes < 61) {
11
- len = schemaProp.maxBytes + 1;
12
- }
13
- else if ('max' in schemaProp && schemaProp.max < 31) {
14
- len = schemaProp.max * 2 + 1;
15
- }
16
- }
17
- }
18
- else if (isPropType('vector', schemaProp)) {
19
- len = 4 * schemaProp.size;
20
- }
21
- return len;
22
- }
23
- //# sourceMappingURL=getPropLen.js.map
@@ -1,3 +0,0 @@
1
- import { SchemaTypeDef, PropDef } from './types.js';
2
- export declare function makePacked(result: Partial<SchemaTypeDef>, typeName: string, vals: PropDef[], len: number): void;
3
- //# sourceMappingURL=makePacked.d.ts.map
@@ -1,50 +0,0 @@
1
- export function makePacked(result, typeName, vals, len) {
2
- const encoder = new TextEncoder();
3
- result.buf = new Uint8Array(len);
4
- result.buf[0] = result.idUint8[0];
5
- result.buf[1] = result.idUint8[1];
6
- const fieldNames = [];
7
- const tNameBuf = encoder.encode(typeName);
8
- fieldNames.push(tNameBuf);
9
- let fieldNameLen = tNameBuf.byteLength + 1;
10
- let i = 2;
11
- if (result.mainLen) {
12
- result.buf[i] = 0;
13
- for (const f of vals) {
14
- if (!f.separate) {
15
- i++;
16
- result.buf[i] = f.typeIndex;
17
- const name = encoder.encode(f.path.join('.'));
18
- fieldNames.push(name);
19
- fieldNameLen += name.byteLength + 1;
20
- }
21
- }
22
- i++;
23
- result.buf[i] = 0;
24
- }
25
- for (const f of vals) {
26
- if (f.separate) {
27
- i++;
28
- result.buf[i] = f.prop;
29
- i++;
30
- result.buf[i] = f.typeIndex;
31
- const name = encoder.encode(f.path.join('.'));
32
- fieldNames.push(name);
33
- fieldNameLen += name.byteLength + 1;
34
- }
35
- }
36
- result.propNames = new Uint8Array(fieldNameLen);
37
- let lastWritten = 0;
38
- for (const f of fieldNames) {
39
- result.propNames[lastWritten] = f.byteLength;
40
- result.propNames.set(f, lastWritten + 1);
41
- lastWritten += f.byteLength + 1;
42
- }
43
- let bufLen = result.buf.length;
44
- result.packed = new Uint8Array(2 + bufLen + result.propNames.length);
45
- result.packed[0] = bufLen;
46
- result.packed[1] = bufLen >>>= 8;
47
- result.packed.set(result.buf, 2);
48
- result.packed.set(result.propNames, result.buf.length + 2);
49
- }
50
- //# sourceMappingURL=makePacked.js.map
@@ -1,3 +0,0 @@
1
- import { SchemaTypeDef } from './types.js';
2
- export declare const readFromPacked: (packed: Uint8Array) => SchemaTypeDef;
3
- //# sourceMappingURL=readFromPacked.d.ts.map
@@ -1,137 +0,0 @@
1
- import { DEFAULT_MAP, REVERSE_SIZE_MAP, } from './types.js';
2
- export const readFromPacked = (packed) => {
3
- const size = (packed[0] | (packed[1] << 8)) >>> 0;
4
- const props = [];
5
- const b = packed.subarray(2, 2 + size);
6
- let collectMain = false;
7
- const mainProps = [];
8
- const typeId = b.subarray(0, 2);
9
- const typeIdNr = (typeId[0] | (typeId[1] << 8)) >>> 0;
10
- for (let i = 2; i < b.length; i++) {
11
- const prop = b[i];
12
- if (collectMain) {
13
- if (prop === 0) {
14
- collectMain = false;
15
- }
16
- else {
17
- mainProps.push({
18
- prop: 0,
19
- typeIndex: b[i],
20
- });
21
- }
22
- }
23
- else {
24
- if (prop == 0) {
25
- collectMain = true;
26
- }
27
- else {
28
- props.push({ prop, typeIndex: b[i + 1] });
29
- i++;
30
- }
31
- }
32
- }
33
- const decoder = new TextDecoder();
34
- const fields = [];
35
- const f = packed.subarray(2 + size, packed.length);
36
- for (let i = 0; i < f.length; i++) {
37
- const size = f[i];
38
- fields.push(decoder.decode(f.subarray(i + 1, i + 1 + size)));
39
- i += size;
40
- }
41
- for (let i = 0; i < mainProps.length; i++) {
42
- mainProps[i].path = fields[i + 1];
43
- }
44
- for (let i = 0; i < props.length; i++) {
45
- props[i].path = fields[i + 1 + mainProps.length];
46
- }
47
- // Fixed len strings not supported
48
- // Refs also not supported
49
- // Text not supported yet
50
- // Ref not supported yet
51
- // compression: 1 (0)
52
- // YET
53
- const result = {
54
- cnt: 0,
55
- checksum: 0,
56
- total: 0,
57
- type: fields[0],
58
- lastId: 0,
59
- blockCapacity: 0,
60
- mainLen: mainProps.length,
61
- buf: b,
62
- propNames: f,
63
- packed,
64
- props: {},
65
- reverseProps: {}, // in a bit
66
- id: typeIdNr,
67
- idUint8: typeId,
68
- separate: [],
69
- main: {},
70
- tree: {},
71
- // not nessecary...
72
- hasSeperateSort: false,
73
- seperateSort: {
74
- size: 0,
75
- buffer: new Uint8Array([]),
76
- bufferTmp: new Uint8Array([]),
77
- props: [],
78
- },
79
- hasSeperateTextSort: false,
80
- seperateTextSort: {
81
- localeToIndex: new Map(),
82
- localeStringToIndex: new Map(),
83
- noUndefined: new Uint8Array([]),
84
- size: 0,
85
- buffer: new Uint8Array([]),
86
- bufferTmp: new Uint8Array([]),
87
- props: [],
88
- },
89
- mainEmpty: new Uint8Array([]),
90
- mainEmptyAllZeroes: true,
91
- // need this...
92
- locales: {},
93
- localeSize: 0,
94
- };
95
- let s = 0;
96
- for (const p of mainProps) {
97
- const len = REVERSE_SIZE_MAP[p.typeIndex];
98
- const prop = {
99
- prop: p.prop,
100
- separate: false,
101
- __isPropDef: true,
102
- start: s,
103
- default: DEFAULT_MAP[p.typeIndex], // tmp
104
- typeIndex: p.typeIndex,
105
- path: p.path.split('.'),
106
- len,
107
- };
108
- result.props[p.path] = prop;
109
- result.main[prop.start] = prop;
110
- s += len;
111
- }
112
- for (const p of props) {
113
- const prop = {
114
- prop: p.prop,
115
- separate: true,
116
- __isPropDef: true,
117
- start: 0,
118
- typeIndex: p.typeIndex,
119
- default: DEFAULT_MAP[p.typeIndex], // tmp
120
- path: p.path.split('.'),
121
- len: 0,
122
- compression: 1,
123
- };
124
- result.props[p.path] = prop;
125
- result.reverseProps[prop.prop] = prop;
126
- }
127
- // make this into a typeDef
128
- // return {
129
- // type: fields[0],
130
- // fields,
131
- // typeId,
132
- // props,
133
- // mainProps,
134
- // }
135
- return result;
136
- };
137
- //# sourceMappingURL=readFromPacked.js.map
package/dist/mermaid.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { StrictSchema } from './types.js';
2
- export declare const mermaid: (schema: StrictSchema) => string;
3
- //# sourceMappingURL=mermaid.d.ts.map
package/dist/mermaid.js DELETED
@@ -1,24 +0,0 @@
1
- import { getPropType } from './parse/utils.js';
2
- import { isPropType } from './types.js';
3
- export const mermaid = (schema) => {
4
- let mermaid = 'classDiagram';
5
- if (schema.types) {
6
- for (const type in schema.types) {
7
- for (const key in schema.types[type].props) {
8
- const prop = schema.types[type].props[key];
9
- const propType = getPropType(prop);
10
- if (isPropType('reference', prop)) {
11
- mermaid += `\n${type} --> ${prop.ref} : ${key}`;
12
- }
13
- else if (isPropType('references', prop)) {
14
- mermaid += `\n${type} --> ${prop.items.ref} : ${key}[]`;
15
- }
16
- else {
17
- mermaid += `\n${type} : ${propType} ${key}`;
18
- }
19
- }
20
- }
21
- }
22
- return mermaid;
23
- };
24
- //# sourceMappingURL=mermaid.js.map