opacacms 0.1.7 → 0.1.8
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/admin/index.js +255 -20
- package/dist/admin/webcomponent.js +291 -46
- package/dist/cli/index.js +3638 -30
- package/dist/client.js +126 -5
- package/dist/db/bun-sqlite.js +790 -21
- package/dist/db/d1.js +788 -19
- package/dist/db/index.js +53 -4
- package/dist/db/postgres.js +792 -23
- package/dist/db/sqlite.js +788 -19
- package/dist/index.js +456 -8
- package/dist/runtimes/bun.js +1909 -8
- package/dist/runtimes/cloudflare-workers.js +1910 -9
- package/dist/runtimes/next.js +1908 -7
- package/dist/runtimes/node.js +1909 -8
- package/dist/schema/collection.d.ts +3 -7
- package/dist/schema/fields/index.d.ts +24 -25
- package/dist/schema/global.d.ts +9 -9
- package/dist/schema/index.d.ts +30 -4
- package/dist/schema/index.js +546 -1
- package/dist/server.js +2246 -17
- package/dist/storage/index.js +40 -1
- package/package.json +1 -1
- package/dist/chunk-16vgcf3k.js +0 -88
- package/dist/chunk-2yz1nsxs.js +0 -126
- package/dist/chunk-5gvbp2qa.js +0 -167
- package/dist/chunk-62ev8gnc.js +0 -41
- package/dist/chunk-6ew02s0c.js +0 -472
- package/dist/chunk-7a9kn0np.js +0 -116
- package/dist/chunk-8sqjbsgt.js +0 -42
- package/dist/chunk-9kxpbcb1.js +0 -85
- package/dist/chunk-cvdd4eqh.js +0 -110
- package/dist/chunk-d3ffeqp9.js +0 -87
- package/dist/chunk-fa5mg0hr.js +0 -96
- package/dist/chunk-j4d50hrx.js +0 -20
- package/dist/chunk-jwjk85ze.js +0 -15
- package/dist/chunk-m09hahe2.js +0 -250
- package/dist/chunk-s8mqwnm1.js +0 -14
- package/dist/chunk-srsac177.js +0 -85
- package/dist/chunk-v521d72w.js +0 -10
- package/dist/chunk-vtvqfhgy.js +0 -2442
- package/dist/chunk-xa7rjsn2.js +0 -20
- package/dist/chunk-xg35h5a3.js +0 -15
- package/dist/chunk-y8hc6nm4.js +0 -17
- package/dist/chunk-ybbbqj63.js +0 -130
- package/dist/chunk-yr32cp7h.js +0 -1603
- package/dist/chunk-zvwb67nd.js +0 -332
package/dist/client.js
CHANGED
|
@@ -1,8 +1,129 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
function __accessProp(key) {
|
|
7
|
+
return this[key];
|
|
8
|
+
}
|
|
9
|
+
var __toCommonJS = (from) => {
|
|
10
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
11
|
+
if (entry)
|
|
12
|
+
return entry;
|
|
13
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (var key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(entry, key))
|
|
17
|
+
__defProp(entry, key, {
|
|
18
|
+
get: __accessProp.bind(from, key),
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
__moduleCache.set(from, entry);
|
|
23
|
+
return entry;
|
|
24
|
+
};
|
|
25
|
+
var __moduleCache;
|
|
26
|
+
var __returnValue = (v) => v;
|
|
27
|
+
function __exportSetter(name, newValue) {
|
|
28
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
29
|
+
}
|
|
30
|
+
var __export = (target, all) => {
|
|
31
|
+
for (var name in all)
|
|
32
|
+
__defProp(target, name, {
|
|
33
|
+
get: all[name],
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
set: __exportSetter.bind(all, name)
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
40
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
41
|
+
|
|
42
|
+
// src/client.ts
|
|
43
|
+
class OpacaError extends Error {
|
|
44
|
+
status;
|
|
45
|
+
data;
|
|
46
|
+
constructor(message, status, data = {}) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.name = "OpacaError";
|
|
49
|
+
this.status = status;
|
|
50
|
+
this.data = data;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function createClient(configOrOptions) {
|
|
54
|
+
const options = configOrOptions.serverURL ? { baseURL: configOrOptions.serverURL } : configOrOptions;
|
|
55
|
+
const baseURL = options.baseURL.replace(/\/$/, "");
|
|
56
|
+
const getHeaders = () => {
|
|
57
|
+
const headers = {
|
|
58
|
+
"Content-Type": "application/json"
|
|
59
|
+
};
|
|
60
|
+
if (options.token) {
|
|
61
|
+
headers.Authorization = `Bearer ${options.token}`;
|
|
62
|
+
}
|
|
63
|
+
return headers;
|
|
64
|
+
};
|
|
65
|
+
const fetcher = async (path, init) => {
|
|
66
|
+
const res = await fetch(`${baseURL}${path}`, {
|
|
67
|
+
...init,
|
|
68
|
+
credentials: "include",
|
|
69
|
+
headers: {
|
|
70
|
+
...getHeaders(),
|
|
71
|
+
...init?.headers
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (!res.ok) {
|
|
75
|
+
const errorData = await res.json().catch(() => ({}));
|
|
76
|
+
throw new OpacaError(errorData.message || `API Error: ${res.status}`, res.status, errorData);
|
|
77
|
+
}
|
|
78
|
+
return res.json();
|
|
79
|
+
};
|
|
80
|
+
const client = {
|
|
81
|
+
getMetadata: () => fetcher("/api/__admin/metadata"),
|
|
82
|
+
getCollections: () => fetcher("/api/__admin/collections"),
|
|
83
|
+
getSetupStatus: () => fetcher("/api/__admin/setup"),
|
|
84
|
+
collections: new Proxy({}, {
|
|
85
|
+
get(_, collectionSlug) {
|
|
86
|
+
return {
|
|
87
|
+
find: (query) => {
|
|
88
|
+
const searchParams = new URLSearchParams;
|
|
89
|
+
if (query) {
|
|
90
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
91
|
+
searchParams.append(key, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const queryString = searchParams.toString();
|
|
95
|
+
return fetcher(`/api/${String(collectionSlug)}${queryString ? `?${queryString}` : ""}`);
|
|
96
|
+
},
|
|
97
|
+
findOne: (id) => fetcher(`/api/${String(collectionSlug)}/${id}`),
|
|
98
|
+
list: () => fetcher(`/api/${String(collectionSlug)}`),
|
|
99
|
+
create: (data) => fetcher(`/api/${String(collectionSlug)}`, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
body: JSON.stringify(data)
|
|
102
|
+
}),
|
|
103
|
+
update: (id, data) => fetcher(`/api/${String(collectionSlug)}/${id}`, {
|
|
104
|
+
method: "PATCH",
|
|
105
|
+
body: JSON.stringify(data)
|
|
106
|
+
}),
|
|
107
|
+
delete: (id) => fetcher(`/api/${String(collectionSlug)}/${id}`, {
|
|
108
|
+
method: "DELETE"
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
globals: new Proxy({}, {
|
|
114
|
+
get(_, globalSlug) {
|
|
115
|
+
return {
|
|
116
|
+
get: () => fetcher(`/api/globals/${String(globalSlug)}`),
|
|
117
|
+
update: (data) => fetcher(`/api/globals/${String(globalSlug)}`, {
|
|
118
|
+
method: "PATCH",
|
|
119
|
+
body: JSON.stringify(data)
|
|
120
|
+
})
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
};
|
|
125
|
+
return client;
|
|
126
|
+
}
|
|
6
127
|
export {
|
|
7
128
|
createClient,
|
|
8
129
|
OpacaError
|