githttp-fs-client 1.0.1 → 1.0.2

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 CHANGED
@@ -1,5 +1,7 @@
1
1
  # node-githttp-fs-client
2
2
 
3
+ [![Build and Release](https://github.com/crisp-oss/node-githttp-fs-client/workflows/Build%20and%20Release/badge.svg)](https://github.com/crisp-oss/node-githttp-fs-client/actions?query=workflow%3A%22Build+and+Release%22) [![NPM](https://img.shields.io/npm/v/githttp-fs-client.svg)](https://www.npmjs.com/package/githttp-fs-client) [![Downloads](https://img.shields.io/npm/dt/githttp-fs-client.svg)](https://www.npmjs.com/package/githttp-fs-client)
4
+
3
5
  **Git HTTP FS client for Node. Used in pair with Git HTTP FS, a git-backed content management database served over HTTP.**
4
6
 
5
7
  Git HTTP FS Client is used to manage per-tenant Git content databases, over the Git HTTP FS HTTP API. All operations supported by the Git HTTP FS HTTP API are also supported in this client.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "githttp-fs-client",
3
3
  "description": "Git HTTP FS client for Node. Used in pair with Git HTTP FS, a git-backed content management database served over HTTP.",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/crisp-oss/node-githttp-fs-client",
7
7
  "license": "MIT",
@@ -23,13 +23,24 @@
23
23
  "url": "https://github.com/crisp-oss/node-githttp-fs-client/blob/master/LICENSE"
24
24
  }
25
25
  ],
26
- "main": "lib/index.ts",
26
+ "main": "dist/index.js",
27
+ "types": "dist/index.d.ts",
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "scripts": {
32
+ "build": "tsc",
33
+ "prepublishOnly": "npm run build"
34
+ },
27
35
  "engines": {
28
- "node": ">= 23.0.0"
36
+ "node": ">= 18.0.0"
29
37
  },
30
38
  "keywords": [
31
39
  "githttp-fs",
32
40
  "git",
33
41
  "cms"
34
- ]
42
+ ],
43
+ "devDependencies": {
44
+ "typescript": "5.8.3"
45
+ }
35
46
  }
@@ -1,29 +0,0 @@
1
- on:
2
- push:
3
- tags:
4
- - "v*.*.*"
5
-
6
- permissions:
7
- id-token: write
8
-
9
- name: Build and Release
10
-
11
- jobs:
12
- release:
13
- runs-on: ubuntu-latest
14
-
15
- steps:
16
- - name: Checkout code
17
- uses: actions/checkout@v2
18
-
19
- - name: Install NodeJS
20
- uses: actions/setup-node@v1
21
- with:
22
- node-version: 24.x
23
- registry-url: https://registry.npmjs.org
24
-
25
- - name: Verify versions
26
- run: node --version && npm --version && node -p process.versions.v8
27
-
28
- - name: Release package
29
- run: npm publish --ignore-scripts --provenance
package/lib/index.ts DELETED
@@ -1,157 +0,0 @@
1
- /*
2
- * node-githttp-fs-client
3
- *
4
- * Copyright 2026, Valerian Saliou
5
- * Author: Valerian Saliou <valerian@valeriansaliou.name>
6
- */
7
-
8
- /**
9
- * Configuration for the Git HTTP FS API client.
10
- */
11
- export interface ClientConfig {
12
- baseUrl: string;
13
- apiKey: string;
14
- }
15
-
16
- /** Defines the API version */
17
- const VERSION = "v1";
18
-
19
- /** Defines all HTTP methods */
20
- const GET = "GET";
21
- const POST = "POST";
22
- const PUT = "PUT";
23
- const DELETE = "DELETE";
24
-
25
- /**
26
- * Git HTTP FS client, manages files and commits over the Git HTTP FS HTTP API.
27
- */
28
- export class GitHTTPFSClient {
29
- private baseUrl: string;
30
- private headers: Record<string, string>;
31
-
32
- constructor(config: ClientConfig) {
33
- // Remove trailing slash (if any)
34
- this.baseUrl = config.baseUrl.replace(/\/$/, "");
35
-
36
- this.headers = {
37
- "Authorization": `Bearer ${config.apiKey}`,
38
- "Content-Type": "application/json",
39
- "Accept": "application/json"
40
- };
41
- }
42
-
43
- /**
44
- * Helper to handle requests and parse JSON responses.
45
- */
46
- private async request<T>(
47
- path: string,
48
- method: "GET" | "POST" | "PUT" | "DELETE",
49
- body?: any,
50
- params?: Record<string, string>
51
- ): Promise<T> {
52
- const url = new URL(`${this.baseUrl}/${VERSION}/${path}`);
53
-
54
- // Append query parameters
55
- if (params) {
56
- Object.entries(params).forEach(([key, value]) =>
57
- url.searchParams.set(key, value)
58
- );
59
- }
60
-
61
- const options: RequestInit = {
62
- method,
63
-
64
- headers: this.headers
65
- };
66
-
67
- if (body && method !== GET) {
68
- options.body = JSON.stringify(body);
69
- }
70
-
71
- const response = await fetch(url.toString(), options);
72
-
73
- if (!response.ok) {
74
- const errorText = await response.text();
75
-
76
- throw new Error(`API Error [${response.status}]: ${errorText}`);
77
- }
78
-
79
- return response.json();
80
- }
81
-
82
- // --- Tenant Operations ---
83
-
84
- /** Delete entire tenant repository */
85
- async deleteTenant(tenantId: string) {
86
- return this.request(
87
- `${tenantId}`, DELETE
88
- );
89
- }
90
-
91
- /** List all tracked files (path + size) */
92
- async listFiles(tenantId: string) {
93
- return this.request(
94
- `${tenantId}/files`, GET
95
- );
96
- }
97
-
98
- /** Read file content */
99
- async getFileContent(tenantId: string, path: string) {
100
- return this.request(
101
- `${tenantId}/files/${path}`, GET
102
- );
103
- }
104
-
105
- /** Create or update a file */
106
- async putFile(tenantId: string, path: string, body: any) {
107
- return this.request(
108
- `${tenantId}/files/${path}`, PUT, body
109
- );
110
- }
111
-
112
- /** Delete a file */
113
- async deleteFile(tenantId: string, path: string) {
114
- return this.request(
115
- `${tenantId}/files/${path}`, DELETE
116
- );
117
- }
118
-
119
- /** Move / rename a file */
120
- async moveFile(tenantId: string, path: string, body: any) {
121
- return this.request(
122
- `${tenantId}/files/${path}/move`, POST, body
123
- );
124
- }
125
-
126
- // --- Commit Operations ---
127
-
128
- /** List commits with pagination */
129
- async listCommits(
130
- tenantId: string,
131
- page: number = 1,
132
- perPage: number = 100
133
- ) {
134
- const params = {
135
- page: page.toString(),
136
- per_page: Math.min(perPage, 500).toString()
137
- };
138
-
139
- return this.request(
140
- `${tenantId}/commits`, GET, undefined, params
141
- );
142
- }
143
-
144
- /** Commit detail with per-file diffs and snapshots */
145
- async getCommitDetail(tenantId: string, sha: string) {
146
- return this.request(
147
- `${tenantId}/commits/${sha}`, GET
148
- );
149
- }
150
-
151
- /** Revert a commit */
152
- async revertCommit(tenantId: string, sha: string, body: any) {
153
- return this.request(
154
- `${tenantId}/commits/${sha}/revert`, POST, body
155
- );
156
- }
157
- }