@oh-my-ghaad/core 0.0.1 → 0.0.6
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 +40 -0
- package/LICENSE +7 -0
- package/README.md +124 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/package.json +2 -1
- package/src/adapter.ts +2 -0
- package/src/types.ts +2 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
## [0.0.6](https://github.com/cmgriffing/oh-my-ghaad/compare/v0.0.5...v0.0.6) (2025-10-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## [0.0.5](https://github.com/cmgriffing/oh-my-ghaad/compare/v0.0.4...v0.0.5) (2025-10-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [0.0.4](https://github.com/cmgriffing/oh-my-ghaad/compare/v0.0.3...v0.0.4) (2025-10-04)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [0.0.3](https://github.com/cmgriffing/oh-my-ghaad/compare/v0.0.2...v0.0.3) (2025-10-04)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.0.2](https://github.com/cmgriffing/oh-my-ghaad/compare/v0.0.1...v0.0.2) (2025-10-04)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## [0.0.1](https://github.com/cmgriffing/oh-my-ghaad/compare/c7429b9154b82e94b4a214489b11e9b80642e0c7...v0.0.1) (2025-10-04)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* add number support for repository IDs and bump version ([3936a33](https://github.com/cmgriffing/oh-my-ghaad/commit/3936a338152d51ce71959a97d11b157ef8e8f619))
|
|
27
|
+
* add prepublish commands ([2166aa7](https://github.com/cmgriffing/oh-my-ghaad/commit/2166aa72c0e983ba106181a7ea24e2c61eabe28c))
|
|
28
|
+
* add scopes to adapter config ([137202f](https://github.com/cmgriffing/oh-my-ghaad/commit/137202f28b3dcf538947e17b42b299a888869e4b))
|
|
29
|
+
* clean up console logs and commented code ([8625536](https://github.com/cmgriffing/oh-my-ghaad/commit/8625536d411035ab4ebfc0729e88f61b31d5342b))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* add gitlab adapter ([a3367b1](https://github.com/cmgriffing/oh-my-ghaad/commit/a3367b1690c534c4d1fe19be6a287171226d9590))
|
|
35
|
+
* begin scaffolding an msw adapter and filling in some gaps in the engine ([6993e92](https://github.com/cmgriffing/oh-my-ghaad/commit/6993e928dd55e5cd44c0c0ae8e81d126e2ec8b90))
|
|
36
|
+
* bring demo-app up to functional and add mvp methods for engine ([46e2539](https://github.com/cmgriffing/oh-my-ghaad/commit/46e2539da2b72e0d1f95ce739d19f5137a726adb))
|
|
37
|
+
* initial prototyping ([c7429b9](https://github.com/cmgriffing/oh-my-ghaad/commit/c7429b9154b82e94b4a214489b11e9b80642e0c7))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 Chris Griffing
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# @oh-my-ghaad/core
|
|
2
|
+
|
|
3
|
+
The core package provides the fundamental functionality for treating Git repositories as JSON databases. It handles the abstraction layer between your application and the Git platform adapters.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The core package provides:
|
|
8
|
+
|
|
9
|
+
- Collection management with Zod validation
|
|
10
|
+
- Repository configuration and initialization
|
|
11
|
+
- CRUD operations for JSON data
|
|
12
|
+
- Subscription system for real-time updates
|
|
13
|
+
- Adapter management for different Git platforms
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @oh-my-ghaad/core
|
|
19
|
+
# or
|
|
20
|
+
yarn add @oh-my-ghaad/core
|
|
21
|
+
# or
|
|
22
|
+
pnpm add @oh-my-ghaad/core
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Basic Usage
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Engine } from '@oh-my-ghaad/core';
|
|
29
|
+
import { z } from 'zod';
|
|
30
|
+
|
|
31
|
+
// Define your collection schema
|
|
32
|
+
const widgetSchema = z.object({
|
|
33
|
+
id: z.string(),
|
|
34
|
+
name: z.string(),
|
|
35
|
+
type: z.enum(['gauge', 'chart', 'counter']),
|
|
36
|
+
config: z.object({
|
|
37
|
+
color: z.string(),
|
|
38
|
+
size: z.enum(['small', 'medium', 'large']),
|
|
39
|
+
enabled: z.boolean()
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Create a collection
|
|
44
|
+
const widgetsCollection = {
|
|
45
|
+
id: 'widgets',
|
|
46
|
+
names: {
|
|
47
|
+
singular: 'widget',
|
|
48
|
+
plural: 'widgets',
|
|
49
|
+
path: 'widgets'
|
|
50
|
+
},
|
|
51
|
+
validator: widgetSchema,
|
|
52
|
+
idFunction: () => crypto.randomUUID()
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Create the engine instance
|
|
56
|
+
const engine = new Engine({
|
|
57
|
+
adapters: [/* your adapter */],
|
|
58
|
+
collections: [widgetsCollection],
|
|
59
|
+
appConfig: {
|
|
60
|
+
persisted: true
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Key Concepts
|
|
66
|
+
|
|
67
|
+
### Collections
|
|
68
|
+
|
|
69
|
+
Collections are the primary way to organize and validate your data. Each collection:
|
|
70
|
+
- Has a unique ID
|
|
71
|
+
- Uses Zod for schema validation
|
|
72
|
+
- Can be referenced by ID, singular name, or plural name
|
|
73
|
+
- Stores data in a dedicated directory in the repository
|
|
74
|
+
|
|
75
|
+
### Engine
|
|
76
|
+
|
|
77
|
+
The Engine is the main interface for interacting with your Git-based database. It:
|
|
78
|
+
- Manages adapters for different Git platforms
|
|
79
|
+
- Handles collection operations
|
|
80
|
+
- Provides real-time updates through subscriptions
|
|
81
|
+
- Manages repository configuration
|
|
82
|
+
|
|
83
|
+
### Adapters
|
|
84
|
+
|
|
85
|
+
Adapters are responsible for platform-specific operations. The core package defines the interface that all adapters must implement. See the [main README](../../README.md) for available adapters.
|
|
86
|
+
|
|
87
|
+
## API Reference
|
|
88
|
+
|
|
89
|
+
### Engine
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
class Engine {
|
|
93
|
+
constructor(config: {
|
|
94
|
+
adapters: (Adapter & IAdapter)[];
|
|
95
|
+
collections: Collection[];
|
|
96
|
+
appConfig: AppConfig;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Collection Operations
|
|
100
|
+
addToCollection<T>(collectionId: string, data: T): Promise<T[]>;
|
|
101
|
+
updateInCollection<T>(collectionId: string, itemId: string, data: T): Promise<T[]>;
|
|
102
|
+
removeFromCollection<T>(collectionId: string, itemId: string): Promise<T[]>;
|
|
103
|
+
fetchCollectionItems<T>(collectionId: string): Promise<T[]>;
|
|
104
|
+
fetchCollectionItem<T>(collectionId: string, itemId: string): Promise<T | null>;
|
|
105
|
+
|
|
106
|
+
// Repository Management
|
|
107
|
+
initialize(): Promise<void>;
|
|
108
|
+
sync(): Promise<void>;
|
|
109
|
+
setRepoOwner(owner: string): void;
|
|
110
|
+
setRepoName(name: string): void;
|
|
111
|
+
setToken(token: string): void;
|
|
112
|
+
|
|
113
|
+
// Subscription
|
|
114
|
+
subscribe(callback: (collections: Collection[]) => void): void;
|
|
115
|
+
unsubscribe(callback: (collections: Collection[]) => void): void;
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Related Packages
|
|
120
|
+
|
|
121
|
+
- [@oh-my-ghaad/adapter-github](../adapter-github/README.md) - GitHub adapter implementation
|
|
122
|
+
- [@oh-my-ghaad/react](../react/README.md) - React integration
|
|
123
|
+
|
|
124
|
+
For more examples and detailed usage, see the [main README](../../README.md).
|
package/dist/index.cjs
CHANGED
|
@@ -431,11 +431,13 @@ var Adapter = class {
|
|
|
431
431
|
owner;
|
|
432
432
|
repo;
|
|
433
433
|
accessManagementUrl;
|
|
434
|
+
scopes;
|
|
434
435
|
unauthorizedHandler = null;
|
|
435
436
|
constructor(props) {
|
|
436
437
|
this.clientId = props.clientId;
|
|
437
438
|
this.redirectUri = props.redirectUri;
|
|
438
439
|
this.accessManagementUrl = props.accessManagementUrl;
|
|
440
|
+
this.scopes = props.scopes;
|
|
439
441
|
}
|
|
440
442
|
setOwner(owner) {
|
|
441
443
|
this.owner = owner;
|
package/dist/index.d.cts
CHANGED
|
@@ -28,10 +28,11 @@ interface AdapterProps {
|
|
|
28
28
|
clientId: string;
|
|
29
29
|
redirectUri: string;
|
|
30
30
|
accessManagementUrl: string;
|
|
31
|
+
scopes: string[];
|
|
31
32
|
}
|
|
32
33
|
type Subscription = (collections: Collection[]) => void | Promise<void>;
|
|
33
34
|
interface RepositoryResponse {
|
|
34
|
-
id: string;
|
|
35
|
+
id: string | number;
|
|
35
36
|
org: string;
|
|
36
37
|
name: string;
|
|
37
38
|
url: string;
|
|
@@ -85,6 +86,7 @@ declare class Adapter implements AdapterProps {
|
|
|
85
86
|
owner: string | null;
|
|
86
87
|
repo: string | null;
|
|
87
88
|
accessManagementUrl: string;
|
|
89
|
+
scopes: string[];
|
|
88
90
|
protected unauthorizedHandler: (() => void | Promise<void>) | null;
|
|
89
91
|
constructor(props: AdapterProps);
|
|
90
92
|
setOwner(owner: string | null): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -28,10 +28,11 @@ interface AdapterProps {
|
|
|
28
28
|
clientId: string;
|
|
29
29
|
redirectUri: string;
|
|
30
30
|
accessManagementUrl: string;
|
|
31
|
+
scopes: string[];
|
|
31
32
|
}
|
|
32
33
|
type Subscription = (collections: Collection[]) => void | Promise<void>;
|
|
33
34
|
interface RepositoryResponse {
|
|
34
|
-
id: string;
|
|
35
|
+
id: string | number;
|
|
35
36
|
org: string;
|
|
36
37
|
name: string;
|
|
37
38
|
url: string;
|
|
@@ -85,6 +86,7 @@ declare class Adapter implements AdapterProps {
|
|
|
85
86
|
owner: string | null;
|
|
86
87
|
repo: string | null;
|
|
87
88
|
accessManagementUrl: string;
|
|
89
|
+
scopes: string[];
|
|
88
90
|
protected unauthorizedHandler: (() => void | Promise<void>) | null;
|
|
89
91
|
constructor(props: AdapterProps);
|
|
90
92
|
setOwner(owner: string | null): void;
|
package/dist/index.js
CHANGED
|
@@ -402,11 +402,13 @@ var Adapter = class {
|
|
|
402
402
|
owner;
|
|
403
403
|
repo;
|
|
404
404
|
accessManagementUrl;
|
|
405
|
+
scopes;
|
|
405
406
|
unauthorizedHandler = null;
|
|
406
407
|
constructor(props) {
|
|
407
408
|
this.clientId = props.clientId;
|
|
408
409
|
this.redirectUri = props.redirectUri;
|
|
409
410
|
this.accessManagementUrl = props.accessManagementUrl;
|
|
411
|
+
this.scopes = props.scopes;
|
|
410
412
|
}
|
|
411
413
|
setOwner(owner) {
|
|
412
414
|
this.owner = owner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oh-my-ghaad/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"dev": "tsup src/index.ts --watch --dts --format esm,cjs",
|
|
20
20
|
"build": "tsup src/index.ts --dts --format esm,cjs",
|
|
21
|
+
"prepublish": "pnpm run build",
|
|
21
22
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
22
23
|
}
|
|
23
24
|
}
|
package/src/adapter.ts
CHANGED
|
@@ -7,12 +7,14 @@ export class Adapter implements AdapterProps {
|
|
|
7
7
|
owner: string | null;
|
|
8
8
|
repo: string | null;
|
|
9
9
|
accessManagementUrl: string;
|
|
10
|
+
scopes: string[];
|
|
10
11
|
protected unauthorizedHandler: (() => void | Promise<void>) | null = null;
|
|
11
12
|
|
|
12
13
|
constructor(props: AdapterProps) {
|
|
13
14
|
this.clientId = props.clientId;
|
|
14
15
|
this.redirectUri = props.redirectUri;
|
|
15
16
|
this.accessManagementUrl = props.accessManagementUrl;
|
|
17
|
+
this.scopes = props.scopes;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
setOwner(owner: string | null) {
|
package/src/types.ts
CHANGED
|
@@ -12,12 +12,13 @@ export interface AdapterProps {
|
|
|
12
12
|
clientId: string;
|
|
13
13
|
redirectUri: string;
|
|
14
14
|
accessManagementUrl: string;
|
|
15
|
+
scopes: string[];
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export type Subscription = (collections: Collection[]) => void | Promise<void>;
|
|
18
19
|
|
|
19
20
|
export interface RepositoryResponse {
|
|
20
|
-
id: string;
|
|
21
|
+
id: string | number;
|
|
21
22
|
org: string;
|
|
22
23
|
name: string;
|
|
23
24
|
url: string;
|