inibase 1.0.0-rc.11 → 1.0.0-rc.13
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 +50 -0
- package/dist/file.d.ts +33 -0
- package/dist/file.js +501 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +940 -0
- package/dist/utils.d.ts +54 -0
- package/dist/utils.js +301 -0
- package/package.json +22 -9
- package/file.ts +0 -544
- package/index.test.ts +0 -247
- package/index.ts +0 -1510
- package/tsconfig.json +0 -7
- package/utils.server.ts +0 -79
- package/utils.ts +0 -212
package/index.test.ts
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { decode } from "./file";
|
|
2
|
-
import Inibase, { Schema, Data } from "./index";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
// import os from "os";
|
|
5
|
-
// Create a new instance of Inibase with the database path
|
|
6
|
-
const db = new Inibase("inicontent", join("..", "inicontent", "databases"));
|
|
7
|
-
|
|
8
|
-
const schema_1: Schema = [
|
|
9
|
-
{
|
|
10
|
-
key: "username",
|
|
11
|
-
type: "string",
|
|
12
|
-
required: true,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
key: "password",
|
|
16
|
-
type: "password",
|
|
17
|
-
required: true,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
key: "email",
|
|
21
|
-
type: "email",
|
|
22
|
-
required: true,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
key: "role",
|
|
26
|
-
type: "string",
|
|
27
|
-
required: true,
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
const data_1: Data = [
|
|
32
|
-
{
|
|
33
|
-
username: "admin",
|
|
34
|
-
password: "admina",
|
|
35
|
-
email: "karim.amahtil@gmail.com",
|
|
36
|
-
role: "admin",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
username: "kamatil",
|
|
40
|
-
password: "admina",
|
|
41
|
-
email: "karim.amahtil21@gmail.com",
|
|
42
|
-
role: "user",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
username: "tvonthego",
|
|
46
|
-
password: "azqswx",
|
|
47
|
-
email: "vip72abdo@gmail.com",
|
|
48
|
-
role: "user",
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
const schema_2: Schema = [
|
|
53
|
-
{
|
|
54
|
-
key: "name",
|
|
55
|
-
type: "string",
|
|
56
|
-
required: true,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
key: "slug",
|
|
60
|
-
type: "string",
|
|
61
|
-
required: true,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
key: "icon",
|
|
65
|
-
type: "url",
|
|
66
|
-
required: false,
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
key: "languages",
|
|
70
|
-
type: "array",
|
|
71
|
-
children: "string",
|
|
72
|
-
required: false,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
key: "allowed_domains",
|
|
76
|
-
type: "array",
|
|
77
|
-
children: "url",
|
|
78
|
-
required: false,
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
key: "tables",
|
|
82
|
-
type: "array",
|
|
83
|
-
children: [
|
|
84
|
-
{
|
|
85
|
-
key: "name",
|
|
86
|
-
type: "string",
|
|
87
|
-
required: true,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
key: "slug",
|
|
91
|
-
type: "string",
|
|
92
|
-
required: true,
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
key: "allowed_methods",
|
|
96
|
-
type: "array",
|
|
97
|
-
children: [
|
|
98
|
-
{
|
|
99
|
-
key: "role",
|
|
100
|
-
type: "string",
|
|
101
|
-
required: true,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
key: "methods",
|
|
105
|
-
type: "string",
|
|
106
|
-
required: true,
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
required: true,
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
key: "schema",
|
|
113
|
-
type: "array",
|
|
114
|
-
children: [
|
|
115
|
-
{
|
|
116
|
-
key: "id",
|
|
117
|
-
type: "id",
|
|
118
|
-
required: true,
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
key: "subtype",
|
|
122
|
-
type: "string",
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
key: "accept",
|
|
126
|
-
type: "array",
|
|
127
|
-
children: "string",
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
key: "search",
|
|
131
|
-
type: "array",
|
|
132
|
-
children: "string",
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
key: "label",
|
|
136
|
-
type: "array",
|
|
137
|
-
children: "string",
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
key: "image",
|
|
141
|
-
type: "string",
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
key: "values",
|
|
145
|
-
type: "array",
|
|
146
|
-
children: "string",
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
key: "user",
|
|
154
|
-
type: ["array", "table"],
|
|
155
|
-
children: "table",
|
|
156
|
-
required: false,
|
|
157
|
-
},
|
|
158
|
-
];
|
|
159
|
-
|
|
160
|
-
const data_2 = [
|
|
161
|
-
{
|
|
162
|
-
name: "Inicontent",
|
|
163
|
-
slug: "inicontent",
|
|
164
|
-
allowed_domains: ["http://localhost:3000"],
|
|
165
|
-
tables: [
|
|
166
|
-
{
|
|
167
|
-
name: "User",
|
|
168
|
-
slug: "user",
|
|
169
|
-
allowed_methods: [
|
|
170
|
-
{
|
|
171
|
-
role: "user",
|
|
172
|
-
methods: "cru",
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
role: "guest",
|
|
176
|
-
methods: "c",
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
name: "Database",
|
|
182
|
-
slug: "database",
|
|
183
|
-
allowed_methods: [
|
|
184
|
-
{
|
|
185
|
-
role: "user",
|
|
186
|
-
methods: "crud",
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
role: "guest",
|
|
190
|
-
methods: "c",
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
user: 1,
|
|
196
|
-
},
|
|
197
|
-
];
|
|
198
|
-
try {
|
|
199
|
-
// db.setTableSchema("database", schema_2);
|
|
200
|
-
// const DATA = await db.post("database", data_2);
|
|
201
|
-
// const DATA = await db.delete("database", 2);
|
|
202
|
-
// const DATA = await db.post("database", {
|
|
203
|
-
// slug: "demo",
|
|
204
|
-
// tables: [
|
|
205
|
-
// {
|
|
206
|
-
// id: 1,
|
|
207
|
-
// slug: "user",
|
|
208
|
-
// allowed_methods: [
|
|
209
|
-
// {
|
|
210
|
-
// role: "user",
|
|
211
|
-
// methods: ["c", "r", "u"],
|
|
212
|
-
// },
|
|
213
|
-
// {
|
|
214
|
-
// role: "guest",
|
|
215
|
-
// methods: ["c"],
|
|
216
|
-
// },
|
|
217
|
-
// {
|
|
218
|
-
// role: "admin",
|
|
219
|
-
// methods: ["d", "u"],
|
|
220
|
-
// },
|
|
221
|
-
// ],
|
|
222
|
-
// },
|
|
223
|
-
// {
|
|
224
|
-
// id: 1,
|
|
225
|
-
// slug: "user",
|
|
226
|
-
// allowed_methods: [
|
|
227
|
-
// {
|
|
228
|
-
// role: "user",
|
|
229
|
-
// methods: ["c", "r", "u"],
|
|
230
|
-
// },
|
|
231
|
-
// {
|
|
232
|
-
// role: "guest",
|
|
233
|
-
// methods: ["c"],
|
|
234
|
-
// },
|
|
235
|
-
// {
|
|
236
|
-
// role: "admin",
|
|
237
|
-
// methods: ["d", "u"],
|
|
238
|
-
// },
|
|
239
|
-
// ],
|
|
240
|
-
// },
|
|
241
|
-
// ],
|
|
242
|
-
// });
|
|
243
|
-
const DATA = await db.get("database");
|
|
244
|
-
console.log(JSON.stringify(DATA, null, 4));
|
|
245
|
-
} catch (er) {
|
|
246
|
-
console.log(er);
|
|
247
|
-
}
|