@mountsqli/shared 0.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.
- package/dist/index.d.ts +52 -0
- package/dist/index.js +21 -0
- package/package.json +25 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Simplify an intersection type to its flattened form for readability */
|
|
2
|
+
type Simplify<T> = {
|
|
3
|
+
[K in keyof T]: T[K];
|
|
4
|
+
} & {};
|
|
5
|
+
/** Exact equality check at the type level */
|
|
6
|
+
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
7
|
+
/** Cast T as U, but only if T extends U */
|
|
8
|
+
type Assume<T, U> = T extends U ? T : U;
|
|
9
|
+
/** Check if a type is never */
|
|
10
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
11
|
+
/** Allow a value or an array of that value */
|
|
12
|
+
type ValueOrArray<T> = T | T[];
|
|
13
|
+
/** Extract the resolved type of a Promise */
|
|
14
|
+
type PromiseOf<T> = T extends Promise<infer U> ? U : T;
|
|
15
|
+
/** Mark a type with a compile-time error message */
|
|
16
|
+
type MountSQLiError<T extends string> = {
|
|
17
|
+
$mountsqliError: T;
|
|
18
|
+
};
|
|
19
|
+
/** Merge type U into T, overriding overlapping keys */
|
|
20
|
+
type Update<T, U> = {
|
|
21
|
+
[K in Exclude<keyof T, keyof U>]: T[K];
|
|
22
|
+
} & U;
|
|
23
|
+
/** Make selected keys optional */
|
|
24
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
25
|
+
/** Make selected keys required */
|
|
26
|
+
type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
27
|
+
/** Get the value type of a Record */
|
|
28
|
+
type GetValues<T> = T[keyof T];
|
|
29
|
+
/** Wrap a type in an array if not already */
|
|
30
|
+
type EnsureArray<T> = T extends any[] ? T : T[];
|
|
31
|
+
/** Brand type for nominal typing */
|
|
32
|
+
type Brand<K, T> = T & {
|
|
33
|
+
readonly __brand: K;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Package name constants */
|
|
37
|
+
declare const PACKAGE_NAME: "@mountsqli";
|
|
38
|
+
/** Supported dialects */
|
|
39
|
+
type Dialect = 'pg' | 'mysql' | 'sqlite' | 'mongo';
|
|
40
|
+
/** Default migration table name */
|
|
41
|
+
declare const MIGRATIONS_TABLE: "_mountsqli_migrations";
|
|
42
|
+
/** Default studio port */
|
|
43
|
+
declare const DEFAULT_STUDIO_PORT: 3333;
|
|
44
|
+
/** Entity kind symbol — shared across all packages */
|
|
45
|
+
declare const ENTITY_KIND: unique symbol;
|
|
46
|
+
/** Has-own entity kind symbol */
|
|
47
|
+
declare const HAS_OWN_ENTITY_KIND: unique symbol;
|
|
48
|
+
|
|
49
|
+
/** Schema fingerprint for migration diffing */
|
|
50
|
+
declare function schemaHash(schema: Record<string, unknown>): string;
|
|
51
|
+
|
|
52
|
+
export { type Assume, type Brand, DEFAULT_STUDIO_PORT, type Dialect, ENTITY_KIND, type EnsureArray, type Equal, type GetValues, HAS_OWN_ENTITY_KIND, type IsNever, MIGRATIONS_TABLE, type MountSQLiError, PACKAGE_NAME, type PartialBy, type PromiseOf, type RequiredBy, type Simplify, type Update, type ValueOrArray, schemaHash };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/constants.ts
|
|
2
|
+
var PACKAGE_NAME = "@mountsqli";
|
|
3
|
+
var MIGRATIONS_TABLE = "_mountsqli_migrations";
|
|
4
|
+
var DEFAULT_STUDIO_PORT = 3333;
|
|
5
|
+
var ENTITY_KIND = /* @__PURE__ */ Symbol.for("mountsqli.entityKind");
|
|
6
|
+
var HAS_OWN_ENTITY_KIND = /* @__PURE__ */ Symbol.for("mountsqli.hasOwnEntityKind");
|
|
7
|
+
|
|
8
|
+
// src/schema-hash.ts
|
|
9
|
+
import { createHash } from "crypto";
|
|
10
|
+
function schemaHash(schema) {
|
|
11
|
+
const canonical = JSON.stringify(schema, Object.keys(schema).sort());
|
|
12
|
+
return createHash("sha256").update(canonical).digest("hex").slice(0, 16);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
DEFAULT_STUDIO_PORT,
|
|
16
|
+
ENTITY_KIND,
|
|
17
|
+
HAS_OWN_ENTITY_KIND,
|
|
18
|
+
MIGRATIONS_TABLE,
|
|
19
|
+
PACKAGE_NAME,
|
|
20
|
+
schemaHash
|
|
21
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mountsqli/shared",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"import": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"files": ["dist", "LICENSE", "README.md"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
17
|
+
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
18
|
+
"clean": "rm -rf dist"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^22.0.0",
|
|
22
|
+
"typescript": "^5.7.0",
|
|
23
|
+
"tsup": "^8.0.0"
|
|
24
|
+
}
|
|
25
|
+
}
|