@tanglemedia/svelte-starter-directus-api 0.0.9 → 0.0.11
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/client.d.ts +6 -6
- package/dist/client.js +12 -12
- package/dist/static.d.ts +6 -6
- package/dist/static.js +12 -12
- package/package.json +10 -10
- package/src/client.ts +12 -12
- package/src/static.ts +12 -12
package/dist/client.d.ts
CHANGED
|
@@ -7,12 +7,12 @@ declare class ApiClientDirectus implements ApiAdapterInterface {
|
|
|
7
7
|
constructor(baseURL: string);
|
|
8
8
|
private init;
|
|
9
9
|
getConfig<T extends object>(configuration?: unknown): BaseApiAdapterConfig;
|
|
10
|
-
request<T>(method: BaseApiMethods, url: string,
|
|
11
|
-
find<T>(collection: string,
|
|
12
|
-
findOne<T>(collection: string, key?: ApiId,
|
|
13
|
-
aggregate<T>(collection: string,
|
|
14
|
-
patch<T>(collection: string, key: ApiId,
|
|
15
|
-
post<T>(collection: string, data: AnyObject,
|
|
10
|
+
request<T>(method: BaseApiMethods, url: string, query?: Record<string, unknown>): Promise<T>;
|
|
11
|
+
find<T>(collection: string, query?: Record<string, unknown>): Promise<T>;
|
|
12
|
+
findOne<T>(collection: string, key?: ApiId, query?: Record<string, unknown>): Promise<T>;
|
|
13
|
+
aggregate<T>(collection: string, query?: Record<string, unknown>): Promise<T>;
|
|
14
|
+
patch<T>(collection: string, key: ApiId, query?: Record<string, unknown>): Promise<T>;
|
|
15
|
+
post<T>(collection: string, data: AnyObject, query?: Record<string, unknown>): Promise<T>;
|
|
16
16
|
delete<T>(collection: string, key?: ApiId): Promise<T>;
|
|
17
17
|
put<T>(collection: string, payload: AnyObject, config?: ApiAdapterRequestConfig, key?: ApiId): Promise<T>;
|
|
18
18
|
upload<T>(path: string | undefined, data: FormData): Promise<T>;
|
package/dist/client.js
CHANGED
|
@@ -54,10 +54,10 @@ class ApiClientDirectus {
|
|
|
54
54
|
};
|
|
55
55
|
return Object.assign(client, config);
|
|
56
56
|
}
|
|
57
|
-
async request(method, url,
|
|
57
|
+
async request(method, url, query) {
|
|
58
58
|
try {
|
|
59
59
|
const response = await this.directus.request(() => {
|
|
60
|
-
const params = JSON.stringify(
|
|
60
|
+
const params = JSON.stringify(query);
|
|
61
61
|
return {
|
|
62
62
|
path: `${url}?${params}`,
|
|
63
63
|
method: method
|
|
@@ -70,11 +70,11 @@ class ApiClientDirectus {
|
|
|
70
70
|
throw error;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
async find(collection,
|
|
73
|
+
async find(collection, query) {
|
|
74
74
|
// console.log('in find');
|
|
75
75
|
try {
|
|
76
76
|
// console.log(`Find ${collection}`)
|
|
77
|
-
const response = await this.directus.request(readItems(collection,
|
|
77
|
+
const response = await this.directus.request(readItems(collection, query));
|
|
78
78
|
return response;
|
|
79
79
|
}
|
|
80
80
|
catch (error) {
|
|
@@ -82,9 +82,9 @@ class ApiClientDirectus {
|
|
|
82
82
|
throw error;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
async findOne(collection, key,
|
|
85
|
+
async findOne(collection, key, query) {
|
|
86
86
|
try {
|
|
87
|
-
const response = await this.directus.request(readItem(collection, key,
|
|
87
|
+
const response = await this.directus.request(readItem(collection, key, query));
|
|
88
88
|
return response;
|
|
89
89
|
}
|
|
90
90
|
catch (error) {
|
|
@@ -92,13 +92,13 @@ class ApiClientDirectus {
|
|
|
92
92
|
throw error;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
async aggregate(collection,
|
|
95
|
+
async aggregate(collection, query) {
|
|
96
96
|
try {
|
|
97
97
|
const response = await this.directus.request(aggregate(collection, {
|
|
98
98
|
aggregate: {
|
|
99
99
|
count: 'id'
|
|
100
100
|
},
|
|
101
|
-
|
|
101
|
+
query
|
|
102
102
|
}));
|
|
103
103
|
return response;
|
|
104
104
|
}
|
|
@@ -107,9 +107,9 @@ class ApiClientDirectus {
|
|
|
107
107
|
throw error;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
async patch(collection, key,
|
|
110
|
+
async patch(collection, key, query) {
|
|
111
111
|
try {
|
|
112
|
-
const response = await this.directus.request(updateItem(collection, key,
|
|
112
|
+
const response = await this.directus.request(updateItem(collection, key, query));
|
|
113
113
|
return response;
|
|
114
114
|
}
|
|
115
115
|
catch (error) {
|
|
@@ -117,9 +117,9 @@ class ApiClientDirectus {
|
|
|
117
117
|
throw error;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
async post(collection, data,
|
|
120
|
+
async post(collection, data, query) {
|
|
121
121
|
try {
|
|
122
|
-
const response = await this.directus.request(createItem(collection, data,
|
|
122
|
+
const response = await this.directus.request(createItem(collection, data, query));
|
|
123
123
|
return response;
|
|
124
124
|
}
|
|
125
125
|
catch (error) {
|
package/dist/static.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare class ApiStaticDirectus implements ApiAdapterInterface {
|
|
|
8
8
|
constructor(baseURL: string, directusAccessToken: string);
|
|
9
9
|
private init;
|
|
10
10
|
getConfig<T extends object>(configuration?: unknown): BaseApiAdapterConfig;
|
|
11
|
-
request<T>(method: BaseApiMethods, url: string,
|
|
11
|
+
request<T>(method: BaseApiMethods, url: string, query?: Record<string, unknown>): Promise<T>;
|
|
12
12
|
createUser(data: {
|
|
13
13
|
email: string;
|
|
14
14
|
password: string;
|
|
@@ -19,11 +19,11 @@ declare class ApiStaticDirectus implements ApiAdapterInterface {
|
|
|
19
19
|
message: string;
|
|
20
20
|
type: string;
|
|
21
21
|
}>;
|
|
22
|
-
find<T>(collection: string,
|
|
23
|
-
findOne<T>(collection: string, key: ApiId,
|
|
24
|
-
aggregate<T>(collection: string,
|
|
25
|
-
patch<T>(collection: string, key: ApiId,
|
|
26
|
-
post<T>(collection: string, data: AnyObject,
|
|
22
|
+
find<T>(collection: string, query?: Record<string, unknown>): Promise<T>;
|
|
23
|
+
findOne<T>(collection: string, key: ApiId, query?: Record<string, unknown>): Promise<T>;
|
|
24
|
+
aggregate<T>(collection: string, query?: Record<string, unknown>): Promise<T>;
|
|
25
|
+
patch<T>(collection: string, key: ApiId, query?: Record<string, unknown>): Promise<T>;
|
|
26
|
+
post<T>(collection: string, data: AnyObject, query?: Record<string, unknown>): Promise<T>;
|
|
27
27
|
delete<T>(collection: string, keys: ApiId): Promise<T>;
|
|
28
28
|
put<T>(collection: string, payload: AnyObject, config?: ApiAdapterRequestConfig, key?: ApiId): Promise<T>;
|
|
29
29
|
upload<T>(path: string | undefined, data: FormData): Promise<T>;
|
package/dist/static.js
CHANGED
|
@@ -28,10 +28,10 @@ class ApiStaticDirectus {
|
|
|
28
28
|
};
|
|
29
29
|
return Object.assign(client, config);
|
|
30
30
|
}
|
|
31
|
-
async request(method, url,
|
|
31
|
+
async request(method, url, query) {
|
|
32
32
|
try {
|
|
33
33
|
const response = await this.directus.request(() => {
|
|
34
|
-
const params = JSON.stringify(
|
|
34
|
+
const params = JSON.stringify(query);
|
|
35
35
|
return {
|
|
36
36
|
path: `${url}?${params}`,
|
|
37
37
|
method: method
|
|
@@ -54,9 +54,9 @@ class ApiStaticDirectus {
|
|
|
54
54
|
throw error;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
async find(collection,
|
|
57
|
+
async find(collection, query) {
|
|
58
58
|
try {
|
|
59
|
-
const response = await this.directus.request(readItems(collection,
|
|
59
|
+
const response = await this.directus.request(readItems(collection, query));
|
|
60
60
|
return response;
|
|
61
61
|
}
|
|
62
62
|
catch (error) {
|
|
@@ -64,9 +64,9 @@ class ApiStaticDirectus {
|
|
|
64
64
|
throw error;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
async findOne(collection, key,
|
|
67
|
+
async findOne(collection, key, query) {
|
|
68
68
|
try {
|
|
69
|
-
const response = await this.directus.request(readItem(collection, key,
|
|
69
|
+
const response = await this.directus.request(readItem(collection, key, query));
|
|
70
70
|
return response;
|
|
71
71
|
}
|
|
72
72
|
catch (error) {
|
|
@@ -74,13 +74,13 @@ class ApiStaticDirectus {
|
|
|
74
74
|
throw error;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
async aggregate(collection,
|
|
77
|
+
async aggregate(collection, query) {
|
|
78
78
|
try {
|
|
79
79
|
const response = await this.directus.request(aggregate(collection, {
|
|
80
80
|
aggregate: {
|
|
81
81
|
count: 'id'
|
|
82
82
|
},
|
|
83
|
-
|
|
83
|
+
query
|
|
84
84
|
}));
|
|
85
85
|
return response;
|
|
86
86
|
}
|
|
@@ -89,9 +89,9 @@ class ApiStaticDirectus {
|
|
|
89
89
|
throw error;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
async patch(collection, key,
|
|
92
|
+
async patch(collection, key, query) {
|
|
93
93
|
try {
|
|
94
|
-
const response = await this.directus.request(updateItems(collection, key,
|
|
94
|
+
const response = await this.directus.request(updateItems(collection, key, query));
|
|
95
95
|
return response;
|
|
96
96
|
}
|
|
97
97
|
catch (error) {
|
|
@@ -99,9 +99,9 @@ class ApiStaticDirectus {
|
|
|
99
99
|
throw error;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
async post(collection, data,
|
|
102
|
+
async post(collection, data, query) {
|
|
103
103
|
try {
|
|
104
|
-
const response = await this.directus.request(createItem(collection, data,
|
|
104
|
+
const response = await this.directus.request(createItem(collection, data, query));
|
|
105
105
|
return response;
|
|
106
106
|
}
|
|
107
107
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanglemedia/svelte-starter-directus-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"types": "src/index.ts",
|
|
6
6
|
"description": "directus API wrapper for all the directus sdk functionality",
|
|
@@ -22,23 +22,23 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@sveltejs/adapter-auto": "^3.0
|
|
25
|
+
"@sveltejs/adapter-auto": "^3.1.0",
|
|
26
26
|
"@sveltejs/package": "^2.2.5",
|
|
27
27
|
"@sveltejs/vite-plugin-svelte": "^3.0.1",
|
|
28
|
-
"@testing-library/jest-dom": "^6.
|
|
28
|
+
"@testing-library/jest-dom": "^6.2.0",
|
|
29
29
|
"@testing-library/svelte": "^4.0.5",
|
|
30
|
-
"@vitest/coverage-v8": "^1.
|
|
31
|
-
"jsdom": "^23.0
|
|
32
|
-
"msw": "^2.0
|
|
30
|
+
"@vitest/coverage-v8": "^1.2.0",
|
|
31
|
+
"jsdom": "^23.2.0",
|
|
32
|
+
"msw": "^2.1.0",
|
|
33
33
|
"svelte": "^4.2.8",
|
|
34
|
-
"svelte-check": "^3.6.
|
|
35
|
-
"vite": "^5.0.
|
|
36
|
-
"vitest": "^1.
|
|
34
|
+
"svelte-check": "^3.6.3",
|
|
35
|
+
"vite": "^5.0.11",
|
|
36
|
+
"vitest": "^1.2.0",
|
|
37
37
|
"eslint-config-custom": "0.0.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@directus/sdk": "^14.0.0",
|
|
41
|
-
"@tanglemedia/svelte-starter-core": "0.0.
|
|
41
|
+
"@tanglemedia/svelte-starter-core": "0.0.15"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@sveltejs/kit": ">=1.20 <2",
|
package/src/client.ts
CHANGED
|
@@ -91,11 +91,11 @@ class ApiClientDirectus implements ApiAdapterInterface {
|
|
|
91
91
|
public async request<T>(
|
|
92
92
|
method: BaseApiMethods,
|
|
93
93
|
url: string,
|
|
94
|
-
|
|
94
|
+
query?: Record<string, unknown>
|
|
95
95
|
): Promise<T> {
|
|
96
96
|
try {
|
|
97
97
|
const response = await this.directus.request<T>(() => {
|
|
98
|
-
const params = JSON.stringify(
|
|
98
|
+
const params = JSON.stringify(query);
|
|
99
99
|
return {
|
|
100
100
|
path: `${url}?${params}`,
|
|
101
101
|
method: method
|
|
@@ -108,11 +108,11 @@ class ApiClientDirectus implements ApiAdapterInterface {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
public async find<T>(collection: string,
|
|
111
|
+
public async find<T>(collection: string, query?: Record<string, unknown>): Promise<T> {
|
|
112
112
|
// console.log('in find');
|
|
113
113
|
try {
|
|
114
114
|
// console.log(`Find ${collection}`)
|
|
115
|
-
const response = await this.directus.request<T>(readItems(collection,
|
|
115
|
+
const response = await this.directus.request<T>(readItems(collection, query));
|
|
116
116
|
return response;
|
|
117
117
|
} catch (error) {
|
|
118
118
|
console.error(`Error fetching all ${collection}:`, error);
|
|
@@ -123,10 +123,10 @@ class ApiClientDirectus implements ApiAdapterInterface {
|
|
|
123
123
|
public async findOne<T>(
|
|
124
124
|
collection: string,
|
|
125
125
|
key?: ApiId,
|
|
126
|
-
|
|
126
|
+
query?: Record<string, unknown>
|
|
127
127
|
): Promise<T> {
|
|
128
128
|
try {
|
|
129
|
-
const response = await this.directus.request<T>(readItem(collection, key,
|
|
129
|
+
const response = await this.directus.request<T>(readItem(collection, key, query));
|
|
130
130
|
return response;
|
|
131
131
|
} catch (error) {
|
|
132
132
|
console.error(`Error fetching ${collection}:`, error);
|
|
@@ -134,14 +134,14 @@ class ApiClientDirectus implements ApiAdapterInterface {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
public async aggregate<T>(collection: string,
|
|
137
|
+
public async aggregate<T>(collection: string, query?: Record<string, unknown>): Promise<T> {
|
|
138
138
|
try {
|
|
139
139
|
const response = await this.directus.request<T>(
|
|
140
140
|
aggregate(collection, {
|
|
141
141
|
aggregate: {
|
|
142
142
|
count: 'id'
|
|
143
143
|
},
|
|
144
|
-
|
|
144
|
+
query
|
|
145
145
|
})
|
|
146
146
|
);
|
|
147
147
|
return response;
|
|
@@ -154,10 +154,10 @@ class ApiClientDirectus implements ApiAdapterInterface {
|
|
|
154
154
|
public async patch<T>(
|
|
155
155
|
collection: string,
|
|
156
156
|
key: ApiId,
|
|
157
|
-
|
|
157
|
+
query?: Record<string, unknown>
|
|
158
158
|
): Promise<T> {
|
|
159
159
|
try {
|
|
160
|
-
const response = await this.directus.request<T>(updateItem(collection, key,
|
|
160
|
+
const response = await this.directus.request<T>(updateItem(collection, key, query));
|
|
161
161
|
return response;
|
|
162
162
|
} catch (error) {
|
|
163
163
|
console.error(`Error updating all ${collection}:`, error);
|
|
@@ -168,10 +168,10 @@ class ApiClientDirectus implements ApiAdapterInterface {
|
|
|
168
168
|
public async post<T>(
|
|
169
169
|
collection: string,
|
|
170
170
|
data: AnyObject,
|
|
171
|
-
|
|
171
|
+
query?: Record<string, unknown>
|
|
172
172
|
): Promise<T> {
|
|
173
173
|
try {
|
|
174
|
-
const response = await this.directus.request<T>(createItem(collection, data,
|
|
174
|
+
const response = await this.directus.request<T>(createItem(collection, data, query));
|
|
175
175
|
return response;
|
|
176
176
|
} catch (error) {
|
|
177
177
|
console.error(`Error creating items ${collection}:`, error);
|
package/src/static.ts
CHANGED
|
@@ -61,11 +61,11 @@ class ApiStaticDirectus implements ApiAdapterInterface {
|
|
|
61
61
|
public async request<T>(
|
|
62
62
|
method: BaseApiMethods,
|
|
63
63
|
url: string,
|
|
64
|
-
|
|
64
|
+
query?: Record<string, unknown>
|
|
65
65
|
): Promise<T> {
|
|
66
66
|
try {
|
|
67
67
|
const response = await this.directus.request<T>(() => {
|
|
68
|
-
const params = JSON.stringify(
|
|
68
|
+
const params = JSON.stringify(query);
|
|
69
69
|
return {
|
|
70
70
|
path: `${url}?${params}`,
|
|
71
71
|
method: method
|
|
@@ -93,9 +93,9 @@ class ApiStaticDirectus implements ApiAdapterInterface {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
public async find<T>(collection: string,
|
|
96
|
+
public async find<T>(collection: string, query?: Record<string, unknown>): Promise<T> {
|
|
97
97
|
try {
|
|
98
|
-
const response = await this.directus.request<T>(readItems(collection,
|
|
98
|
+
const response = await this.directus.request<T>(readItems(collection, query));
|
|
99
99
|
return response;
|
|
100
100
|
} catch (error) {
|
|
101
101
|
console.error(`Error fetching all ${collection}:`, error);
|
|
@@ -106,10 +106,10 @@ class ApiStaticDirectus implements ApiAdapterInterface {
|
|
|
106
106
|
public async findOne<T>(
|
|
107
107
|
collection: string,
|
|
108
108
|
key: ApiId,
|
|
109
|
-
|
|
109
|
+
query?: Record<string, unknown>
|
|
110
110
|
): Promise<T> {
|
|
111
111
|
try {
|
|
112
|
-
const response = await this.directus.request<T>(readItem(collection, key,
|
|
112
|
+
const response = await this.directus.request<T>(readItem(collection, key, query));
|
|
113
113
|
return response;
|
|
114
114
|
} catch (error) {
|
|
115
115
|
console.error(`Error fetching ${collection}:`, error);
|
|
@@ -117,14 +117,14 @@ class ApiStaticDirectus implements ApiAdapterInterface {
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
public async aggregate<T>(collection: string,
|
|
120
|
+
public async aggregate<T>(collection: string, query?: Record<string, unknown>): Promise<T> {
|
|
121
121
|
try {
|
|
122
122
|
const response = await this.directus.request<T>(
|
|
123
123
|
aggregate(collection, {
|
|
124
124
|
aggregate: {
|
|
125
125
|
count: 'id'
|
|
126
126
|
},
|
|
127
|
-
|
|
127
|
+
query
|
|
128
128
|
})
|
|
129
129
|
);
|
|
130
130
|
return response;
|
|
@@ -137,10 +137,10 @@ class ApiStaticDirectus implements ApiAdapterInterface {
|
|
|
137
137
|
public async patch<T>(
|
|
138
138
|
collection: string,
|
|
139
139
|
key: ApiId,
|
|
140
|
-
|
|
140
|
+
query?: Record<string, unknown>
|
|
141
141
|
): Promise<T> {
|
|
142
142
|
try {
|
|
143
|
-
const response = await this.directus.request<T>(updateItems(collection, key,
|
|
143
|
+
const response = await this.directus.request<T>(updateItems(collection, key, query));
|
|
144
144
|
return response;
|
|
145
145
|
} catch (error) {
|
|
146
146
|
console.error(`Error updating all ${collection}:`, error);
|
|
@@ -151,10 +151,10 @@ class ApiStaticDirectus implements ApiAdapterInterface {
|
|
|
151
151
|
public async post<T>(
|
|
152
152
|
collection: string,
|
|
153
153
|
data: AnyObject,
|
|
154
|
-
|
|
154
|
+
query?: Record<string, unknown>
|
|
155
155
|
): Promise<T> {
|
|
156
156
|
try {
|
|
157
|
-
const response = await this.directus.request<T>(createItem(collection, data,
|
|
157
|
+
const response = await this.directus.request<T>(createItem(collection, data, query));
|
|
158
158
|
return response;
|
|
159
159
|
} catch (error) {
|
|
160
160
|
console.error(`Error creating items ${collection}:`, error);
|