@matvdt/js-toolkit 0.0.1-canary.14 → 0.0.1-canary.16
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/payload-cms/server/create-collection.d.ts +10 -9
- package/dist/payload-cms/server/create-global.d.ts +2 -2
- package/dist/payload-cms/server/get-payload.d.ts +1 -1
- package/dist/payload-cms/server/index.cjs +43 -35
- package/dist/payload-cms/server/index.d.ts +1 -1
- package/dist/payload-cms/server/index.js +41 -33
- package/dist/payload-cms/server/{db.d.ts → payload.d.ts} +4 -4
- package/package.json +1 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { CollectionSlug, Where } from 'payload';
|
|
2
|
-
import {
|
|
2
|
+
import { payload, DeleteOptions, FindByIDOptions, FindOptions, UpdateData, UpdateOptions } from './payload';
|
|
3
3
|
export type BaseCollectionMethods<TSlug extends CollectionSlug> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
find: (options?: FindOptions) => ReturnType<typeof payload.find<TSlug>>;
|
|
5
|
+
findOne: (options?: FindOptions) => ReturnType<typeof payload.findOne<TSlug>>;
|
|
6
|
+
findBySlug: (slug: string, options?: FindOptions) => ReturnType<typeof payload.findBySlug<TSlug>>;
|
|
7
|
+
findByID: (id: string | number, options?: FindByIDOptions) => ReturnType<typeof payload.findByID<TSlug>>;
|
|
8
|
+
findAll: (options?: FindOptions) => ReturnType<typeof payload.findAll<TSlug>>;
|
|
9
|
+
update: (id: string | number, data: UpdateData, options?: UpdateOptions) => ReturnType<typeof payload.update<TSlug>>;
|
|
10
|
+
updateMany: (where: Where, data: UpdateData, options?: UpdateOptions) => ReturnType<typeof payload.updateMany<TSlug>>;
|
|
11
|
+
delete: (id: string | number, options?: DeleteOptions) => ReturnType<typeof payload.delete<TSlug>>;
|
|
12
|
+
deleteMany: (where: Where, options?: DeleteOptions) => ReturnType<typeof payload.deleteMany<TSlug>>;
|
|
12
13
|
};
|
|
13
14
|
type ExtensionFunction = (...args: any[]) => any;
|
|
14
15
|
type ExtensionObject = Record<string, unknown>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GlobalSlug } from 'payload';
|
|
2
|
-
import {
|
|
2
|
+
import { payload } from './payload';
|
|
3
3
|
type BaseGlobalMethods<TSlug extends GlobalSlug> = {
|
|
4
|
-
get: () => ReturnType<typeof
|
|
4
|
+
get: () => ReturnType<typeof payload.global<TSlug>>;
|
|
5
5
|
};
|
|
6
6
|
export declare function createGlobal<TSlug extends GlobalSlug, TExtend extends Record<string, (...args: any[]) => any> = {}>(slug: TSlug, extend?: (base: BaseGlobalMethods<TSlug>) => TExtend): BaseGlobalMethods<TSlug> & TExtend;
|
|
7
7
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Payload, type SanitizedConfig } from 'payload';
|
|
2
2
|
export declare function configurePayload(config: Promise<SanitizedConfig> | SanitizedConfig): void;
|
|
3
3
|
export declare const getPayload: (config?: Promise<SanitizedConfig> | SanitizedConfig) => Promise<Payload>;
|
|
@@ -23,12 +23,12 @@ __export(server_exports, {
|
|
|
23
23
|
configurePayload: () => configurePayload,
|
|
24
24
|
createCollection: () => createCollection,
|
|
25
25
|
createGlobal: () => createGlobal,
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
getPayload: () => getPayload,
|
|
27
|
+
payload: () => payload
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(server_exports);
|
|
30
30
|
|
|
31
|
-
// src/payload-cms/server/
|
|
31
|
+
// src/payload-cms/server/payload.ts
|
|
32
32
|
var import_react = require("react");
|
|
33
33
|
|
|
34
34
|
// src/payload-cms/server/get-payload.ts
|
|
@@ -48,14 +48,14 @@ var getPayload = async (config) => {
|
|
|
48
48
|
return (0, import_payload.getPayload)({ config: resolvedConfig });
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
// src/payload-cms/server/
|
|
51
|
+
// src/payload-cms/server/payload.ts
|
|
52
52
|
var getClient = (0, import_react.cache)(async () => {
|
|
53
53
|
return await getPayload();
|
|
54
54
|
});
|
|
55
|
-
var
|
|
55
|
+
var payload = {
|
|
56
56
|
findOne: async (collection, options) => {
|
|
57
|
-
const
|
|
58
|
-
const res = await
|
|
57
|
+
const payload2 = await getClient();
|
|
58
|
+
const res = await payload2.find({
|
|
59
59
|
...options,
|
|
60
60
|
collection,
|
|
61
61
|
limit: 1
|
|
@@ -63,7 +63,7 @@ var db = {
|
|
|
63
63
|
return res.docs[0] ?? null;
|
|
64
64
|
},
|
|
65
65
|
findBySlug: async (collection, slug, options) => {
|
|
66
|
-
return
|
|
66
|
+
return payload.findOne(
|
|
67
67
|
collection,
|
|
68
68
|
{
|
|
69
69
|
...options,
|
|
@@ -74,9 +74,16 @@ var db = {
|
|
|
74
74
|
}
|
|
75
75
|
);
|
|
76
76
|
},
|
|
77
|
+
find: async (collection, options) => {
|
|
78
|
+
const payload2 = await getClient();
|
|
79
|
+
return payload2.find({
|
|
80
|
+
...options,
|
|
81
|
+
collection
|
|
82
|
+
});
|
|
83
|
+
},
|
|
77
84
|
findAll: async (collection, options) => {
|
|
78
|
-
const
|
|
79
|
-
const res = await
|
|
85
|
+
const payload2 = await getClient();
|
|
86
|
+
const res = await payload2.find({
|
|
80
87
|
...options,
|
|
81
88
|
collection,
|
|
82
89
|
limit: options?.limit ?? 100
|
|
@@ -84,24 +91,24 @@ var db = {
|
|
|
84
91
|
return res.docs;
|
|
85
92
|
},
|
|
86
93
|
findByID: async (collection, id, options) => {
|
|
87
|
-
const
|
|
88
|
-
return
|
|
94
|
+
const payload2 = await getClient();
|
|
95
|
+
return payload2.findByID({
|
|
89
96
|
...options,
|
|
90
97
|
collection,
|
|
91
98
|
id
|
|
92
99
|
});
|
|
93
100
|
},
|
|
94
101
|
create: async (collection, data, options) => {
|
|
95
|
-
const
|
|
96
|
-
return
|
|
102
|
+
const payload2 = await getClient();
|
|
103
|
+
return payload2.create({
|
|
97
104
|
...options,
|
|
98
105
|
collection,
|
|
99
106
|
data
|
|
100
107
|
});
|
|
101
108
|
},
|
|
102
109
|
update: async (collection, id, data, options) => {
|
|
103
|
-
const
|
|
104
|
-
return
|
|
110
|
+
const payload2 = await getClient();
|
|
111
|
+
return payload2.update({
|
|
105
112
|
...options,
|
|
106
113
|
collection,
|
|
107
114
|
id,
|
|
@@ -109,8 +116,8 @@ var db = {
|
|
|
109
116
|
});
|
|
110
117
|
},
|
|
111
118
|
updateMany: async (collection, where, data, options) => {
|
|
112
|
-
const
|
|
113
|
-
return
|
|
119
|
+
const payload2 = await getClient();
|
|
120
|
+
return payload2.update({
|
|
114
121
|
...options,
|
|
115
122
|
collection,
|
|
116
123
|
where,
|
|
@@ -119,8 +126,8 @@ var db = {
|
|
|
119
126
|
});
|
|
120
127
|
},
|
|
121
128
|
delete: async (collection, id, options) => {
|
|
122
|
-
const
|
|
123
|
-
return
|
|
129
|
+
const payload2 = await getClient();
|
|
130
|
+
return payload2.delete({
|
|
124
131
|
...options,
|
|
125
132
|
collection,
|
|
126
133
|
id,
|
|
@@ -128,8 +135,8 @@ var db = {
|
|
|
128
135
|
});
|
|
129
136
|
},
|
|
130
137
|
deleteMany: async (collection, where, options) => {
|
|
131
|
-
const
|
|
132
|
-
return
|
|
138
|
+
const payload2 = await getClient();
|
|
139
|
+
return payload2.delete({
|
|
133
140
|
...options,
|
|
134
141
|
collection,
|
|
135
142
|
where,
|
|
@@ -137,8 +144,8 @@ var db = {
|
|
|
137
144
|
});
|
|
138
145
|
},
|
|
139
146
|
global: async (slug) => {
|
|
140
|
-
const
|
|
141
|
-
return
|
|
147
|
+
const payload2 = await getClient();
|
|
148
|
+
return payload2.findGlobal({ slug });
|
|
142
149
|
},
|
|
143
150
|
raw: getClient
|
|
144
151
|
};
|
|
@@ -146,14 +153,15 @@ var db = {
|
|
|
146
153
|
// src/payload-cms/server/create-collection.ts
|
|
147
154
|
function createCollection(collection, extend) {
|
|
148
155
|
const base = {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
find: (options) => payload.find(collection, options),
|
|
157
|
+
findOne: (options) => payload.findOne(collection, options),
|
|
158
|
+
findByID: (id, options) => payload.findByID(collection, id, options),
|
|
159
|
+
findBySlug: (slug, options) => payload.findBySlug(collection, slug, options),
|
|
160
|
+
findAll: (options) => payload.findAll(collection, options),
|
|
161
|
+
update: (id, data, options) => payload.update(collection, id, data, options),
|
|
162
|
+
updateMany: (where, data, options) => payload.updateMany(collection, where, data, options),
|
|
163
|
+
delete: (id, options) => payload.delete(collection, id, options),
|
|
164
|
+
deleteMany: (where, options) => payload.deleteMany(collection, where, options)
|
|
157
165
|
};
|
|
158
166
|
const extended = extend ? extend(base) : void 0;
|
|
159
167
|
return {
|
|
@@ -165,7 +173,7 @@ function createCollection(collection, extend) {
|
|
|
165
173
|
// src/payload-cms/server/create-global.ts
|
|
166
174
|
function createGlobal(slug, extend) {
|
|
167
175
|
const base = {
|
|
168
|
-
get: () =>
|
|
176
|
+
get: () => payload.global(slug)
|
|
169
177
|
};
|
|
170
178
|
const extended = extend ? extend(base) : void 0;
|
|
171
179
|
return {
|
|
@@ -178,6 +186,6 @@ function createGlobal(slug, extend) {
|
|
|
178
186
|
configurePayload,
|
|
179
187
|
createCollection,
|
|
180
188
|
createGlobal,
|
|
181
|
-
|
|
182
|
-
|
|
189
|
+
getPayload,
|
|
190
|
+
payload
|
|
183
191
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/payload-cms/server/
|
|
1
|
+
// src/payload-cms/server/payload.ts
|
|
2
2
|
import { cache } from "react";
|
|
3
3
|
|
|
4
4
|
// src/payload-cms/server/get-payload.ts
|
|
@@ -18,14 +18,14 @@ var getPayload = async (config) => {
|
|
|
18
18
|
return getPayloadSDK({ config: resolvedConfig });
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
// src/payload-cms/server/
|
|
21
|
+
// src/payload-cms/server/payload.ts
|
|
22
22
|
var getClient = cache(async () => {
|
|
23
23
|
return await getPayload();
|
|
24
24
|
});
|
|
25
|
-
var
|
|
25
|
+
var payload = {
|
|
26
26
|
findOne: async (collection, options) => {
|
|
27
|
-
const
|
|
28
|
-
const res = await
|
|
27
|
+
const payload2 = await getClient();
|
|
28
|
+
const res = await payload2.find({
|
|
29
29
|
...options,
|
|
30
30
|
collection,
|
|
31
31
|
limit: 1
|
|
@@ -33,7 +33,7 @@ var db = {
|
|
|
33
33
|
return res.docs[0] ?? null;
|
|
34
34
|
},
|
|
35
35
|
findBySlug: async (collection, slug, options) => {
|
|
36
|
-
return
|
|
36
|
+
return payload.findOne(
|
|
37
37
|
collection,
|
|
38
38
|
{
|
|
39
39
|
...options,
|
|
@@ -44,9 +44,16 @@ var db = {
|
|
|
44
44
|
}
|
|
45
45
|
);
|
|
46
46
|
},
|
|
47
|
+
find: async (collection, options) => {
|
|
48
|
+
const payload2 = await getClient();
|
|
49
|
+
return payload2.find({
|
|
50
|
+
...options,
|
|
51
|
+
collection
|
|
52
|
+
});
|
|
53
|
+
},
|
|
47
54
|
findAll: async (collection, options) => {
|
|
48
|
-
const
|
|
49
|
-
const res = await
|
|
55
|
+
const payload2 = await getClient();
|
|
56
|
+
const res = await payload2.find({
|
|
50
57
|
...options,
|
|
51
58
|
collection,
|
|
52
59
|
limit: options?.limit ?? 100
|
|
@@ -54,24 +61,24 @@ var db = {
|
|
|
54
61
|
return res.docs;
|
|
55
62
|
},
|
|
56
63
|
findByID: async (collection, id, options) => {
|
|
57
|
-
const
|
|
58
|
-
return
|
|
64
|
+
const payload2 = await getClient();
|
|
65
|
+
return payload2.findByID({
|
|
59
66
|
...options,
|
|
60
67
|
collection,
|
|
61
68
|
id
|
|
62
69
|
});
|
|
63
70
|
},
|
|
64
71
|
create: async (collection, data, options) => {
|
|
65
|
-
const
|
|
66
|
-
return
|
|
72
|
+
const payload2 = await getClient();
|
|
73
|
+
return payload2.create({
|
|
67
74
|
...options,
|
|
68
75
|
collection,
|
|
69
76
|
data
|
|
70
77
|
});
|
|
71
78
|
},
|
|
72
79
|
update: async (collection, id, data, options) => {
|
|
73
|
-
const
|
|
74
|
-
return
|
|
80
|
+
const payload2 = await getClient();
|
|
81
|
+
return payload2.update({
|
|
75
82
|
...options,
|
|
76
83
|
collection,
|
|
77
84
|
id,
|
|
@@ -79,8 +86,8 @@ var db = {
|
|
|
79
86
|
});
|
|
80
87
|
},
|
|
81
88
|
updateMany: async (collection, where, data, options) => {
|
|
82
|
-
const
|
|
83
|
-
return
|
|
89
|
+
const payload2 = await getClient();
|
|
90
|
+
return payload2.update({
|
|
84
91
|
...options,
|
|
85
92
|
collection,
|
|
86
93
|
where,
|
|
@@ -89,8 +96,8 @@ var db = {
|
|
|
89
96
|
});
|
|
90
97
|
},
|
|
91
98
|
delete: async (collection, id, options) => {
|
|
92
|
-
const
|
|
93
|
-
return
|
|
99
|
+
const payload2 = await getClient();
|
|
100
|
+
return payload2.delete({
|
|
94
101
|
...options,
|
|
95
102
|
collection,
|
|
96
103
|
id,
|
|
@@ -98,8 +105,8 @@ var db = {
|
|
|
98
105
|
});
|
|
99
106
|
},
|
|
100
107
|
deleteMany: async (collection, where, options) => {
|
|
101
|
-
const
|
|
102
|
-
return
|
|
108
|
+
const payload2 = await getClient();
|
|
109
|
+
return payload2.delete({
|
|
103
110
|
...options,
|
|
104
111
|
collection,
|
|
105
112
|
where,
|
|
@@ -107,8 +114,8 @@ var db = {
|
|
|
107
114
|
});
|
|
108
115
|
},
|
|
109
116
|
global: async (slug) => {
|
|
110
|
-
const
|
|
111
|
-
return
|
|
117
|
+
const payload2 = await getClient();
|
|
118
|
+
return payload2.findGlobal({ slug });
|
|
112
119
|
},
|
|
113
120
|
raw: getClient
|
|
114
121
|
};
|
|
@@ -116,14 +123,15 @@ var db = {
|
|
|
116
123
|
// src/payload-cms/server/create-collection.ts
|
|
117
124
|
function createCollection(collection, extend) {
|
|
118
125
|
const base = {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
find: (options) => payload.find(collection, options),
|
|
127
|
+
findOne: (options) => payload.findOne(collection, options),
|
|
128
|
+
findByID: (id, options) => payload.findByID(collection, id, options),
|
|
129
|
+
findBySlug: (slug, options) => payload.findBySlug(collection, slug, options),
|
|
130
|
+
findAll: (options) => payload.findAll(collection, options),
|
|
131
|
+
update: (id, data, options) => payload.update(collection, id, data, options),
|
|
132
|
+
updateMany: (where, data, options) => payload.updateMany(collection, where, data, options),
|
|
133
|
+
delete: (id, options) => payload.delete(collection, id, options),
|
|
134
|
+
deleteMany: (where, options) => payload.deleteMany(collection, where, options)
|
|
127
135
|
};
|
|
128
136
|
const extended = extend ? extend(base) : void 0;
|
|
129
137
|
return {
|
|
@@ -135,7 +143,7 @@ function createCollection(collection, extend) {
|
|
|
135
143
|
// src/payload-cms/server/create-global.ts
|
|
136
144
|
function createGlobal(slug, extend) {
|
|
137
145
|
const base = {
|
|
138
|
-
get: () =>
|
|
146
|
+
get: () => payload.global(slug)
|
|
139
147
|
};
|
|
140
148
|
const extended = extend ? extend(base) : void 0;
|
|
141
149
|
return {
|
|
@@ -147,6 +155,6 @@ export {
|
|
|
147
155
|
configurePayload,
|
|
148
156
|
createCollection,
|
|
149
157
|
createGlobal,
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
getPayload,
|
|
159
|
+
payload
|
|
152
160
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { CollectionSlug, DataFromCollectionSlug, DataFromGlobalSlug, GlobalSlug, Where } from 'payload';
|
|
1
|
+
import type { CollectionSlug, DataFromCollectionSlug, DataFromGlobalSlug, GlobalSlug, PaginatedDocs, Where } from 'payload';
|
|
2
2
|
import { getPayload } from './get-payload';
|
|
3
3
|
export type FindOptions = Omit<Parameters<Awaited<ReturnType<typeof getPayload>>['find']>[0], 'collection'>;
|
|
4
4
|
export type FindByIDOptions = Omit<Parameters<Awaited<ReturnType<typeof getPayload>>['findByID']>[0], 'collection' | 'id'>;
|
|
5
|
-
export type FindAllOptions = Omit<Parameters<Awaited<ReturnType<typeof getPayload>>['find']>[0], 'collection'>;
|
|
6
5
|
export type UpdateOptions = Omit<Parameters<Awaited<ReturnType<typeof getPayload>>['update']>[0], 'collection' | 'id' | 'data' | 'where'>;
|
|
7
6
|
export type DeleteOptions = Omit<Parameters<Awaited<ReturnType<typeof getPayload>>['delete']>[0], 'collection' | 'id' | 'where'>;
|
|
8
7
|
export type UpdateData = Parameters<Awaited<ReturnType<typeof getPayload>>['update']>[0]['data'];
|
|
9
|
-
export declare const
|
|
8
|
+
export declare const payload: {
|
|
10
9
|
findOne: <TSlug extends CollectionSlug>(collection: TSlug, options?: FindOptions) => Promise<DataFromCollectionSlug<TSlug>>;
|
|
11
10
|
findBySlug: <TSlug extends CollectionSlug>(collection: TSlug, slug: string, options?: FindOptions) => Promise<DataFromCollectionSlug<TSlug>>;
|
|
12
|
-
|
|
11
|
+
find: <TSlug extends CollectionSlug>(collection: TSlug, options?: FindOptions) => Promise<PaginatedDocs<DataFromCollectionSlug<TSlug>>>;
|
|
12
|
+
findAll: <TSlug extends CollectionSlug>(collection: TSlug, options?: FindOptions) => Promise<DataFromCollectionSlug<TSlug>[]>;
|
|
13
13
|
findByID: <TSlug extends CollectionSlug>(collection: TSlug, id: string | number, options?: FindByIDOptions) => Promise<DataFromCollectionSlug<TSlug>>;
|
|
14
14
|
create: <TSlug extends CollectionSlug>(collection: TSlug, data: Parameters<Awaited<ReturnType<typeof getPayload>>['create']>[0]['data'], options?: Omit<Parameters<Awaited<ReturnType<typeof getPayload>>['create']>[0], 'collection' | 'data'>) => Promise<import("payload").JsonObject & import("payload").TypeWithID>;
|
|
15
15
|
update: <TSlug extends CollectionSlug>(collection: TSlug, id: string | number, data: UpdateData, options?: UpdateOptions) => Promise<import("payload").JsonObject & import("payload").TypeWithID>;
|