@matvdt/js-toolkit 0.0.1-canary.15 → 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 -10
- 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 +38 -38
- package/dist/payload-cms/server/index.d.ts +1 -1
- package/dist/payload-cms/server/index.js +36 -36
- package/dist/payload-cms/server/{db.d.ts → payload.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -1,15 +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
|
-
find: (options?: FindOptions) => ReturnType<typeof
|
|
5
|
-
findOne: (options?: FindOptions) => ReturnType<typeof
|
|
6
|
-
findBySlug: (slug: string, options?: FindOptions) => ReturnType<typeof
|
|
7
|
-
findByID: (id: string | number, options?: FindByIDOptions) => ReturnType<typeof
|
|
8
|
-
findAll: (options?: FindOptions) => ReturnType<typeof
|
|
9
|
-
update: (id: string | number, data: UpdateData, options?: UpdateOptions) => ReturnType<typeof
|
|
10
|
-
updateMany: (where: Where, data: UpdateData, options?: UpdateOptions) => ReturnType<typeof
|
|
11
|
-
delete: (id: string | number, options?: DeleteOptions) => ReturnType<typeof
|
|
12
|
-
deleteMany: (where: Where, options?: DeleteOptions) => ReturnType<typeof
|
|
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>>;
|
|
13
13
|
};
|
|
14
14
|
type ExtensionFunction = (...args: any[]) => any;
|
|
15
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,
|
|
@@ -75,15 +75,15 @@ var db = {
|
|
|
75
75
|
);
|
|
76
76
|
},
|
|
77
77
|
find: async (collection, options) => {
|
|
78
|
-
const
|
|
79
|
-
return
|
|
78
|
+
const payload2 = await getClient();
|
|
79
|
+
return payload2.find({
|
|
80
80
|
...options,
|
|
81
81
|
collection
|
|
82
82
|
});
|
|
83
83
|
},
|
|
84
84
|
findAll: async (collection, options) => {
|
|
85
|
-
const
|
|
86
|
-
const res = await
|
|
85
|
+
const payload2 = await getClient();
|
|
86
|
+
const res = await payload2.find({
|
|
87
87
|
...options,
|
|
88
88
|
collection,
|
|
89
89
|
limit: options?.limit ?? 100
|
|
@@ -91,24 +91,24 @@ var db = {
|
|
|
91
91
|
return res.docs;
|
|
92
92
|
},
|
|
93
93
|
findByID: async (collection, id, options) => {
|
|
94
|
-
const
|
|
95
|
-
return
|
|
94
|
+
const payload2 = await getClient();
|
|
95
|
+
return payload2.findByID({
|
|
96
96
|
...options,
|
|
97
97
|
collection,
|
|
98
98
|
id
|
|
99
99
|
});
|
|
100
100
|
},
|
|
101
101
|
create: async (collection, data, options) => {
|
|
102
|
-
const
|
|
103
|
-
return
|
|
102
|
+
const payload2 = await getClient();
|
|
103
|
+
return payload2.create({
|
|
104
104
|
...options,
|
|
105
105
|
collection,
|
|
106
106
|
data
|
|
107
107
|
});
|
|
108
108
|
},
|
|
109
109
|
update: async (collection, id, data, options) => {
|
|
110
|
-
const
|
|
111
|
-
return
|
|
110
|
+
const payload2 = await getClient();
|
|
111
|
+
return payload2.update({
|
|
112
112
|
...options,
|
|
113
113
|
collection,
|
|
114
114
|
id,
|
|
@@ -116,8 +116,8 @@ var db = {
|
|
|
116
116
|
});
|
|
117
117
|
},
|
|
118
118
|
updateMany: async (collection, where, data, options) => {
|
|
119
|
-
const
|
|
120
|
-
return
|
|
119
|
+
const payload2 = await getClient();
|
|
120
|
+
return payload2.update({
|
|
121
121
|
...options,
|
|
122
122
|
collection,
|
|
123
123
|
where,
|
|
@@ -126,8 +126,8 @@ var db = {
|
|
|
126
126
|
});
|
|
127
127
|
},
|
|
128
128
|
delete: async (collection, id, options) => {
|
|
129
|
-
const
|
|
130
|
-
return
|
|
129
|
+
const payload2 = await getClient();
|
|
130
|
+
return payload2.delete({
|
|
131
131
|
...options,
|
|
132
132
|
collection,
|
|
133
133
|
id,
|
|
@@ -135,8 +135,8 @@ var db = {
|
|
|
135
135
|
});
|
|
136
136
|
},
|
|
137
137
|
deleteMany: async (collection, where, options) => {
|
|
138
|
-
const
|
|
139
|
-
return
|
|
138
|
+
const payload2 = await getClient();
|
|
139
|
+
return payload2.delete({
|
|
140
140
|
...options,
|
|
141
141
|
collection,
|
|
142
142
|
where,
|
|
@@ -144,8 +144,8 @@ var db = {
|
|
|
144
144
|
});
|
|
145
145
|
},
|
|
146
146
|
global: async (slug) => {
|
|
147
|
-
const
|
|
148
|
-
return
|
|
147
|
+
const payload2 = await getClient();
|
|
148
|
+
return payload2.findGlobal({ slug });
|
|
149
149
|
},
|
|
150
150
|
raw: getClient
|
|
151
151
|
};
|
|
@@ -153,15 +153,15 @@ var db = {
|
|
|
153
153
|
// src/payload-cms/server/create-collection.ts
|
|
154
154
|
function createCollection(collection, extend) {
|
|
155
155
|
const base = {
|
|
156
|
-
find: (options) =>
|
|
157
|
-
findOne: (options) =>
|
|
158
|
-
findByID: (id, options) =>
|
|
159
|
-
findBySlug: (slug, options) =>
|
|
160
|
-
findAll: (options) =>
|
|
161
|
-
update: (id, data, options) =>
|
|
162
|
-
updateMany: (where, data, options) =>
|
|
163
|
-
delete: (id, options) =>
|
|
164
|
-
deleteMany: (where, options) =>
|
|
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)
|
|
165
165
|
};
|
|
166
166
|
const extended = extend ? extend(base) : void 0;
|
|
167
167
|
return {
|
|
@@ -173,7 +173,7 @@ function createCollection(collection, extend) {
|
|
|
173
173
|
// src/payload-cms/server/create-global.ts
|
|
174
174
|
function createGlobal(slug, extend) {
|
|
175
175
|
const base = {
|
|
176
|
-
get: () =>
|
|
176
|
+
get: () => payload.global(slug)
|
|
177
177
|
};
|
|
178
178
|
const extended = extend ? extend(base) : void 0;
|
|
179
179
|
return {
|
|
@@ -186,6 +186,6 @@ function createGlobal(slug, extend) {
|
|
|
186
186
|
configurePayload,
|
|
187
187
|
createCollection,
|
|
188
188
|
createGlobal,
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
getPayload,
|
|
190
|
+
payload
|
|
191
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,
|
|
@@ -45,15 +45,15 @@ var db = {
|
|
|
45
45
|
);
|
|
46
46
|
},
|
|
47
47
|
find: async (collection, options) => {
|
|
48
|
-
const
|
|
49
|
-
return
|
|
48
|
+
const payload2 = await getClient();
|
|
49
|
+
return payload2.find({
|
|
50
50
|
...options,
|
|
51
51
|
collection
|
|
52
52
|
});
|
|
53
53
|
},
|
|
54
54
|
findAll: async (collection, options) => {
|
|
55
|
-
const
|
|
56
|
-
const res = await
|
|
55
|
+
const payload2 = await getClient();
|
|
56
|
+
const res = await payload2.find({
|
|
57
57
|
...options,
|
|
58
58
|
collection,
|
|
59
59
|
limit: options?.limit ?? 100
|
|
@@ -61,24 +61,24 @@ var db = {
|
|
|
61
61
|
return res.docs;
|
|
62
62
|
},
|
|
63
63
|
findByID: async (collection, id, options) => {
|
|
64
|
-
const
|
|
65
|
-
return
|
|
64
|
+
const payload2 = await getClient();
|
|
65
|
+
return payload2.findByID({
|
|
66
66
|
...options,
|
|
67
67
|
collection,
|
|
68
68
|
id
|
|
69
69
|
});
|
|
70
70
|
},
|
|
71
71
|
create: async (collection, data, options) => {
|
|
72
|
-
const
|
|
73
|
-
return
|
|
72
|
+
const payload2 = await getClient();
|
|
73
|
+
return payload2.create({
|
|
74
74
|
...options,
|
|
75
75
|
collection,
|
|
76
76
|
data
|
|
77
77
|
});
|
|
78
78
|
},
|
|
79
79
|
update: async (collection, id, data, options) => {
|
|
80
|
-
const
|
|
81
|
-
return
|
|
80
|
+
const payload2 = await getClient();
|
|
81
|
+
return payload2.update({
|
|
82
82
|
...options,
|
|
83
83
|
collection,
|
|
84
84
|
id,
|
|
@@ -86,8 +86,8 @@ var db = {
|
|
|
86
86
|
});
|
|
87
87
|
},
|
|
88
88
|
updateMany: async (collection, where, data, options) => {
|
|
89
|
-
const
|
|
90
|
-
return
|
|
89
|
+
const payload2 = await getClient();
|
|
90
|
+
return payload2.update({
|
|
91
91
|
...options,
|
|
92
92
|
collection,
|
|
93
93
|
where,
|
|
@@ -96,8 +96,8 @@ var db = {
|
|
|
96
96
|
});
|
|
97
97
|
},
|
|
98
98
|
delete: async (collection, id, options) => {
|
|
99
|
-
const
|
|
100
|
-
return
|
|
99
|
+
const payload2 = await getClient();
|
|
100
|
+
return payload2.delete({
|
|
101
101
|
...options,
|
|
102
102
|
collection,
|
|
103
103
|
id,
|
|
@@ -105,8 +105,8 @@ var db = {
|
|
|
105
105
|
});
|
|
106
106
|
},
|
|
107
107
|
deleteMany: async (collection, where, options) => {
|
|
108
|
-
const
|
|
109
|
-
return
|
|
108
|
+
const payload2 = await getClient();
|
|
109
|
+
return payload2.delete({
|
|
110
110
|
...options,
|
|
111
111
|
collection,
|
|
112
112
|
where,
|
|
@@ -114,8 +114,8 @@ var db = {
|
|
|
114
114
|
});
|
|
115
115
|
},
|
|
116
116
|
global: async (slug) => {
|
|
117
|
-
const
|
|
118
|
-
return
|
|
117
|
+
const payload2 = await getClient();
|
|
118
|
+
return payload2.findGlobal({ slug });
|
|
119
119
|
},
|
|
120
120
|
raw: getClient
|
|
121
121
|
};
|
|
@@ -123,15 +123,15 @@ var db = {
|
|
|
123
123
|
// src/payload-cms/server/create-collection.ts
|
|
124
124
|
function createCollection(collection, extend) {
|
|
125
125
|
const base = {
|
|
126
|
-
find: (options) =>
|
|
127
|
-
findOne: (options) =>
|
|
128
|
-
findByID: (id, options) =>
|
|
129
|
-
findBySlug: (slug, options) =>
|
|
130
|
-
findAll: (options) =>
|
|
131
|
-
update: (id, data, options) =>
|
|
132
|
-
updateMany: (where, data, options) =>
|
|
133
|
-
delete: (id, options) =>
|
|
134
|
-
deleteMany: (where, options) =>
|
|
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)
|
|
135
135
|
};
|
|
136
136
|
const extended = extend ? extend(base) : void 0;
|
|
137
137
|
return {
|
|
@@ -143,7 +143,7 @@ function createCollection(collection, extend) {
|
|
|
143
143
|
// src/payload-cms/server/create-global.ts
|
|
144
144
|
function createGlobal(slug, extend) {
|
|
145
145
|
const base = {
|
|
146
|
-
get: () =>
|
|
146
|
+
get: () => payload.global(slug)
|
|
147
147
|
};
|
|
148
148
|
const extended = extend ? extend(base) : void 0;
|
|
149
149
|
return {
|
|
@@ -155,6 +155,6 @@ export {
|
|
|
155
155
|
configurePayload,
|
|
156
156
|
createCollection,
|
|
157
157
|
createGlobal,
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
getPayload,
|
|
159
|
+
payload
|
|
160
160
|
};
|
|
@@ -5,7 +5,7 @@ export type FindByIDOptions = Omit<Parameters<Awaited<ReturnType<typeof getPaylo
|
|
|
5
5
|
export type UpdateOptions = Omit<Parameters<Awaited<ReturnType<typeof getPayload>>['update']>[0], 'collection' | 'id' | 'data' | 'where'>;
|
|
6
6
|
export type DeleteOptions = Omit<Parameters<Awaited<ReturnType<typeof getPayload>>['delete']>[0], 'collection' | 'id' | 'where'>;
|
|
7
7
|
export type UpdateData = Parameters<Awaited<ReturnType<typeof getPayload>>['update']>[0]['data'];
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const payload: {
|
|
9
9
|
findOne: <TSlug extends CollectionSlug>(collection: TSlug, options?: FindOptions) => Promise<DataFromCollectionSlug<TSlug>>;
|
|
10
10
|
findBySlug: <TSlug extends CollectionSlug>(collection: TSlug, slug: string, options?: FindOptions) => Promise<DataFromCollectionSlug<TSlug>>;
|
|
11
11
|
find: <TSlug extends CollectionSlug>(collection: TSlug, options?: FindOptions) => Promise<PaginatedDocs<DataFromCollectionSlug<TSlug>>>;
|