@ankhorage/contracts 1.2.0 → 1.3.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/CHANGELOG.md +6 -0
- package/dist/db.d.ts +110 -46
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js.map +1 -1
- package/package.json +16 -6
- package/src/contracts.test.ts +134 -0
- package/src/db.ts +135 -41
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @ankhorage/contracts
|
|
2
2
|
|
|
3
|
+
## 1.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9dadeaf: Replace the database contract surface with canonical provider-neutral CRUD capabilities and add realtime subscription plus privileged admin/schema contracts.
|
|
8
|
+
|
|
3
9
|
## 1.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/db.d.ts
CHANGED
|
@@ -1,63 +1,66 @@
|
|
|
1
1
|
export type DbRecord = Record<string, unknown>;
|
|
2
|
-
export type DbSortDirection = 'asc' | 'desc';
|
|
3
2
|
export interface DbAdapterError {
|
|
4
|
-
code: string;
|
|
5
|
-
message: string;
|
|
6
|
-
cause?: unknown;
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly cause?: unknown;
|
|
7
6
|
}
|
|
8
|
-
export type
|
|
9
|
-
ok: true;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export type DbSuccess<TData = void> = [TData] extends [void] ? {
|
|
8
|
+
readonly ok: true;
|
|
9
|
+
} : {
|
|
10
|
+
readonly ok: true;
|
|
11
|
+
readonly data: TData;
|
|
12
|
+
};
|
|
13
|
+
export type DbResult<TData = void> = DbSuccess<TData> | {
|
|
14
|
+
readonly ok: false;
|
|
15
|
+
readonly error: DbAdapterError;
|
|
14
16
|
};
|
|
17
|
+
export type DbSortDirection = 'asc' | 'desc';
|
|
15
18
|
export interface DbSort {
|
|
16
|
-
field: string;
|
|
17
|
-
direction?: DbSortDirection;
|
|
19
|
+
readonly field: string;
|
|
20
|
+
readonly direction?: DbSortDirection;
|
|
18
21
|
}
|
|
19
22
|
export interface DbPage {
|
|
20
|
-
limit?: number;
|
|
21
|
-
offset?: number;
|
|
23
|
+
readonly limit?: number;
|
|
24
|
+
readonly offset?: number;
|
|
22
25
|
}
|
|
23
26
|
export type DbFilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'contains' | 'startsWith' | 'endsWith';
|
|
24
27
|
export interface DbFilter {
|
|
25
|
-
field: string;
|
|
26
|
-
operator: DbFilterOperator;
|
|
27
|
-
value: unknown;
|
|
28
|
-
}
|
|
29
|
-
export interface
|
|
30
|
-
table: string;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
filters: DbFilter[];
|
|
28
|
+
readonly field: string;
|
|
29
|
+
readonly operator: DbFilterOperator;
|
|
30
|
+
readonly value: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface DbTableInput {
|
|
33
|
+
readonly table: string;
|
|
34
|
+
readonly schema?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface DbSelectInput extends DbTableInput {
|
|
37
|
+
readonly columns?: readonly string[];
|
|
38
|
+
readonly filters?: readonly DbFilter[];
|
|
39
|
+
readonly sort?: readonly DbSort[];
|
|
40
|
+
readonly page?: DbPage;
|
|
41
|
+
}
|
|
42
|
+
export interface DbFindByIdInput extends DbTableInput {
|
|
43
|
+
readonly id: string | number;
|
|
44
|
+
readonly idField?: string;
|
|
45
|
+
readonly columns?: readonly string[];
|
|
46
|
+
}
|
|
47
|
+
export interface DbInsertInput<TRecord extends object = DbRecord> extends DbTableInput {
|
|
48
|
+
readonly values: TRecord | readonly TRecord[];
|
|
49
|
+
}
|
|
50
|
+
export interface DbUpdateInput<TRecord extends object = DbRecord> extends DbTableInput {
|
|
51
|
+
readonly values: Partial<TRecord>;
|
|
52
|
+
readonly filters: readonly DbFilter[];
|
|
53
|
+
}
|
|
54
|
+
export interface DbDeleteInput extends DbTableInput {
|
|
55
|
+
readonly filters: readonly DbFilter[];
|
|
53
56
|
}
|
|
54
57
|
export interface DbAdapterCapabilities {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
readonly transactions: boolean;
|
|
59
|
+
readonly returning: boolean;
|
|
60
|
+
readonly realtime: boolean;
|
|
58
61
|
}
|
|
59
62
|
export interface DbAdapter {
|
|
60
|
-
readonly capabilities
|
|
63
|
+
readonly capabilities: DbAdapterCapabilities;
|
|
61
64
|
select<TRecord extends object = DbRecord>(input: DbSelectInput): Promise<DbResult<TRecord[]>>;
|
|
62
65
|
findById<TRecord extends object = DbRecord>(input: DbFindByIdInput): Promise<DbResult<TRecord | null>>;
|
|
63
66
|
insert<TRecord extends object = DbRecord>(input: DbInsertInput<TRecord>): Promise<DbResult<TRecord[]>>;
|
|
@@ -65,4 +68,65 @@ export interface DbAdapter {
|
|
|
65
68
|
delete<TRecord extends object = DbRecord>(input: DbDeleteInput): Promise<DbResult<TRecord[]>>;
|
|
66
69
|
transaction?<TResult>(run: (adapter: DbAdapter) => Promise<TResult>): Promise<DbResult<TResult>>;
|
|
67
70
|
}
|
|
71
|
+
export type DbChangeKind = 'insert' | 'update' | 'delete';
|
|
72
|
+
export interface DbChangeEvent<TRecord extends object = DbRecord> {
|
|
73
|
+
readonly table: string;
|
|
74
|
+
readonly schema?: string;
|
|
75
|
+
readonly kind: DbChangeKind;
|
|
76
|
+
readonly record: TRecord | null;
|
|
77
|
+
readonly previousRecord?: TRecord;
|
|
78
|
+
readonly committedAt?: string;
|
|
79
|
+
}
|
|
80
|
+
export type DbChangeListener<TRecord extends object = DbRecord> = (event: DbChangeEvent<TRecord>) => void;
|
|
81
|
+
export interface DbSubscription {
|
|
82
|
+
unsubscribe(): Promise<void> | void;
|
|
83
|
+
}
|
|
84
|
+
export type DbCollectionSubscriptionInput = DbTableInput;
|
|
85
|
+
export interface DbRecordSubscriptionInput extends DbCollectionSubscriptionInput {
|
|
86
|
+
readonly id: string | number;
|
|
87
|
+
readonly idField?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface DbRealtimeAdapter {
|
|
90
|
+
readonly realtime: {
|
|
91
|
+
subscribeToCollection<TRecord extends object = DbRecord>(input: DbCollectionSubscriptionInput, listener: DbChangeListener<TRecord>): DbSubscription;
|
|
92
|
+
subscribeToRecord<TRecord extends object = DbRecord>(input: DbRecordSubscriptionInput, listener: DbChangeListener<TRecord>): DbSubscription;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export type DbFieldType = 'text' | 'number' | 'boolean' | 'datetime' | 'json' | 'uuid';
|
|
96
|
+
export interface DbFieldDefinition {
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly type: DbFieldType;
|
|
99
|
+
readonly required?: boolean;
|
|
100
|
+
readonly unique?: boolean;
|
|
101
|
+
readonly defaultValue?: string | number | boolean | null;
|
|
102
|
+
}
|
|
103
|
+
export interface DbCollectionDefinition {
|
|
104
|
+
readonly name: string;
|
|
105
|
+
readonly schema?: string;
|
|
106
|
+
readonly fields: readonly DbFieldDefinition[];
|
|
107
|
+
readonly primaryKey?: string;
|
|
108
|
+
}
|
|
109
|
+
export interface DbCollectionReference {
|
|
110
|
+
readonly name: string;
|
|
111
|
+
readonly schema?: string;
|
|
112
|
+
}
|
|
113
|
+
export type DbAdminResult = {
|
|
114
|
+
readonly ok: true;
|
|
115
|
+
readonly executed: boolean;
|
|
116
|
+
readonly sql?: string;
|
|
117
|
+
} | {
|
|
118
|
+
readonly ok: false;
|
|
119
|
+
readonly error: DbAdapterError;
|
|
120
|
+
};
|
|
121
|
+
export interface DbAdminAdapterCapabilities {
|
|
122
|
+
readonly schemaGeneration: boolean;
|
|
123
|
+
readonly directExecution: boolean;
|
|
124
|
+
}
|
|
125
|
+
export interface DbAdminAdapter {
|
|
126
|
+
readonly capabilities: DbAdminAdapterCapabilities;
|
|
127
|
+
createCollection(input: DbCollectionDefinition): Promise<DbAdminResult>;
|
|
128
|
+
deleteCollection(input: DbCollectionReference): Promise<DbAdminResult>;
|
|
129
|
+
generateCreateCollectionSql(input: DbCollectionDefinition): DbAdminResult;
|
|
130
|
+
generateDeleteCollectionSql(input: DbCollectionReference): DbAdminResult;
|
|
131
|
+
}
|
|
68
132
|
//# sourceMappingURL=db.d.ts.map
|
package/dist/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,MAAM,SAAS,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,GACxD;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;CACnB,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;CACtB,CAAC;A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,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,aAAa,GACrB;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC,CAAC;AAEN,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,YAAY,EAAE,0BAA0B,CAAC;IAElD,gBAAgB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACxE,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACvE,2BAA2B,CAAC,KAAK,EAAE,sBAAsB,GAAG,aAAa,CAAC;IAC1E,2BAA2B,CAAC,KAAK,EAAE,qBAAqB,GAAG,aAAa,CAAC;CAC1E"}
|
package/dist/db.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"","sourcesContent":["export type DbRecord = Record<string, unknown>;\
|
|
1
|
+
{"version":3,"file":"db.js","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"","sourcesContent":["export type DbRecord = Record<string, unknown>;\n\nexport interface DbAdapterError {\n readonly code: string;\n readonly message: string;\n readonly cause?: unknown;\n}\n\nexport type DbSuccess<TData = void> = [TData] extends [void]\n ? {\n readonly ok: true;\n }\n : {\n readonly ok: true;\n readonly data: TData;\n };\n\nexport type DbResult<TData = void> =\n | DbSuccess<TData>\n | {\n readonly ok: false;\n readonly error: DbAdapterError;\n };\n\nexport type DbSortDirection = 'asc' | 'desc';\n\nexport interface DbSort {\n readonly field: string;\n readonly direction?: DbSortDirection;\n}\n\nexport interface DbPage {\n readonly limit?: number;\n readonly offset?: number;\n}\n\nexport type DbFilterOperator =\n | 'eq'\n | 'neq'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'in'\n | 'contains'\n | 'startsWith'\n | 'endsWith';\n\nexport interface DbFilter {\n readonly field: string;\n readonly operator: DbFilterOperator;\n readonly value: unknown;\n}\n\nexport interface DbTableInput {\n readonly table: string;\n readonly schema?: string;\n}\n\nexport interface DbSelectInput extends DbTableInput {\n readonly columns?: readonly string[];\n readonly filters?: readonly DbFilter[];\n readonly sort?: readonly DbSort[];\n readonly page?: DbPage;\n}\n\nexport interface DbFindByIdInput extends DbTableInput {\n readonly id: string | number;\n readonly idField?: string;\n readonly columns?: readonly string[];\n}\n\nexport interface DbInsertInput<TRecord extends object = DbRecord> extends DbTableInput {\n readonly values: TRecord | readonly TRecord[];\n}\n\nexport interface DbUpdateInput<TRecord extends object = DbRecord> extends DbTableInput {\n readonly values: Partial<TRecord>;\n readonly filters: readonly DbFilter[];\n}\n\nexport interface DbDeleteInput extends DbTableInput {\n readonly filters: readonly DbFilter[];\n}\n\nexport interface DbAdapterCapabilities {\n readonly transactions: boolean;\n readonly returning: boolean;\n readonly realtime: boolean;\n}\n\nexport interface DbAdapter {\n readonly capabilities: DbAdapterCapabilities;\n\n select<TRecord extends object = DbRecord>(input: DbSelectInput): Promise<DbResult<TRecord[]>>;\n findById<TRecord extends object = DbRecord>(\n input: DbFindByIdInput,\n ): Promise<DbResult<TRecord | null>>;\n insert<TRecord extends object = DbRecord>(\n input: DbInsertInput<TRecord>,\n ): Promise<DbResult<TRecord[]>>;\n update<TRecord extends object = DbRecord>(\n input: DbUpdateInput<TRecord>,\n ): Promise<DbResult<TRecord[]>>;\n delete<TRecord extends object = DbRecord>(input: DbDeleteInput): Promise<DbResult<TRecord[]>>;\n\n transaction?<TResult>(run: (adapter: DbAdapter) => Promise<TResult>): Promise<DbResult<TResult>>;\n}\n\nexport type DbChangeKind = 'insert' | 'update' | 'delete';\n\nexport interface DbChangeEvent<TRecord extends object = DbRecord> {\n readonly table: string;\n readonly schema?: string;\n readonly kind: DbChangeKind;\n readonly record: TRecord | null;\n readonly previousRecord?: TRecord;\n readonly committedAt?: string;\n}\n\nexport type DbChangeListener<TRecord extends object = DbRecord> = (\n event: DbChangeEvent<TRecord>,\n) => void;\n\nexport interface DbSubscription {\n unsubscribe(): Promise<void> | void;\n}\n\nexport type DbCollectionSubscriptionInput = DbTableInput;\n\nexport interface DbRecordSubscriptionInput extends DbCollectionSubscriptionInput {\n readonly id: string | number;\n readonly idField?: string;\n}\n\nexport interface DbRealtimeAdapter {\n readonly realtime: {\n subscribeToCollection<TRecord extends object = DbRecord>(\n input: DbCollectionSubscriptionInput,\n listener: DbChangeListener<TRecord>,\n ): DbSubscription;\n subscribeToRecord<TRecord extends object = DbRecord>(\n input: DbRecordSubscriptionInput,\n listener: DbChangeListener<TRecord>,\n ): DbSubscription;\n };\n}\n\nexport type DbFieldType = 'text' | 'number' | 'boolean' | 'datetime' | 'json' | 'uuid';\n\nexport interface DbFieldDefinition {\n readonly name: string;\n readonly type: DbFieldType;\n readonly required?: boolean;\n readonly unique?: boolean;\n readonly defaultValue?: string | number | boolean | null;\n}\n\nexport interface DbCollectionDefinition {\n readonly name: string;\n readonly schema?: string;\n readonly fields: readonly DbFieldDefinition[];\n readonly primaryKey?: string;\n}\n\nexport interface DbCollectionReference {\n readonly name: string;\n readonly schema?: string;\n}\n\nexport type DbAdminResult =\n | {\n readonly ok: true;\n readonly executed: boolean;\n readonly sql?: string;\n }\n | {\n readonly ok: false;\n readonly error: DbAdapterError;\n };\n\nexport interface DbAdminAdapterCapabilities {\n readonly schemaGeneration: boolean;\n readonly directExecution: boolean;\n}\n\nexport interface DbAdminAdapter {\n readonly capabilities: DbAdminAdapterCapabilities;\n\n createCollection(input: DbCollectionDefinition): Promise<DbAdminResult>;\n deleteCollection(input: DbCollectionReference): Promise<DbAdminResult>;\n generateCreateCollectionSql(input: DbCollectionDefinition): DbAdminResult;\n generateDeleteCollectionSql(input: DbCollectionReference): DbAdminResult;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/contracts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@ankhorage/color-theory": "^0.0.4"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@ankhorage/devtools": "^1.0.
|
|
9
|
+
"@ankhorage/devtools": "^1.0.5",
|
|
10
10
|
"@changesets/cli": "^2.30.0",
|
|
11
11
|
"@types/bun": "^1.3.13",
|
|
12
12
|
"@types/node": "^25.2.3",
|
|
@@ -31,6 +31,15 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"description": "Serializable app, action, and theme config contracts for Ankhorage.",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"typescript",
|
|
36
|
+
"contracts",
|
|
37
|
+
"schema",
|
|
38
|
+
"manifest",
|
|
39
|
+
"auth",
|
|
40
|
+
"storage",
|
|
41
|
+
"adapter"
|
|
42
|
+
],
|
|
34
43
|
"files": [
|
|
35
44
|
"dist",
|
|
36
45
|
"src",
|
|
@@ -50,10 +59,11 @@
|
|
|
50
59
|
},
|
|
51
60
|
"scripts": {
|
|
52
61
|
"build": "rm -rf dist tsconfig.tsbuildinfo && bun x tsc -p tsconfig.json",
|
|
53
|
-
"
|
|
54
|
-
"lint
|
|
55
|
-
"
|
|
56
|
-
"format
|
|
62
|
+
"knip": "ankhorage-knip",
|
|
63
|
+
"lint": "ankhorage-eslint . --max-warnings=0",
|
|
64
|
+
"lint:fix": "ankhorage-eslint . --fix --max-warnings=0",
|
|
65
|
+
"format": "ankhorage-prettier --write .",
|
|
66
|
+
"format:check": "ankhorage-prettier --check .",
|
|
57
67
|
"test": "bun test src",
|
|
58
68
|
"version-packages": "changeset version"
|
|
59
69
|
},
|
package/src/contracts.test.ts
CHANGED
|
@@ -12,6 +12,10 @@ import {
|
|
|
12
12
|
AUTH_SIGN_UP_POLICIES,
|
|
13
13
|
type AuthFlowConfig,
|
|
14
14
|
type AuthSpec,
|
|
15
|
+
type DbAdapter,
|
|
16
|
+
type DbAdminAdapter,
|
|
17
|
+
type DbChangeEvent,
|
|
18
|
+
type DbRealtimeAdapter,
|
|
15
19
|
DEPLOYMENT_TARGETS,
|
|
16
20
|
type ImageAssetSource,
|
|
17
21
|
NAVIGATOR_TYPES,
|
|
@@ -218,4 +222,134 @@ describe('contracts', () => {
|
|
|
218
222
|
|
|
219
223
|
expect(JSON.parse(JSON.stringify(source))).toEqual(source);
|
|
220
224
|
});
|
|
225
|
+
|
|
226
|
+
it('accepts a provider-neutral CRUD database adapter', async () => {
|
|
227
|
+
const adapter: DbAdapter = {
|
|
228
|
+
capabilities: {
|
|
229
|
+
transactions: false,
|
|
230
|
+
returning: true,
|
|
231
|
+
realtime: false,
|
|
232
|
+
},
|
|
233
|
+
select() {
|
|
234
|
+
return Promise.resolve({ ok: true, data: [{ id: 'post-1', title: 'Hello' }] });
|
|
235
|
+
},
|
|
236
|
+
findById() {
|
|
237
|
+
return Promise.resolve({ ok: true, data: { id: 'post-1', title: 'Hello' } });
|
|
238
|
+
},
|
|
239
|
+
insert(input) {
|
|
240
|
+
const values = Array.isArray(input.values) ? input.values : [input.values];
|
|
241
|
+
return Promise.resolve({ ok: true, data: values });
|
|
242
|
+
},
|
|
243
|
+
update() {
|
|
244
|
+
return Promise.resolve({ ok: true, data: [{ id: 'post-1', title: 'Updated' }] });
|
|
245
|
+
},
|
|
246
|
+
delete() {
|
|
247
|
+
return Promise.resolve({ ok: true, data: [{ id: 'post-1', title: 'Deleted' }] });
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const result = await adapter.select({
|
|
252
|
+
table: 'posts',
|
|
253
|
+
filters: [{ field: 'title', operator: 'startsWith', value: 'Hel' }],
|
|
254
|
+
sort: [{ field: 'title', direction: 'asc' }],
|
|
255
|
+
page: { limit: 10 },
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
expect(result.ok).toBe(true);
|
|
259
|
+
expect(result.ok ? result.data[0]?.id : undefined).toBe('post-1');
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('accepts a provider-neutral realtime database adapter', () => {
|
|
263
|
+
const received: DbChangeEvent[] = [];
|
|
264
|
+
const adapter: DbRealtimeAdapter = {
|
|
265
|
+
realtime: {
|
|
266
|
+
subscribeToCollection(_input, listener) {
|
|
267
|
+
listener({
|
|
268
|
+
table: 'posts',
|
|
269
|
+
schema: 'public',
|
|
270
|
+
kind: 'insert',
|
|
271
|
+
record: { id: 'post-1' },
|
|
272
|
+
committedAt: '2026-05-12T10:00:00.000Z',
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
return { unsubscribe: () => undefined };
|
|
276
|
+
},
|
|
277
|
+
subscribeToRecord(_input, listener) {
|
|
278
|
+
listener({
|
|
279
|
+
table: 'posts',
|
|
280
|
+
kind: 'update',
|
|
281
|
+
record: { id: 'post-1', title: 'Updated' },
|
|
282
|
+
previousRecord: { id: 'post-1', title: 'Old' },
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
return { unsubscribe: () => undefined };
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const subscription = adapter.realtime.subscribeToCollection({ table: 'posts' }, (event) => {
|
|
291
|
+
received.push(event);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
void subscription.unsubscribe();
|
|
295
|
+
|
|
296
|
+
expect(received).toEqual([
|
|
297
|
+
{
|
|
298
|
+
table: 'posts',
|
|
299
|
+
schema: 'public',
|
|
300
|
+
kind: 'insert',
|
|
301
|
+
record: { id: 'post-1' },
|
|
302
|
+
committedAt: '2026-05-12T10:00:00.000Z',
|
|
303
|
+
},
|
|
304
|
+
]);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it('accepts a provider-neutral database admin adapter', async () => {
|
|
308
|
+
const adapter: DbAdminAdapter = {
|
|
309
|
+
capabilities: {
|
|
310
|
+
schemaGeneration: true,
|
|
311
|
+
directExecution: false,
|
|
312
|
+
},
|
|
313
|
+
createCollection(input) {
|
|
314
|
+
return Promise.resolve({
|
|
315
|
+
ok: true,
|
|
316
|
+
executed: false,
|
|
317
|
+
sql: `create table ${input.name}`,
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
deleteCollection(input) {
|
|
321
|
+
return Promise.resolve({
|
|
322
|
+
ok: true,
|
|
323
|
+
executed: false,
|
|
324
|
+
sql: `drop table ${input.name}`,
|
|
325
|
+
});
|
|
326
|
+
},
|
|
327
|
+
generateCreateCollectionSql(input) {
|
|
328
|
+
return {
|
|
329
|
+
ok: true,
|
|
330
|
+
executed: false,
|
|
331
|
+
sql: `create table ${input.name}`,
|
|
332
|
+
};
|
|
333
|
+
},
|
|
334
|
+
generateDeleteCollectionSql(input) {
|
|
335
|
+
return {
|
|
336
|
+
ok: true,
|
|
337
|
+
executed: false,
|
|
338
|
+
sql: `drop table ${input.name}`,
|
|
339
|
+
};
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const result = await adapter.createCollection({
|
|
344
|
+
name: 'posts',
|
|
345
|
+
schema: 'public',
|
|
346
|
+
primaryKey: 'id',
|
|
347
|
+
fields: [
|
|
348
|
+
{ name: 'title', type: 'text', required: true },
|
|
349
|
+
{ name: 'metadata', type: 'json' },
|
|
350
|
+
],
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
expect(result).toEqual({ ok: true, executed: false, sql: 'create table posts' });
|
|
354
|
+
});
|
|
221
355
|
});
|
package/src/db.ts
CHANGED
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
export type DbRecord = Record<string, unknown>;
|
|
2
|
-
export type DbSortDirection = 'asc' | 'desc';
|
|
3
2
|
|
|
4
3
|
export interface DbAdapterError {
|
|
5
|
-
code: string;
|
|
6
|
-
message: string;
|
|
7
|
-
cause?: unknown;
|
|
4
|
+
readonly code: string;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
readonly cause?: unknown;
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
ok: true;
|
|
13
|
-
data?: TData;
|
|
9
|
+
export type DbSuccess<TData = void> = [TData] extends [void]
|
|
10
|
+
? {
|
|
11
|
+
readonly ok: true;
|
|
14
12
|
}
|
|
13
|
+
: {
|
|
14
|
+
readonly ok: true;
|
|
15
|
+
readonly data: TData;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type DbResult<TData = void> =
|
|
19
|
+
| DbSuccess<TData>
|
|
15
20
|
| {
|
|
16
|
-
ok: false;
|
|
17
|
-
error: DbAdapterError;
|
|
21
|
+
readonly ok: false;
|
|
22
|
+
readonly error: DbAdapterError;
|
|
18
23
|
};
|
|
19
24
|
|
|
25
|
+
export type DbSortDirection = 'asc' | 'desc';
|
|
26
|
+
|
|
20
27
|
export interface DbSort {
|
|
21
|
-
field: string;
|
|
22
|
-
direction?: DbSortDirection;
|
|
28
|
+
readonly field: string;
|
|
29
|
+
readonly direction?: DbSortDirection;
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
export interface DbPage {
|
|
26
|
-
limit?: number;
|
|
27
|
-
offset?: number;
|
|
33
|
+
readonly limit?: number;
|
|
34
|
+
readonly offset?: number;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
export type DbFilterOperator =
|
|
@@ -40,49 +47,50 @@ export type DbFilterOperator =
|
|
|
40
47
|
| 'endsWith';
|
|
41
48
|
|
|
42
49
|
export interface DbFilter {
|
|
43
|
-
field: string;
|
|
44
|
-
operator: DbFilterOperator;
|
|
45
|
-
value: unknown;
|
|
50
|
+
readonly field: string;
|
|
51
|
+
readonly operator: DbFilterOperator;
|
|
52
|
+
readonly value: unknown;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface DbTableInput {
|
|
56
|
+
readonly table: string;
|
|
57
|
+
readonly schema?: string;
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
export interface DbSelectInput {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
page?: DbPage;
|
|
60
|
+
export interface DbSelectInput extends DbTableInput {
|
|
61
|
+
readonly columns?: readonly string[];
|
|
62
|
+
readonly filters?: readonly DbFilter[];
|
|
63
|
+
readonly sort?: readonly DbSort[];
|
|
64
|
+
readonly page?: DbPage;
|
|
54
65
|
}
|
|
55
66
|
|
|
56
|
-
export interface DbFindByIdInput {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
columns?: string[];
|
|
67
|
+
export interface DbFindByIdInput extends DbTableInput {
|
|
68
|
+
readonly id: string | number;
|
|
69
|
+
readonly idField?: string;
|
|
70
|
+
readonly columns?: readonly string[];
|
|
60
71
|
}
|
|
61
72
|
|
|
62
|
-
export interface DbInsertInput<TRecord extends object = DbRecord> {
|
|
63
|
-
|
|
64
|
-
values: TRecord | TRecord[];
|
|
73
|
+
export interface DbInsertInput<TRecord extends object = DbRecord> extends DbTableInput {
|
|
74
|
+
readonly values: TRecord | readonly TRecord[];
|
|
65
75
|
}
|
|
66
76
|
|
|
67
|
-
export interface DbUpdateInput<TRecord extends object = DbRecord> {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
filters: DbFilter[];
|
|
77
|
+
export interface DbUpdateInput<TRecord extends object = DbRecord> extends DbTableInput {
|
|
78
|
+
readonly values: Partial<TRecord>;
|
|
79
|
+
readonly filters: readonly DbFilter[];
|
|
71
80
|
}
|
|
72
81
|
|
|
73
|
-
export interface DbDeleteInput {
|
|
74
|
-
|
|
75
|
-
filters: DbFilter[];
|
|
82
|
+
export interface DbDeleteInput extends DbTableInput {
|
|
83
|
+
readonly filters: readonly DbFilter[];
|
|
76
84
|
}
|
|
77
85
|
|
|
78
86
|
export interface DbAdapterCapabilities {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
readonly transactions: boolean;
|
|
88
|
+
readonly returning: boolean;
|
|
89
|
+
readonly realtime: boolean;
|
|
82
90
|
}
|
|
83
91
|
|
|
84
92
|
export interface DbAdapter {
|
|
85
|
-
readonly capabilities
|
|
93
|
+
readonly capabilities: DbAdapterCapabilities;
|
|
86
94
|
|
|
87
95
|
select<TRecord extends object = DbRecord>(input: DbSelectInput): Promise<DbResult<TRecord[]>>;
|
|
88
96
|
findById<TRecord extends object = DbRecord>(
|
|
@@ -98,3 +106,89 @@ export interface DbAdapter {
|
|
|
98
106
|
|
|
99
107
|
transaction?<TResult>(run: (adapter: DbAdapter) => Promise<TResult>): Promise<DbResult<TResult>>;
|
|
100
108
|
}
|
|
109
|
+
|
|
110
|
+
export type DbChangeKind = 'insert' | 'update' | 'delete';
|
|
111
|
+
|
|
112
|
+
export interface DbChangeEvent<TRecord extends object = DbRecord> {
|
|
113
|
+
readonly table: string;
|
|
114
|
+
readonly schema?: string;
|
|
115
|
+
readonly kind: DbChangeKind;
|
|
116
|
+
readonly record: TRecord | null;
|
|
117
|
+
readonly previousRecord?: TRecord;
|
|
118
|
+
readonly committedAt?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export type DbChangeListener<TRecord extends object = DbRecord> = (
|
|
122
|
+
event: DbChangeEvent<TRecord>,
|
|
123
|
+
) => void;
|
|
124
|
+
|
|
125
|
+
export interface DbSubscription {
|
|
126
|
+
unsubscribe(): Promise<void> | void;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type DbCollectionSubscriptionInput = DbTableInput;
|
|
130
|
+
|
|
131
|
+
export interface DbRecordSubscriptionInput extends DbCollectionSubscriptionInput {
|
|
132
|
+
readonly id: string | number;
|
|
133
|
+
readonly idField?: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface DbRealtimeAdapter {
|
|
137
|
+
readonly realtime: {
|
|
138
|
+
subscribeToCollection<TRecord extends object = DbRecord>(
|
|
139
|
+
input: DbCollectionSubscriptionInput,
|
|
140
|
+
listener: DbChangeListener<TRecord>,
|
|
141
|
+
): DbSubscription;
|
|
142
|
+
subscribeToRecord<TRecord extends object = DbRecord>(
|
|
143
|
+
input: DbRecordSubscriptionInput,
|
|
144
|
+
listener: DbChangeListener<TRecord>,
|
|
145
|
+
): DbSubscription;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export type DbFieldType = 'text' | 'number' | 'boolean' | 'datetime' | 'json' | 'uuid';
|
|
150
|
+
|
|
151
|
+
export interface DbFieldDefinition {
|
|
152
|
+
readonly name: string;
|
|
153
|
+
readonly type: DbFieldType;
|
|
154
|
+
readonly required?: boolean;
|
|
155
|
+
readonly unique?: boolean;
|
|
156
|
+
readonly defaultValue?: string | number | boolean | null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface DbCollectionDefinition {
|
|
160
|
+
readonly name: string;
|
|
161
|
+
readonly schema?: string;
|
|
162
|
+
readonly fields: readonly DbFieldDefinition[];
|
|
163
|
+
readonly primaryKey?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface DbCollectionReference {
|
|
167
|
+
readonly name: string;
|
|
168
|
+
readonly schema?: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export type DbAdminResult =
|
|
172
|
+
| {
|
|
173
|
+
readonly ok: true;
|
|
174
|
+
readonly executed: boolean;
|
|
175
|
+
readonly sql?: string;
|
|
176
|
+
}
|
|
177
|
+
| {
|
|
178
|
+
readonly ok: false;
|
|
179
|
+
readonly error: DbAdapterError;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export interface DbAdminAdapterCapabilities {
|
|
183
|
+
readonly schemaGeneration: boolean;
|
|
184
|
+
readonly directExecution: boolean;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface DbAdminAdapter {
|
|
188
|
+
readonly capabilities: DbAdminAdapterCapabilities;
|
|
189
|
+
|
|
190
|
+
createCollection(input: DbCollectionDefinition): Promise<DbAdminResult>;
|
|
191
|
+
deleteCollection(input: DbCollectionReference): Promise<DbAdminResult>;
|
|
192
|
+
generateCreateCollectionSql(input: DbCollectionDefinition): DbAdminResult;
|
|
193
|
+
generateDeleteCollectionSql(input: DbCollectionReference): DbAdminResult;
|
|
194
|
+
}
|