uql-codemod 0.48.1 → 0.49.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.
- package/README.md +27 -16
- package/dist/builders.d.ts +18 -0
- package/dist/builders.js +588 -0
- package/dist/classOptions.d.ts +9 -0
- package/dist/classOptions.js +240 -0
- package/dist/columnMethods.d.ts +11 -0
- package/dist/columnMethods.js +6 -0
- package/dist/columnRefs.js +3 -10
- package/dist/context.d.ts +18 -5
- package/dist/context.js +22 -4
- package/dist/definers.d.ts +24 -0
- package/dist/definers.js +34 -0
- package/dist/edits.d.ts +43 -11
- package/dist/edits.js +105 -26
- package/dist/entitySql.d.ts +15 -16
- package/dist/entitySql.js +33 -31
- package/dist/imports.d.ts +33 -16
- package/dist/imports.js +213 -99
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -12
- package/dist/jsonIndex.d.ts +11 -0
- package/dist/jsonIndex.js +78 -0
- package/dist/keyMaps.d.ts +3 -1
- package/dist/keyMaps.js +5 -1
- package/dist/migrationBuilders.d.ts +13 -0
- package/dist/migrationBuilders.js +182 -0
- package/dist/relationTarget.d.ts +6 -0
- package/dist/relationTarget.js +21 -0
- package/dist/schemaEntity.d.ts +12 -0
- package/dist/schemaEntity.js +518 -0
- package/dist/schemaOptions.d.ts +6 -0
- package/dist/schemaOptions.js +6 -0
- package/dist/statementSql.d.ts +2 -1
- package/dist/statementSql.js +10 -4
- package/dist/syntax.d.ts +54 -0
- package/dist/syntax.js +131 -1
- package/dist/transform.d.ts +11 -2
- package/dist/transform.js +174 -165
- package/dist/tsconfig.d.ts +3 -9
- package/dist/tsconfig.js +18 -22
- package/package.json +1 -1
- package/dist/fieldType.d.ts +0 -13
- package/dist/fieldType.js +0 -56
package/package.json
CHANGED
package/dist/fieldType.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
export declare function isBrandedString(type: ts.Type): boolean;
|
|
3
|
-
/**
|
|
4
|
-
* The `type` option reflection supplied for a property of `type`, mirroring `TypeFor` in `uql-orm`, or nothing
|
|
5
|
-
* for a shape a human decides. Only what reflection could produce is read: a `Json<T>` or vector property got
|
|
6
|
-
* `Object`/`Array` from it, so it already declared its `type`.
|
|
7
|
-
*/
|
|
8
|
-
export declare function fieldTypeFor(type: ts.Type): string | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* The entity name a relation property points at: `Company` for `Company`, `Company[]`, and
|
|
11
|
-
* `Relation<Company>` alike, since `Relation<T>` is an alias for `T` and erases before this runs.
|
|
12
|
-
*/
|
|
13
|
-
export declare function relationTargetFor(type: ts.Type, checker: ts.TypeChecker): string | undefined;
|
package/dist/fieldType.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
/** The string types carrying more than `string`, e.g. `` type UUID = `${string}-${string}` ``, still string columns. */
|
|
3
|
-
const BRANDED_STRING = ts.TypeFlags.TemplateLiteral | ts.TypeFlags.StringMapping;
|
|
4
|
-
export function isBrandedString(type) {
|
|
5
|
-
return (type.isUnion() ? type.types : [type]).some((t) => !!(t.getFlags() & BRANDED_STRING));
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Reads a union by requiring its arms to agree, which is what an `'a' | 'b'` enum or a `T | null` looks
|
|
9
|
-
* like. `undefined` and `null` arms are dropped first: they carry no column type of their own.
|
|
10
|
-
*/
|
|
11
|
-
function foldUnion(type, read) {
|
|
12
|
-
const arms = type.types.filter((arm) => !(arm.getFlags() & (ts.TypeFlags.Undefined | ts.TypeFlags.Null)));
|
|
13
|
-
const readings = new Set(arms.map(read));
|
|
14
|
-
return readings.size === 1 ? [...readings][0] : undefined;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* The `type` option reflection supplied for a property of `type`, mirroring `TypeFor` in `uql-orm`, or nothing
|
|
18
|
-
* for a shape a human decides. Only what reflection could produce is read: a `Json<T>` or vector property got
|
|
19
|
-
* `Object`/`Array` from it, so it already declared its `type`.
|
|
20
|
-
*/
|
|
21
|
-
export function fieldTypeFor(type) {
|
|
22
|
-
const flags = type.getFlags();
|
|
23
|
-
if (type.isUnion()) {
|
|
24
|
-
return foldUnion(type, fieldTypeFor);
|
|
25
|
-
}
|
|
26
|
-
if (flags & (ts.TypeFlags.String | ts.TypeFlags.StringLiteral | BRANDED_STRING))
|
|
27
|
-
return 'String';
|
|
28
|
-
if (flags & (ts.TypeFlags.Number | ts.TypeFlags.NumberLiteral))
|
|
29
|
-
return 'Number';
|
|
30
|
-
if (flags & (ts.TypeFlags.BigInt | ts.TypeFlags.BigIntLiteral))
|
|
31
|
-
return 'BigInt';
|
|
32
|
-
if (flags & (ts.TypeFlags.Boolean | ts.TypeFlags.BooleanLiteral))
|
|
33
|
-
return 'Boolean';
|
|
34
|
-
// Matched by declared symbol rather than by the printed type: both of these became generic in the
|
|
35
|
-
// modern lib, so `Uint8Array` prints as `Uint8Array<ArrayBufferLike>` and never compared equal.
|
|
36
|
-
const name = type.getSymbol()?.getName();
|
|
37
|
-
if (name === 'Date')
|
|
38
|
-
return 'Date';
|
|
39
|
-
if (name === 'Buffer' || name === 'Uint8Array')
|
|
40
|
-
return "'blob'";
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The entity name a relation property points at: `Company` for `Company`, `Company[]`, and
|
|
45
|
-
* `Relation<Company>` alike, since `Relation<T>` is an alias for `T` and erases before this runs.
|
|
46
|
-
*/
|
|
47
|
-
export function relationTargetFor(type, checker) {
|
|
48
|
-
if (type.isUnion()) {
|
|
49
|
-
return foldUnion(type, (arm) => relationTargetFor(arm, checker));
|
|
50
|
-
}
|
|
51
|
-
const elementType = checker.getIndexTypeOfType(type, ts.IndexKind.Number);
|
|
52
|
-
const target = elementType ?? type;
|
|
53
|
-
const symbol = target.getSymbol();
|
|
54
|
-
const name = symbol?.getName();
|
|
55
|
-
return name && name !== '__type' && /^[A-Z][A-Za-z0-9_]*$/.test(name) ? name : undefined;
|
|
56
|
-
}
|